Phantom Documentation

[Help Home] [Phantom Home]
SetText

window.SetText(sText);

Applicable Classes:
Edit, ComboBox, ListBox, MainWin, Static

Parameters:
string sText - A string containing the text to be sent to the window.
Return Value: None

Description:
SetText replaces the current text in a window or control with the text contained in sText.  sText must be of type 'string'.  If there is no text currently in the window, SetText places sText in the window. SetText can receive an empty string ("") to clear the text field.

If SetText is called on a frame window, it will change the title (and the tag) of that window. Therefore, when using SetText on a frame window (or any other window referenced using a string tag as opposed to a numeric tag), the window should be accessed using a 'window' variable, with the handle set using 'SetHandle'. This will allow Phantom to know what window is being automated using a numeric ID rather than a text tag and class, so the title (and therefore the tag) can be changed freely

Example Code

System("c:\\windows\\system32\\Notepad.exe");

# Create the window variables
# Want to use GetHandle, since Notepad's title will change
int i = MainWin("Notepad*", "Notepad").GetHandle();
window w;
window e = MainWin("Notepad*", "Notepad").MainWin(1, "Edit");
w.SetHandle(i);

# Set the text of both the edit box and the Notepad window
e.SetText("Hello");
w.SetText("Some Other Title");



See Also: Edit Functions, MainWin Functions, GetHandle, SetHandle


Copyright 2000-2011 Phantom Automated Solutions