This code in particular, move the mouse cursor to the centre of the active window(no matter the screen where the window is) when ALT+TAb is pressed:
~!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,width/2,height/2 returnNow what I want is run this script when the active window change. So it can be used not only when I press ALT+TAb since there are many ways to change active window (like 3rd party software, or Window Taskbar).
I introduce this example for a better understanding: (By windows I mean plural of window)
I have 2 screens, A and B. There are 2 windows, 1 and 2. The window 1 is in the screen A and the window 2 is in the screen B.
The window 1 is currently focused( or active), now when I change using the taskbar to window 2(now the active window is the window 2) run the script.
Is that possible? Any idea?
Regards.