mhd
mhd

Reputation: 43

Pywinauto - select all data from a field

Is there any function that can be used to select all data(strings) from a field?

E.g. when you want to delete all the data from a field, and you manually select it and press delete.

I am currently doing this with DoubleClick() and Backspace key, but if the string contains spaces(e.g. "This is a string") it will only select the first word.

Upvotes: 0

Views: 4185

Answers (1)

Vasily Ryabov
Vasily Ryabov

Reputation: 9991

It looks like you mean edit box text. The following code should help:

from pywinauto.application import Application
app = Application().start('notepad.exe')
app.UntitledNotepad.Edit.set_edit_text(u'some text')
app.UntitledNotepad.Edit.set_edit_text(u'') # clean-up

It works silently (edit box can be out of focus).

For non-standard controls you may call .type_keys('^a{BACKSPACE}') if Ctrl+A is handled by the control.

Upvotes: 7

Related Questions