答案1
尝试这个
^!LButton::
Send #^{Left}
Click up
FocusForemostWindow()
return
^!RButton::
Send #^{Right}
FocusForemostWindow()
return
#If GetKeyState("Ctrl") and GetKeyState("Alt")
LButton::
RButton::
return
#If
; Give focus to the foremost window on the current desktop.
FocusForemostWindow() {
list := ""
WinTitle := ""
; ToolTip
; get a list of all windows on the current desktop
WinGet, id, list,,, Program Manager
Loop, %id%
{
this_ID := id%A_Index%
WinGetTitle, WinTitle, ahk_id %this_ID%
If (WinTitle="")
continue
WinGet, exStyle, exStyle, ahk_id %this_ID%
If !(exStyle & 0x100)
continue
If !IsWindowOnCurrentVirtualDesktop(this_ID)
continue
IfWinNotActive, ahk_id %this_ID%
{
WinActivate, ahk_id %this_ID%
WinWaitActive, ahk_id %this_ID%
}
; ToolTip, %WinTitle%
break
}
Sleep, 30
}
; https://autohotkey.com/boards/viewtopic.php?p=64295#p64295
; Indicates whether the provided window is on the currently active virtual desktop:
IsWindowOnCurrentVirtualDesktop(hWnd) {
onCurrentDesktop := ""
CLSID := "{aa509086-5ca9-4c25-8f95-589d3c07b48a}"
IID := "{a5cd92ff-29be-454c-8d04-d82879fb3f1b}"
IVirtualDesktopManager := ComObjCreate(CLSID, IID)
Error := DllCall(NumGet(NumGet(IVirtualDesktopManager+0), 3*A_PtrSize), "Ptr", IVirtualDesktopManager, "Ptr", hWnd, "IntP", onCurrentDesktop)
ObjRelease(IVirtualDesktopManager)
if !(Error=0)
return false, ErrorLevel := true
return onCurrentDesktop, ErrorLevel := false
}