【问题标题】:Autohotkey - Send key to specific Application - Media Player ClassicAutohotkey - 将密钥发送到特定应用程序 - Media Player Classic
【发布时间】:2019-12-23 11:03:31
【问题描述】:

使用 AutoHotKey,我想通过热键 (^l) 发送正斜杠键,即。 {/} 间隔 10 秒 (Sleep,10000) 后持续到媒体播放器应用程序,前提是它是活动窗口。如果任何其他窗口是活动窗口,则不应发送正斜杠。

热键 (^l) 键应该是一个切换键,即再次按下它应该停止发送正斜杠键。

(经典媒体播放器的ahk_class:) ahk_class MediaPlayerClassicW

提前感谢您的指点/帮助。

【问题讨论】:

    标签: autohotkey


    【解决方案1】:
    #IfWinActive ahk_class MediaPlayerClassicW ; only if it is the active window
    
        ^l::
           send_key := !send_key ; toggles the variable "send_key" between true and false
           if (send_key)  ; is true
                SetTimer send_the_key, 10000
            else
                SetTimer send_the_key, Off
        return
    
        send_the_key:
            If WinActive("ahk_class MediaPlayerClassicW")
                send /
            else   ; if you want to stop the timer whenever the window gets inactive
            {
                SetTimer send_the_key, Off
                send_key := false
            }
        return
    
    #IfWinActive ; turn off context sensitivity
    

    https://www.autohotkey.com/docs/commands/_IfWinActive.htm

    https://www.autohotkey.com/docs/commands/SetTimer.htm

    【讨论】:

    • 效果很好。非常感谢您不厌其烦地编写了我需要的完整代码(使用 cmets)以及指向帮助文档的指针,这将帮助我了解更多信息。
    猜你喜欢
    • 2017-09-20
    • 2018-11-12
    • 1970-01-01
    • 2021-02-24
    • 2020-11-24
    • 2012-12-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多