Home > Language Reference > Windows Management Functions > WriteEdit

WriteEdit

The WriteEdit function sends the specified keystrokes to the specified Edit field.

Usage

Used to simulate keystrokes being typed into an Edit field.  

Syntax

ret=WriteEdit(<edit_identifier>,<text>)

Parameters

<edit_identifier>, string, identifier of the Edit field. Use Recording mode to generate automatically the WriteEdit statement.

<text>, string, text to type into the Edit field.

Return value

ret, optional numeric return value. If the function succeeds, the return value is 0. If the function fails, the return value is a nonzero value (see Window Functions Error Codes).

Remarks

WriteEdit writes in Windows standard Edit fields. If WriteEdit does not work on your specific Edit field, use SendKeys instead such as:
towrite$="my text"
    UseWindow(<window_name_of_the_edit_field>)
    SendKeys(towrite$,NoActivate)

If you want to delete the content of the edit field before writing your text, here is an example :
towrite$="my text"
    UseWindow(<window_name_of_the_edit_field>)
    SendKeys("<Home>",NoActivate)
    pause 5 ticks
    SendKeys("<Shift <End>>",NoActivate)
    pause 5 ticks
    SendKeys("<Del>",NoActivate)
    pause 5 ticks
    SendKeys(towrite$,NoActivate)

To write in a field specified by its UIA descriptor, use WriteUIA function.

See also

SendKeys
WriteCombo
WriteEditEncrypted

Example

Shell("notepad",1)
'Type some text
UseWindow("NOTEPAD.EXE|Edit|Untitled - Notepad|1",1)
 SendKeys("Hello")
'Select Edit/Find menu
UseWindow("NOTEPAD.EXE|Notepad|Untitled - Notepad",1)
 ChooseMenu(Normal,"&Edit|&Find... Ctrl+F")
'Type Hello in the Find edit field
UseWindow("NOTEPAD.EXE|#32770|Find",1)
 WriteEdit("1","Hello")