自动热键热键处理程序会进入/继续到下面的行 [英] Autohotkey hotkey handlers fall through/continue to lines below

查看:92
本文介绍了自动热键热键处理程序会进入/继续到下面的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用Autohotkey时遇到了一些麻烦.我有一个带有几个热键的脚本,但是似乎按下一个热键时,它的处理程序不仅会运行,而且它下面的所有行(包括其他热键处理程序的内容)也会运行.下面是一个演示示例.

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.

出什么问题了?我怎样才能让Autohotkey仅执行处理程序中指定的行?

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

推荐答案

我缺少return命令:

^s::
    MsgBox  Hotkey1
return

MsgBox 1


^a::
    MsgBox  Hotkey2
return

MsgBox 2

我想我已经习惯了更严格的C ++语法;牙套的工作方式并不完全相同.在使用Autohotkey脚本时,我只需要回顾一下Basic和Assembler的美好时光.

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.

这篇关于自动热键热键处理程序会进入/继续到下面的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆