Reputation: 17
I need to send a long string of input names to open dialog of a program. I've tried send() function but it can't do this completely. I think because of OS context switch send() function sends some part of the string to another program.
following code is some part of my script:
$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}")
Upvotes: 1
Views: 2397
Reputation: 15919
ControlSend() should be what you're using in the place of Send(). Also, I noticed you send some {ENTER} keystrokes. Use ControlClick() or ControlCommand() to push the button that is supposed to move you to the next screen (this is more stable).
Send() types to the currently focused control. SendKeepActive() can help with this, however it only keeps the current window active and doesn't necessary keep you active on the control in question.
Use your AutoIt Window Info tool to get the classes of each control for the ControlSend()/ControlClick() function inputs.
Upvotes: 1
Reputation: 1904
I know there are a couple other answers but I think mine might work even a little bit better? Here goes:
;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
Hope this helps!
Upvotes: 0
Reputation: 2270
Sorry, didn't see it already successfully answered below. I'll leave this up just in case it helps somebody else.
Maybe since you are only getting part of your Send() argument into the windows, your window is deactivating. I would try using WinActivate() before each Send(), and also I would put a little bit longer sleep between, maybe 500 or even 1000. I think that would do it, if I understand the problem correctly.
Sorry, didn't see it already successfully answered below. I'll leave this up just in case it helps somebody else.
Upvotes: 0
Reputation: 17
This is the answer I get from Autoitscript, and it works.
we should use controlsettext() when sending long strings.
Upvotes: 1