AutoHotkey, MouseMove - autohotkey

In AutoHotkey, I want to click my mouse at position X,Y where X and Y are known but then I want it to return to the original position (arbitrary)
Right now I just have:
f::
Click 987,851
MouseMove,661,506
return
I would like to replace the 3rd line with a new method that returns it to the original position
Thanks

You need to use MouseGetPos to save the previous position, then restore it.
I think this should do it:
f::
MouseGetPos,xpos,ypos
Click 987,851
MouseMove,%xpos%,%ypos%
return

This has already been answered, but just an FYI, make sure to use SendMode Input for instant mouse movements.

Related

Trigger AHK script based on the position of the mouse

Is it possible to trigger an AHK script based on the position of the mouse? Say, if I wanted to press a button or series of buttons on my keyboard if I move my mouse to the corner or edge of the screen. Also, can this be done multiple times per second until the mouse is moved out of the specified area?
All I could find from googling is AHK scripts for moving the mouse using the keyboard, when I want to do the opposite.
I did it, thanks Aaron and ahkcoder.
I got a little better feel with Up and Down instead of PgUp and PgDn, to anyone else, play with the timings until it's sufficient. You'll also need to modify the values for the edges of your screen.
; move up and down when mouse is at edges of screen
#Persistent
SetTimer, foo, 65
return
foo:
MouseGetPos, x, y, id, control
; ToolTip, %x% %y%
; will trigger only at edges of a full screen
if (y = 1087){
; bottom
send {Down}
send {Down}
send {Down}
; sleep, 300
}
else if(y = 8){
; top
send {Up}
send {Up}
send {Up}
}
return
Yes. Easiest way I can think of to do what you are asking is to use SetTimer and MouseGetPos to evaluate the position and if it matches than trigger your script.
The 2nd example code on the MouseGetPos is using SetTimer. This should get you headed in the right direction.

How to click 2 screen regions at once and how to click without moving pointer in autohotkey

So how to click 2 screen regions at the same time or very fast one after another by using a single hotkey. The intent is to cover clicking on an object that can appear in 2 random areas of the screen by using a single key.
As an example I have tried using
a::click 735, 626 send, 750, 204 send, but it creates a loop for a few seconds, where the mouse is unresponsive and hovers in those areas, and using 2 separate hotkeys takes more time than i would wish.
I would also like to know if it is possible to issue a click command via a hotkey but not move the mouse pointer at all. I would like to set a hotkey that pressed will issue a left click command on a determined area of the screen but not move the mouse pointer in order to do so.
You definitely need to take a look at the help docs or FAQ again as well as some other examples to understand basic syntax. It is only one command per line. Here is an example of code that will get you going.
CoordMode, Mouse, Screen
SetDefaultMouseSpeed, 0 ; Sets default mouse speed to maximum
a::
MouseGetPos, X, Y ; Stores current mouse position
Click 735, 626
Click 735, 500
MouseMove, % X, % Y ; Moves mouse back to original position
Return
For the second question about issuing a click command without using the pointer, I suggest you look at the ControlClick documentation here: http://www.autohotkey.com/docs/commands/ControlClick.htm

position of the window of the menu function

I use the menu() function. The output window is in the left upper corner of the screen.
So the question is, is there a possibility to change that position?
( And of course I know the possibility with the courser )
did you try this? It works for figures for sure, not 100% sure about menus.
http://www.mathworks.es/es/help/matlab/creating_plots/positioning-figures.html?s_tid=doc_12b

How do I use CurrentCharacter in matlab?

I am trying to use the CurrentCharacter property in matlab but I don't know how it works. Could somebody give me an example? I have tried to use get(gcf,'CurrentCharacter');
Run this code and start pressing the keys on the keyboard. Observe the output on the Command Window.
f = figure;
set(f, 'KeyPressFcn', #(x,y)disp(get(f,'CurrentCharacter')))
From MATLAB documentation:
CurrentCharacter
single character
Last key pressed. MATLAB sets this property to the last key pressed in
the figure window. Use CurrentCharacter to obtain user input.
I'm not sure how you're intending to use it, but here's a simple way to demonstrate it;;
Create a figure
Click on the figure (bring it to front in the OS GUI)
Type a character (it will likely appear in your command window)
Enter kkey = get(gcf,'CurrentCharacter') in your command window
By doing this you set kkey to the first character you typed while your figure window was active.

How to find the mouse cursor index

Hi I wrote a script with the "undotext" widget,
and I'm looking for a way to get the line index of the palce where the mouse cursor is standing.
and similarly when the user has select part of the line.
To get the current location of the mouse cursor in text coordinates (not just x,y) you need to do either this:
$txt->index("current");
or this (where $x and $y give the mouse cursor location relative to the text widget):
$txt->index("#$x,$y");
The first is definitely more convenient, but the second is needed if you're in the middle of a drag (the current mark isn't updated while any mouse button is down).