Hi,
I'm using a touchscreen as my 3rd monitor but each time I touch something on it the window on my main monitor will lose focus so I have to Alt+Tab.
Is there any way to detect click (not swap/scroll) on the 3rd monitor and then switch back to the window on the main screen?
PS: Total noob, need to work so I can't invest time into learning AHK at the moment.
Thanks
Activate window after click in other monitor
Re: Activate window after click in other monitor
Try if this works. It's a bit complicated to leave all the normal functions of the mouse intact but this seems to work quite well:
Note that the mouse is not moving back to the original window. It might be possible via OnMessage() but that's to much for today.
Let me know how this works.
Code: Select all
SysGet, MonCount, MonitorCount
SysGet, 3rdMon, Monitor, 3 ; Assuming you touchscreen is monitor 3.
; The abonve command writes 3rdMonLeft, 3rdMonTop, 3rdMonRight and 3rdMonBottom
; with the bounding coordinates of the 3rd monitor.
#If MonCount>2
$LButton::
CoordMode, Mouse, Screen
MouseGetPos, Mx, My ; Get the new position of the mouse.
; Check if the click was on the 3rd monitor.
If (Mx >= 3rdMonLeft) AND (Mx <= 3rdMonRight) AND (My >= 3rdMonTop) AND (My <= 3rdMonBottom)
{
; The mouse press was on the 3rd monitor, wether it was a mouse or a touchscreen click.
OldWinHandle := WinExist("A") ; Save the old window to activate is later.
SEND, {Blind}{Click Down}
KeyWait, LButton
WinActivate, ahk_id %OldWinHandle%
} Else {
SEND, {Blind}{Click Down}
;MsgBox, PriMon=%PriMon%`nMonCount=%MonCount%`n`3rdMonLeft=%3rdMonLeft%`n3rdMonTop=%3rdMonTop%`n3rdMonRight=%3rdMonRight%`n3rdMonBottom=%3rdMonBottom%
}
Return
~LButton Up::
#If
Let me know how this works.
Who is online
Users browsing this forum: No registered users and 370 guests