使 win+m 后跟 win+p 执行代码
Make win+m followed by win+p execute code
我应该如何执行某些代码(即:MsgBox "Hello"
):
按win+m
不按 m 不按 win
- 按 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
LWin_m := false
return
<#p::
If (LWin_m) ; If this variable has the value "true"
msgbox "Hello"
; else
; do sth else
return
编辑:
为了不失去正常的 win+m
和 win+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
好像已经有一个很好的答案了,我只是想输入我能想到的,所以这里是早期答案的一个版本,但是没有 Send
s.
我会说没有它们的解决方案总是可取的,当然,在这么小的事情上,您将很难在实践中找到任何差异。
;runs after m is released on a LWin+m press
<#m up::
Hotkey, <#p, WinMP_Callback, On ;Enable LWin+p hotkey
KeyWait, LWin ;wait for LWin to be released
if (A_PriorKey = "m")
WinMinimizeAll ;keep win+m functional
Hotkey, <#p, , Off ;disable LWin+p hotkey
return
WinMP_Callback()
{
;do stuff
;add this at the end if you dont want
;to be able to keep running this function
;on subsequent presses of p before LWin is released
;Hotkey, <#p, , Off
}
这里的区别在于打开和关闭 LWin+p
热键以及仅使用 WinMinimizeAll
而不是发送 LWin+m
,因为它们是同一件事。
我应该如何执行某些代码(即:MsgBox "Hello"
):
按win+m
不按 m 不按 win
- 按 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
LWin_m := false
return
<#p::
If (LWin_m) ; If this variable has the value "true"
msgbox "Hello"
; else
; do sth else
return
编辑:
为了不失去正常的 win+m
和 win+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
好像已经有一个很好的答案了,我只是想输入我能想到的,所以这里是早期答案的一个版本,但是没有 Send
s.
我会说没有它们的解决方案总是可取的,当然,在这么小的事情上,您将很难在实践中找到任何差异。
;runs after m is released on a LWin+m press
<#m up::
Hotkey, <#p, WinMP_Callback, On ;Enable LWin+p hotkey
KeyWait, LWin ;wait for LWin to be released
if (A_PriorKey = "m")
WinMinimizeAll ;keep win+m functional
Hotkey, <#p, , Off ;disable LWin+p hotkey
return
WinMP_Callback()
{
;do stuff
;add this at the end if you dont want
;to be able to keep running this function
;on subsequent presses of p before LWin is released
;Hotkey, <#p, , Off
}
这里的区别在于打开和关闭 LWin+p
热键以及仅使用 WinMinimizeAll
而不是发送 LWin+m
,因为它们是同一件事。