Autohotkey - ControlClick inside window

Autohotkey - ControlClick inside window

我有以下 运行 C&C Generals 的 ahk 脚本:

#SingleInstance ignore
CoordMode, Mouse, Relative

Run C:\Users\william\Desktop\Generals.lnk

a::Left
s::Down
d::Right
w::Up

Loop{
sleep, 500
}
Until WinExist("ahk_exe Generals.exe")

sleep, 200
SetControlDelay -1
ControlClick, 1, ahk_class #32770, "", LEFT, 10, 300, 300

Loop{
sleep, 500
}

Until WinExist("ahk_exe Generals.exe")
WinWaitClose
Exit

问题是我无法让 ControlClick 单击第二个按钮。

我已经阅读了手册,但我不明白为什么它不起作用。我什至不知道它是否会点击。

成功了:

#SingleInstance ignore
CoordMode, Mouse, Relative

Run C:\Users\william\Desktop\Generals.lnk

winWait, ahk_exe Generals.exe

Click 300, 300

winWait, ahk_exe Generals.exe
WinWaitClose
Exit

a::Left
s::Down
d::Right
w::Up

评论太多,我会改成答案:

a::Left
s::Down
d::Right
w::Up

Loop{
...

键重新映射 (s::Down) 隐含地带来了 return。与像 s::msgbox, hi 这样的热键相同的方式只是

的缩写形式
s::
    msgbox, hi
return

,键重映射只是多行的缩写形式。因此,您的脚本在 Run 命令之后已经终止。将您所有的热键、标签、函数、热字串和键重新映射放在 之后 您希望在程序启动时发生的一切。如果双击任务栏图标,您可以看到脚本行为。有关详细信息,请参阅 the auto-execute section


loop
    sleep, 500
Until WinExist("ahk_exe Generals.exe")

在 AutoHotkey 中实际上有一个特殊的命令:

winWait, ahk_exe Generals.exe

ControlClick, 1, ahk_class #32770, "", LEFT, 10, 300, 300
如果您想单击不在前台的 window,

controlClick 很有用。根据您的形象,C&C 几乎处于您的前台。所以我猜你可以简单地使用 click 命令。

另外(参见 controlClick 解释)1 作为 control-or-pos 没有任何意义.. 你所说的 300, 300 是什么意思?这些是 optionsexcludeTitle 参数


WinWaitClose

你打算用你的脚本退出游戏吗?如果不是,这条线就没有意义


Exit

如果你想保留你的脚本 运行(为了使用键重映射),退出是可以的,但 return 会更合适。如果要退出整个脚本,请使用 exitapp 而不是


The problem is that I can't get the ControlClick to click the second button.

什么按钮??