【问题标题】:AutoHotkey: how to change key behaviour when specific app is in focusAutoHotkey:如何在特定应用程序处于焦点时更改键行为
【发布时间】:2022-01-10 23:35:04
【问题描述】:

当我按下 RIGHT 时,我想另外发送 CTRL+RIGHT,以防 Windows Media Player 当前处于焦点位置。到目前为止,我取得的成就是它可以在 WMP 运行的情况下工作。如何更改脚本,使其仅在 WMP 窗口当前处于焦点时才做出反应?

SetTimer, KeepRunning
return
KeepRunning:
  ifWinActive, "Windows Media Player"
  {
     Right::Send ^{Right}{Right}
  }
return

PS:我是 AutoHotkey 的新手,所以欢迎任何其他代码建议 :)

【问题讨论】:

    标签: windows focus autohotkey


    【解决方案1】:

    查看#If 以创建上下文相关的热键和热字符串。

    #Persistent    
    #If winactive("Windows Media Player")
    Right::Send ^{Right}{Right}
    #If
    

    【讨论】:

    • #Persistent 在这里没有做任何事情,除非确实需要,否则不要使用#If#IfWinActive 在这里使用。
    • 太棒了,像魅力一样工作
    • @0x464e 使用建议的#IfWinActive 语法时,您能否发布完整的工作代码?
    • #IfWinActive, Windows Media Player 没什么特别的。虽然我可能会匹配进程的可执行文件而不是窗口的标题,如下所示:#IfWinActive, ahk_exe wmplayer.exe
    • 谢谢!为什么这样更好?顺便说一句,你知道为什么原来的解决方案在 Windows Media Player 处于全屏模式时不再起作用,而你的 .exe 则可以吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-14
    • 2018-09-08
    • 1970-01-01
    相关资源
    最近更新 更多