暂停 AHK 脚本
Suspend AHK script
我正在为 AHK 编写一个脚本,它可以在我的 MMORPG 游戏中自动执行一些操作。
我想在按下 F2 或 F3 时执行 2 种不同的自动化。
有时此脚本与 keyboard/mouse 中的另一个动作交互,因此我需要在按下以下键之一时暂停脚本:2,3,4,5,E,R
但是当我按 1 时,脚本需要取消挂起。
我尝试了很多不同的选项,但我写不出来。我什至不能 google 任何类似的东西。
我的代码是这样的:
key_a:="F2"
key_b:="F3"
loop {
sleep 1
if GetKeyState(key_a) {
a:=true
b:=false
}
if GetKeyState(key_b) {
a:=false
b:=true
}
if a {
MsgBox, Do something
}
if b {
MsgBox, Do somethiung else
}
}
这种脚本语言对我来说有点陌生。
你能帮帮我吗?
谢谢
尝试:
key_a:="F2"
key_b:="F3"
SetTimer, keyStates, 100
KeyStates: ; SubRoutine
if GetKeyState(key_a, "P") {
a:=true
b:=false
}
if GetKeyState(key_b, "P") {
a:=false
b:=true
}
if a {
ToolTip, F2 is doing something
}
if b {
ToolTip, F3 is Doing Something!
}
return
2::
3::
4::
5::
E::
R::SetTimer, keyStates, Off
1::SetTimer, keyStates, on
我正在为 AHK 编写一个脚本,它可以在我的 MMORPG 游戏中自动执行一些操作。 我想在按下 F2 或 F3 时执行 2 种不同的自动化。
有时此脚本与 keyboard/mouse 中的另一个动作交互,因此我需要在按下以下键之一时暂停脚本:2,3,4,5,E,R
但是当我按 1 时,脚本需要取消挂起。
我尝试了很多不同的选项,但我写不出来。我什至不能 google 任何类似的东西。
我的代码是这样的:
key_a:="F2"
key_b:="F3"
loop {
sleep 1
if GetKeyState(key_a) {
a:=true
b:=false
}
if GetKeyState(key_b) {
a:=false
b:=true
}
if a {
MsgBox, Do something
}
if b {
MsgBox, Do somethiung else
}
}
这种脚本语言对我来说有点陌生。
你能帮帮我吗? 谢谢
尝试:
key_a:="F2"
key_b:="F3"
SetTimer, keyStates, 100
KeyStates: ; SubRoutine
if GetKeyState(key_a, "P") {
a:=true
b:=false
}
if GetKeyState(key_b, "P") {
a:=false
b:=true
}
if a {
ToolTip, F2 is doing something
}
if b {
ToolTip, F3 is Doing Something!
}
return
2::
3::
4::
5::
E::
R::SetTimer, keyStates, Off
1::SetTimer, keyStates, on