如何使用AutoIt v3发送长字符串以打开程序对话框

时间:2012-08-03 08:26:50

标签: autoit

我需要发送一长串输入名称来打开程序对话框。我试过send()函数,但它不能完全做到这一点。我认为因为OS上下文切换send()函数将一些字符串发送到另一个程序。

以下代码是我脚本的一部分:

$ftmp = ""
while 1
  $fname = FileReadLine($file)
  if @error = -1 then ExitLoop
  $ftmp = $ftmp & $fname & " "
WEnd  
send("^o")
WinActivate("Open Image")
sleep(100)
send($fadrs)
Sleep(200)
send("{ENTER}")
sleep(10)
send($ftmp)
Sleep(100)
send("{ENTER}")

4 个答案:

答案 0 :(得分:1)

这是我从Autoitscript得到的答案,它有效 我们应该在发送长字符串时使用controlsettext()

答案 1 :(得分:1)

ControlSend()应该是你在Send()的位置使用的。另外,我注意到你发送了一些{ENTER}击键。使用ControlClick()或ControlCommand()按下应该移动到下一个屏幕的按钮(这样更稳定)。

将()类型发送到当前聚焦的控件。 SendKeepActive()可以帮助解决这个问题,但它只会使当前窗口保持活动状态,并且不需要让您对相关控件保持活动状态。

使用AutoIt窗口信息工具获取ControlSend()/ ControlClick()函数输入的每个控件的类。

答案 2 :(得分:0)

抱歉,以下没有看到它已成功解答。我会把它留下来以防它帮助其他人。

也许既然你只是将你的Send()参数的一部分放到了windows中,你的窗口就会停用。我会尝试在每个Send()之前使用WinActivate(),并且我会在它们之间放置一点点睡眠,可能是500甚至1000.如果我正确理解问题,我认为会这样做。

抱歉,以下没有看到它已成功解答。我会把它留下来以防它帮助其他人。

答案 3 :(得分:0)

我知道还有其他一些答案,但我认为我的工作可能会更好一点?这是:

;send a large string of text instantaneously using the clipboard
ClipPut($myString)
;then you could just send ctrl + v
;Send("^v")
;or to be more precise use controlsend()
ControlSend(WindowTitle, WindowText, controlID, "^v" [, flag] )
;this way it sends instantly

希望这有帮助!