【问题标题】:Hotkeys to override default Windows shortcuts don't always work覆盖默认 Windows 快捷方式的热键并不总是有效
【发布时间】:2021-10-08 03:22:02
【问题描述】:

我定义了热键来覆盖默认的单独 Windows 键行为以及启动备用文件资源管理器应用程序的 Win+E 快捷方式。大多数时候它有效,但有时它不起作用。我无法确定何时失败的模式。当它确实失败时,所看到的行为是启动了默认的 Windows 文件资源管理器。我能够从最近一次失败时获取关键历史记录。

有什么我可以添加到我的脚本或做不同的事情来使我的自定义快捷方式更可靠的吗?

AHK 代码:

#SingleInstance force
#NoTrayIcon
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SetTitleMatchMode, 2  ; match anywhere in the title
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
GroupAdd, grpExplorer, ahk_class CabinetWClass
GroupAdd, grpExplorer, ahk_class ExploreWClass
GroupAdd, grpExplorer, ahk_class #32770
~LWin::Send {Blind}{vkFF}
~RWin::Send {Blind}{vkFF}
LWin UP::
RWin UP::
    if (A_PriorKey = "LWin" || A_PriorKey = "RWin")
    {
        SendInput, {F13}
    }
    return
#e UP::
    explExe := "C:\PortableApps\Explorer++Portable\Explorer++Portable.exe"
    if (FileExist(explExe))
    {
        IfWinExist, ahk_class Explorer++
        {
            WinActivate
        }
        else
        {
            Run, %explExe%
        }
    }
    else
    {
        Run, c:\windows\explorer.exe /e, ::{450D8FBA-AD25-11D0-98A8-0800361B1103}
        WinWait, ahk_group grpExplorer, , 5
        WinActivate
    }
    return
$!#e UP::
    Run, c:\windows\explorer.exe /e, ::{450D8FBA-AD25-11D0-98A8-0800361B1103}
    WinWait, ahk_group grpExplorer, , 5
    WinActivate
    return

这里是关键的历史转储。看起来钥匙被识别得很好。

Window: C:\AHK\KeyRemapping.ahk - AutoHotkey v1.1.33.02
Keybd hook: yes
Mouse hook: yes
Enabled Timers: 0 of 0 ()
Interrupted threads: 0
Paused threads: 0 of 0 (0 layers)
Modifiers (GetKeyState() now) = 
Modifiers (Hook's Logical) = 
Modifiers (Hook's Physical) = 
Prefix key is down: no

NOTE: To disable the key history shown below, add the line "#KeyHistory 0" anywhere in the script.  The same method can be used to change the size of the history buffer.  For example: #KeyHistory 100  (Default is 40, Max is 500)

The oldest are listed first.  VK=Virtual Key, SC=Scan Code, Elapsed=Seconds since the previous event.  Types: h=Hook Hotkey, s=Suppressed (blocked), i=Ignored because it was generated by an AHK script, a=Artificial, #=Disabled via #IfWinActive/Exist, U=Unicode character (SendInput).

VK  SC  Type    Up/Dn   Elapsed Key     Window
-------------------------------------------------------------------------------------------------------------
5B  15B h   d   12.20   LWin            
FF  000 i   d   0.00    not found       
FF  000 i   u   0.00    not found       
45  012     d   0.45    e               
45  012     u   0.11    e               File Explorer
5B  15B h   u   0.09    LWin            
01  000     d   5.50    LButton         
01  000     u   0.22    LButton         C:\AHK\KeyRemapping.ahk - AutoHotkey v1.1.33.02
74  03F     d   1.44    F5              
Press [F5] to refresh.

【问题讨论】:

    标签: keyboard-shortcuts autohotkey


    【解决方案1】:

    从来没有任何问题(我经常使用 WinKey),尝试使用 UI Access 运行脚本。 (docs)

    【讨论】:

      猜你喜欢
      • 2011-04-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-04
      • 1970-01-01
      • 1970-01-01
      • 2016-08-27
      • 1970-01-01
      相关资源
      最近更新 更多