I have an application (Royal TS) which embeds PuTTY sessions within the application's main window. However, if another application's window is obscuring the embedded PuTTY session, and I click on the embedded PuTTY session, the Royal TS window does not come to the front.
So, I tried to resolve this with the following AutoHotKey script:
LButton:: ; Detect left mouse button click
MouseGetPos, xpos, ypos, win_id ; Get mouse position and window ID
WinGetTitle, title, ahk_id %win_id% ; Get window title
WinGetClass, class, ahk_id %win_id% ; Get window class
if class=PuTTY ; If clicked in an emmbeded PuTTY window...
{ ;
IfWinExist, Royal TS ; ...and Royal TS is running...
{ ;
WinActivate ; ...bring Royal TS to the front
} ;
} ;
else ; Else, it wasn't a PuTTY window clicked...
{ ;
MouseClick, left, xpos, ypos ; ...just pass mouse button click through
} ;
return ;
This works fine...up to a point. The problem occurs when I attempt to click and hold any application's title bar to drag it (or resize an application's window) the script runs and intercepts my left button but the intention to drag or resize a window is lost because of the MouseClick command towards the end of the script.
How can I differentiate between a left-click and a left-click and drag action?