Jump to content
Sign in to follow this  

ControlSend ":"

Recommended Posts


When using ControlSend to send a string to an "edit" field I get unexpected results. So, I need some guidance from the community.

I'm sending a string in the form yyyy-ddd-HH:MM:SS. For now I'm hard coding the year and time. So for now I'm sending a string that looks like this: "2012-311-13:33:33".

What I get in the edit box is something on the order of "2012-311-13:33#3". The actual value seems to vary a litle with each run. I can substitute a space or another character like an "a" for the second ":" and the string populates the box just fine. It is the second ":" that seems to be the problem.

Info Window:

>>>> Window <<<<
Title: Telemetry_Analysis
Class: TopLevelShell
Position: 100, 100
Size: 808, 702
Style: 0x16CF0000
ExStyle: 0x00000100
Handle: 0x000D03AC

>>>> Control <<<<
Class: Edit
Instance: 15
ClassnameNN: Edit15
Advanced (Class): [CLASS:Edit; INSTANCE:15]
Text: text
Position: 379, 69
Size: 139, 17
ControlClick Coords: 67, 9
Style: 0x540000C0
ExStyle: 0x00000200
Handle: 0x00230476

>>>> Mouse <<<<
Position: 550, 201
Cursor ID: 0
Color: 0xA6A6A6

Code section, it's a bit messy due to trying to troubleshoot this problem:

$step = 10
$sStartID = "Edit15"
$sStartYear = "2012"
$sStartDay = @YDAY - 30 ;;;;;;;;;;;;;; need to calculate for first 30 days of the year !!!!!
;$sStartTime = "13:33:33"
$sStartHour = "13"
$sStartMin = "33"
$sStartSec = "33"
$sStopID = "Edit14"
$sStopYear = "2012"
$sStopDay = @YDAY
$sStopTime = "13:44:44"
$sColon = ":"
$ctrlID = "ListBox3"
$sMnemonic = "ACS10000"
$sAddSelect = "Button15"
wait_win($TelemAnalysis_gui, $step)
$iWinExists = WinExists($TelemAnalysis_gui)
if $iWinExists Then
;Set start and stop times
tim_set_textbox($TelemAnalysis_gui, $sStartID, $sStartYear & "-" & $sStartday & "-" & $sStartHour & ":" & $sStartMin & $sColon & $sStartSec, $step)
tim_set_textbox($TelemAnalysis_gui, $sStopID, $sStopYear & "-" & $sStopday & "-" & $sStopTime, $step)
;ControlSend($TelemAnalysis_gui, "", $sStartID, $sStartDate & "-" & $sStartHour & ":" & $sStartMin & ":" & $sStartSec)
;ControlSend($TelemAnalysis_gui, "", $sStopID, $sStopDate & "-" & $sStopTime)
;click the add select button
listbox_select_item_clicks($TelemAnalysis_gui, $sMnemonic, $ctrlID, 1)
btn_clk($TelemAnalysis_gui, $sAddSelect, $step)
logup($TelemAnalysis_gui & " Completed " & $step)

logup("Step " & $step & " complete")

Func tim_set_textbox($win, $ctrlID, $string, $step)
jiggle_button($win, $ctrlID, 2, 30)
wait_ctrl($win, $ctrlID, 5000)
ControlFocus($win, "", $ctrlID)
;ControlSend($win, "", $ctrlID, "^{LEFT}^+{END}{DEL}")
;ControlSend($win, "", $ctrlID, "{HOME}+{END}{DEL}")
;MsgBox(0, "DEBUG", "Sending " & $string)
;ControlSend($win, "", $ctrlID, $string & "+{End}{DEL}")
;ControlSend($win, "", $ctrlID, $string & "+{END}{DEL}")
ControlSend($win, "", $ctrlID, $string)
$txt = ControlGetText($win, "", $ctrlID)
;MsgBox(0, "DEBUG", "Got " & $txt)
if $txt = $string then
logup("Step " & $step & ": text box set to " & $txt)
return 1
;TODO Add $error_tag
logup("Step " & $step & ": text box not set correctly" & $error_tag)
;TODO Add time-out
;MsgBox(0, "Script Error", "Please manually set the text box to " & $string & " then select Enter")
return 0

Edited by THeckel

Share this post

Link to post
Share on other sites

Try to send the text as "raw". That means: Add a flag to the ControlSend function:

ControlSend($win, "", $ctrlID, $string, 1)

My UDFs and Tutorials:


Active Directory (NEW 2018-12-03 - Version - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki

ADO - Wiki


Share this post

Link to post
Share on other sites

Thanks for the suggestion. Adding a "raw" (1) flag to ControlSend did not resolve the issue.

Share this post

Link to post
Share on other sites

This reproducer seems to work fine.


WinWaitActive("Untitled - Notepad")

Global Const $sColon = ':'

Global Const $send_string = @YEAR & '-' & "Tuesday" & '-' & @HOUR & ':' & @MIN & $sColon & @SEC

ControlSend("Untitled - Notepad", '', "Edit1", $send_string)

What happens if you type the string into the program manually?

Edited by LaCastiglione

Share this post

Link to post
Share on other sites

The edit box accepts the string when typed in manually.

Share this post

Link to post
Share on other sites

This issue has been noted before, but for the life of me, I can't remember who made a wrapper solution for it. I thought it was Martin, but can't find it.

Anyway, have you tried ControlSetText() ?


Maybe it was Zedna, I really don't know, I know I've seen the issue many times on the forum.

Here's a link to Zedna's solution/suggestion:

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post

Link to post
Share on other sites

Thank you for the suggestion and for the link to the history.

ControlSetText is working.

So the issue seems to be related to ControlSend specifically.

Share this post

Link to post
Share on other sites

It is appropriate for me to mention I had similar problem with controlsend here? The problem seems to be intermittent

This happens when I upload picture files. when sending a filename or directory, like "d:folder1folder2folder3image.jpg".

There are times when

1. ":"(colon) will become ":" (semi-colon)

2. "" become a pipe, "|"

A few thing I also notice.

1. if the time between a pop up dialogue box till my controlsend is too short, there is more likely for this to happen! I use sleep(250) to introduce the delay. Although the problem may still happen sometimes. If i use sleep(150), I will get the error more frequently.

2.I run a few programs at the same time, like firefox, chrome, thunderbird, itune. I suspense the system memory may have cause this problem.

These are intermittent problem. I could not generate this error consistently and therefore I could not submit a bug report.

The only way to work around was to run a loop to re-controlsend if there is an error, in my case.

Edit: I forgot to mention that similar problem happen if I use "send" too.

Edited by sktan7

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