【发布时间】:2020-05-11 16:16:21
【问题描述】:
我一直在玩一个只使用 LeftArrow/A(向左走)、RightArrow/D(向右走)和 shift(冲刺)的游戏。我正在努力制作一个宏,该宏将根据鼠标的 x 坐标向左或向右按,并在鼠标更靠近屏幕边缘时冲刺。为了说明,将以下变量(括号中)视为我屏幕上的不同点,而“|”作为边缘:
|---短跑区---(A)---步行区---(B) 无运动(C)---步行区---(D)---短跑区--- |
如果我的 x 坐标小于 A 或大于 D,我想分别发送 SHIFT+A 或 SHIFT+D 如果我的 x 坐标在 A & B 或 C & D 之间,我想分别发送 A 或 D 我的死区将在 B 和 C 之间。
这是我的 .ahk 文件的代码:
CoordMode, Mouse, Screen
SetTimer, Check, 20
return
Check:
;The following variables are the x-coordinates of my screen, which has a res of 3840x2160
a := 965
b := 1700
c := 2160
d := 2895
MouseGetPos, x, y
return
MouseLoop:
while (x < b || x > c) {
MouseGetPos, x, y
if (x > c) {
if (x > d) {
Send +d
MouseGetPos, x, y
goto, MouseLoop
}
else if (x <= d) {
Send d
MouseGetPos, x, y
goto, MouseLoop
}
MouseGetPos, x, y
}
if (x < b) {
if (x < a) {
Send +a
MouseGetPos, x, y
goto, MouseLoop
}
else if (x >= a){
Send a
MouseGetPos, x, y
goto, MouseLoop
}
MouseGetPos, x, y
}
if GetKeyState("Esc") {
goto, Finished
}
}
return
goto, MouseLoop
Finished:
Exit
【问题讨论】:
-
您是否尝试将脚本设置为
#Persistent?
标签: autohotkey