0

最近我一直在尝试重新绑定我的罗技无线触控板的三指手势,以便在Windows 10中的桌面之间切换。我使用的代码如下:

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
XButton1::SendInput {LCtrl down}{LWin down}{Right}{LCtrl up}{LWin up}
XButton2::SendInput {LCtrl down}{LWin down}{Left}{LCtrl up}{LWin up}
#F::Send {LWin down}{Tab}{LWin up}

但是,当我按下用于 Browser_forward 和 Browser_Back 的鼠标按钮时,鼠标也会在桌面之间切换。您可以强制 AutoHotKey 仅将触控板用于其手势吗?如果是这样,怎么做?

4

1 回答 1

1

你在这里有两个选择!

  1. 您可以从激活热键中排除某些窗口
  2. 使您的热键仅在某些窗口上有效,不包括所有其他窗口

您可以通过使用#IfWinActive #If WinActive IfWinActive WinGet来做到这一点,函数和命令的许多选项用于此...

既然你提到了桌面,我很好奇如何检测桌面是否处于活动状态,结果如下:

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
$XButton1::
    If (IsDeskTopActive())
        SendInput {LCtrl down}{LWin down}{Right}{LCtrl up}{LWin up}
    Else 
        SendInput {XButton1}
Return

$XButton2::
If (IsDeskTopActive()) 
     SendInput {LCtrl down}{LWin down}{Left}{LCtrl up}{LWin up}
Else 
    SendInput {XButton2}
return

#F::Send {LWin down}{Tab}{LWin up}

IsDesktopActive() { ; Modified.. orignal by HotKeyIt
    MouseGetPos,,,win
    WinGetClass, class, ahk_id %win%
    If class in Progman,WorkerW
        Return True
    Return False
}
于 2015-10-09T22:06:25.597 回答