繁体   English   中英

当我更改 AutoHotKey 中的组合框值时,编辑字段中的值不断更改为默认值

[英]The value in the edit field keeps changing to default value when I change the comboBox value in AutoHotKey

我正在尝试使用 AutoHotKey 自动输入软件的输入。 输入参数之一是下拉列表。 另一个是文本字段。 我首先需要填写文本字段,然后选择一个下拉选项。 一旦下降淹没选项发生变化,就需要输入同一文本字段的新值。 手动执行此操作不会更改先前的文本值。

也就是说我选择选项1并输入“hello world”然后我选择选项2并输入“hi world”让我们说默认值为“default”

该软件的功能是在我们输入时保持与选项相关联的文本值。 所以我可以在选项和文本值之间来回显示。

但是,当我尝试自动执行此操作时,之前输入的文本会更改为默认值。 如果我在选项之间来回切换,这些值就会变成默认值。

我使用 python 来运行 autohotkey 脚本。 为了清楚起见,我还上传了部分代码和一些图片。

AHK代码:

SetControlDelay -1
ControlSetText, Edit7, 452000, ahk_exe PerRoad44.exe
SetControlDelay -1
Control, Choose, 3, ComboBox1, ahk_exe PerRoad44.exe
ControlSetText, Edit7, 452000, ahk_exe PerRoad44.exe

蟒蛇代码:

import autopy
from ahk import AHK
from Configuration import Config

ahk = AHK()

ahk.run_script('Run ' + Config.SOFTWARE_PATH)
ahk = AHK()
winStructInputTab = ahk.find_window(title=b'PerRoad 4.4')
winStructInputTab.send(autopy.key.tap(autopy.key.Code.F1)) # this opens up the input tab of the software
ahk.run_script('SetWinDelay, 10')
ahk.run_script('SetWinDelay, 1000')
f = open(r"h2.ahk", "r")
ahk_script = f.read()
print(ahk_script)
ahk.run_script(ahk_script, blocking=False)

我找不到任何解决方案。 请帮我解决这个问题。 谢谢

当前季节是下拉菜单,模数是我尝试设置的文本字段

我从链接( https://autohotkey.com/board/topic/48737-changed-the-value-of-an-edit-control-which-is-taken-over/ )找到了解决问题的方法。

修改后的代码应为以下类型:

ControlClick, Edit7, ahk_exe PerRoad44.exe
ControlSetText, Edit7,,ahk_exe PerRoad44.exe
ControlClick, Edit7, ahk_exe PerRoad44.exe
ControlSend, Edit7, {Home}+{End}, ahk_exe PerRoad44.exe
Control, EditPaste, 55000, Edit7, ahk_exe PerRoad44.exe

ControlFocus, ComboBox1, ahk_exe PerRoad44.exe
Control, Choose, 3, ComboBox1, ahk_exe PerRoad44.exe

ControlClick, Edit7, ahk_exe PerRoad44.exe
ControlSetText, Edit7,,ahk_exe PerRoad44.exe
ControlClick, Edit7, ahk_exe PerRoad44.exe
ControlSend, Edit7, {Home}+{End}, ahk_exe PerRoad44.exe
Control, EditPaste, 55000, Edit7, ahk_exe PerRoad44.exe

这解决了我的问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM