Is there an autohotkey function which brings the mouse pointer to the active cursor?
(assume that the active window has a active cursor, e.g., in notepad, etc.)
MouseMove, A_CaretX, A_CaretY, 0
A_CaretX and A_CaretY are the current X and Y coordinates of the caret (text insertion point). The coordinates are relative to the active window unless CoordMode is used to make them relative to the entire screen. If there is no active window or the caret position cannot be determined, these variables are blank.
https://www.autohotkey.com/docs/Variables.htm#misc
Related
The default behavior is that Emacs keeps scrolling the last line to the center of the frame. How can I keep the last line at the bottom of the frame when I scroll using the mouse?
(setq scroll-conservatively 101)
Here is the information from the *Help* window produced by describe-variable:
scroll-conservatively is a variable defined in `C source code'.
Its value is 101
Original value was 0
Documentation:
Scroll up to this many lines, to bring point back on screen.
If point moves off-screen, redisplay will scroll by up to
‘scroll-conservatively’ lines in order to bring point just barely
onto the screen again. If that cannot be done, then redisplay
recenters point as usual.
If the value is greater than 100, redisplay will never recenter point,
but will always scroll just enough text to bring point into view, even
if you move far away.
A value of zero means always recenter point if it moves off screen.
You can customize this variable.
I have a simple Autohotkey script that I want to use to determine if the mouse was clicked inside a window. I want the function to fail if the click was on the title bar or on the scroll bars of the window. My script looks like this:
LButton::
WinGetPos, X, Y, Width, Height, A
MouseGetPos, x,y
Rightmargin := Width - 50
Topmargin := Y+25
if (x < Rightmargin and y > Topmargin)
MsgBox You're Inside
return
The problem is when I run this, it freezes up my machine. All the left mouse clicks are captured and do not get through to the system and for some reason the test case always fails (I never see the MsgBox).
Can you tell me what I am doing wrong?
Variables, Labelnames and so on are case-insensitive in AutoHotkey. So, with WinGetPos, X, Y and MouseGetPos, x,y, you are allocating these two variables twice, overwriting the window's position coordinates. So, for example, you might want to rename x to mouseX and y to mouseY.
Since you obviously want your mouse coordinates being measured by the current window, you should also include coordmode, mouse, relative before your hotkey assignments.
Finally, if you also want your Click to be send to the window, includ a tilde ~ before your Hotkey: ~LButton::.
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
How do you detect which monitor my mouse pointer is on?
I am using multiple monitors, and I am trying to make an inputBox pop up in the center of the monitor where my mouse is
Right now I have the following code:
CoordMode, Mouse, Screen
MouseGetPos, X_m, Y_m
InputBox, UserInput, Title, Prompt,, 300,150,X_m, Y_m
This pops up the inputbox exactly where the mouse pointer is, but I want it to be on the CENTER of the monitor(where mouse is).
You should check SysGet.
Using the subcommand Monitor [, N] of SysGet, and MouseGetPos you can deduce which monitor the mouse is located and set the msgbox accordingly
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).