Jump to content
Sign in to follow this  

Problem with Send()

Recommended Posts


I've got a script that opens mspaint.exe and pastes a screenshot into it from the clipboard. It then tries to save the image to a specific filename. However, about half of the attempts have dropped characters during the Send(). For example:

$Filename = "C:\TopDir\MidDir\LowDir\FileName"


This leads to some pretty strange results when the directory names get munged. Is there any way, besides slowing the KeyDelay setting way down, to insure that the characters that I sent were actually received by the control? (Even with it turned down to 1000 ms it still drops characters.)



Share this post

Link to post
Share on other sites

are you sure your path does not include any escape charactors for the send command?

Share this post

Link to post
Share on other sites

did you try sending it raw with a flag of 1?

Send("!@#$%^&*()a bunch of crap...", 1)

or try ControlSetText() if it is applicable

Edited by danwilli

Share this post

Link to post
Share on other sites

Holy Cow! You folks are fast!


1 - there are no control or escape characters in the string.

2 - The ControlSetText function looks interesting, but I haven't tried it yet.

3 - The ClipPut() and Send("^v") seems to be working. (so far...)

I'll let the sim run tonight and let you know if I've still got problems.

Thanks for all the suggestions!


Share this post

Link to post
Share on other sites

You could/should check what you send (or set) in a field like that.

Run this little demo:

WinWait("untitled - Paint")
WinActivate("untitled - Paint")
WinWaitActive("untitled - Paint")

;paste stuff into Paint here

WinMenuSelectItem("untitled - Paint", "", "&File", "Save &As")
WinWait("Save As")
WinActivate("Save As")
WinWaitActive("Save As")

$Path = "C:\TopDir\MidDir\LowDir\FileName"
ControlSetText("Save As", "", "Edit1", $Path)

$PathCheck = ControlGetText("Save As", "", "Edit1")
If $Path == $PathCheck Then
    TrayTip("$PathCheck", $PathCheck, 111)
    TrayTip("$PathCheck bad", $PathCheck, 111)
    MsgBox(0, "", "you lose")
;more code here
A TrayTip may not be practical in the final script. You can take whatever action you wish if what you sent/set is not what "arrived". You could also check the window title for the file name to see that the save went as planned and/or do a FileExists check.

hope this helps


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this