Autohotkey hotkey handlers fall through/continue to lines below

我们两清 提交于 2019-12-24 10:44:31

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!