Forum Discussion
hagai1973
10 years agoOccasional Visitor
'Function received the text box object
Function ClearTextBox(outTxtObj)
If outTxtObj.text <> "" Then
ClearTextBox = False
'Locate mouse in the left corner of edit box
outTxtObj.Click 5,10
For i = 0 to Len(outTxtObj.text)
outTxtObj.keys("[Del]")
Next
End If
If outTxtObj.text = "" Then
ClearTextBox = True
Log.Message("Edit box was cleared")
End If
End Function
kirk_bottomley
10 years agoContributor
Nice one, Hagai.
I've got one in JScript I use before sending keys to a text object. Pass in whatever property you want to search for the text field with (I usually use Name, frequently with wildcards), the parameter, and the process. It also has to be a visible object.
function ClearTextObject(ByProperty, Parameter, ProcessName)
{
var PropArray, ValuesArray, Process, Target;
var Depth = 5;
PropArray = new Array(ByProperty, "Visible");
ValuesArray = new Array(Parameter, true);
Process = Sys.Process(ProcessName);
Target = Process.FindChild(PropArray, ValuesArray, Depth);
try
{
if (Target.Exists)
{
var Text = Target.Text;
var Length = Text.length;
Target.Click();
Target.Keys("[End]");
Indicator.PushText("Backspacing the text away.");
for (i = 0; i < Length; i++)
{
Target.Keys("[BS]");
}
Indicator.PopText();
}
else
Log.Error("The object was not found.");
}
catch (err)
{
Log.Error(err.description)
}
}