# ControlSend / ControlSetText

## Recommended Posts

Good Afternoon

I have tried to search as much as I can but I was not able to easily find the answers that I was looking for, perhaps because it is not possible.

I am trying to automate the install of a complicated piece of software that the Vendors say is not possible to automate and it is recommended to install from CD. ;-)

Anyway part of the install requires me to browse to a network location where the Database is stored, but the piece of script that I am trying to use doesn't fully enter.

but it doesn't always enter the

and the above script doesn't seem to work.

I have tested it in notepad and it works fine. :-)

Any advice or direction would be greatly appreciated as this is my first time using Auto it and until this point has been fantastic.

##### Share on other sites

What doesn't work.  You have no error handling, so you are in the dark.

I'd suggest you wait for the window to exist, and grab the handle that's returned...then wait for the control to exist, and grab the handle...then use the controlsettext with the handles captured.

Error handling all along the way, so you know exactly which piece is failing.

Simple example

Run("notepad")
$hWin = WinWait("[CLASS:Notepad]","",5) If Not IsHWnd($hWin) Then
MsgBox(1,1,"not able to get window")
Exit 1
EndIf

$hControl = ControlWait($hWin, 15, 5)
If Not IsHWnd($hWin) Then MsgBox(1,2,"not able to get control handle") Exit 2 EndIf WinActivate($hWin)
ControlFocus($hWin, "",$hControl)
If Not ControlSetText($hWin, "",$hControl,"\\somevalue\to\some\area.txt") Then
MsgBox(1,3,"not able to ControlSetText")
Exit 3
EndIf

Func ControlWait($hWindow,$Control,$iSecTimeout)$hControl = ControlGetHandle($hWindow,"",$Control)
If Not IsHWnd($hControl) Then$iTimer = TimerInit()
Do
Sleep(10)
$hControl = ControlGetHandle($hWindow,"",$Control) Until IsHWnd($hControl) Or TimerDiff($iTimer)>$iSecTimeout*1000
EndIf
Return \$hControl
EndFunc
Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

## Create an account

Register a new account