问题
I’m having some trouble with Autohotkey. I have a script with a few hotkeys but it seems that when a hotkey is pressed, not only does its handler run, but so do all lines below it, including the contents of other hotkey handlers. Below is a demonstrative example.
What is the problem? How can I get Autohotkey to execute only the lines specified in the handler?
#SingleInstance force
;Main loop
While 1
{
}
;Hotkeys:
;Quit with Ctrl+Q
^q::
{
MsgBox Quitting
ExitApp
}
^s::
{
MsgBox Hotkey1
}
MsgBox 1
^a::
{
MsgBox Hotkey2
}
MsgBox 2
回答1:
I am missing the return
command:
^s::
MsgBox Hotkey1
return
MsgBox 1
^a::
MsgBox Hotkey2
return
MsgBox 2
I guess I’m just too used to more strict C++ syntax; the braces don’t quite work the same way. I’ll just have to think back to the good old days of Basic and Assembler when working with Autohotkey scripts.
来源:https://stackoverflow.com/questions/9813484/autohotkey-hotkey-handlers-fall-through-continue-to-lines-below