ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Post New Requests Here

move mouse to active window

<< < (2/3) > >>

MilesAhead:
The first link seems to be in the thread I think.


Edit: I only have a single monitor system.  But playing around with the code I find, for myself, I like the mouse cursor to be near the origin.  If you try to go to the center of the window, it's interpreted differently in different types of windows.  Plus, since MouseMove by default moves relative to the active window, you don't even need to get the position of the active window to do any calculations.  In my modification I just use 16 as offset from the top left origin.  Here's my AutoHotKey variation:


--- ---~!Tab::
KeyWait, Alt
KeyWait, Tab
MouseMove,16,16
return

MilesAhead:
After experimenting I see that my script doesn't take account of minimized windows, which is a main reason to use AltTab in the first place.. Duh!!  :)

So now I get the window position and if either the x or y is < 0 then it's minimized, so I wait a short number of loops with a 1/10th second sleep for the window to open, then put the mouse cursor near the origin.  Here's the revised section of code:


--- ---~!Tab::
KeyWait, Alt
KeyWait, Tab
WinGetPos,x,y,width,height,A
While (x < 0 Or y < 0)
{
Sleep,100
WinGetPos,x,y,width,height,A
IfGreater,A_Index,2,Break
}
MouseMove,16,16
return


The rest of the code just does Tray menu stuff.

A compiled version is on my hotkeys page.

MilesAhead:
I added a call to EmptyWorkingSet to reduce the memory footprint on startup, in v. 1.2 .. avail for download.

lanux128:
for multi-monitor setup, it'd be nice if the cursor only moves when the activated window is not on the primary monitor.

MilesAhead:
for multi-monitor setup, it'd be nice if the cursor only moves when the activated window is not on the primary monitor.
-lanux128 (June 26, 2009, 01:38 AM)
--- End quote ---

I have no way to test it.  I'm using a kvma switch. (If anyone with a MM setup wants to build on the snippet I posted they're welcome to do so.)  :)

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version