首页 > 解决方案 > 让 win+m 后跟 win+p 执行代码

问题描述

我应该怎么做才能通过以下方式执行一些代码(即:)MsgBox "Hello"

  1. win+m

  2. 解压m而不解压win

  3. 紧迫p

标签: keyboard-shortcutsautohotkeyhotkeys

解决方案


试试这个:

<#m::                  ; "<#" means "LWin"
    LWin_m := true     ; assign the Boolean value "true" or "1" to this variable
    KeyWait, LWin, L   ; wait for LWin to be released
    LWin_m := false
return

<#p::
    If (LWin_m)        ; If this variable has the value "true" 
        msgbox "Hello"
    ; else
        ; do sth else
return

编辑:

为了不失去正常win+mwin+p试试这个:

<#m::                      ; "<#" means "LWin"
    LWin_m := true         ; assign the Boolean value "true" or "1" to this variable
    KeyWait, LWin, L       ; wait for LWin to be released
    If (A_PriorKey = "m")
        Send #m     
    LWin_m := false
return

<#p::
    If (LWin_m)  ; If this variable has the value "true" 
        msgbox "Hello"
    else
        Send #p
return

推荐阅读