How to get result from ms calculator text field, which displays result of any math operations? Swapy (v.0.4.3) shows me that this text field has value of 'Static2', after running so simple script i get empty list. Here my code:
from pywinauto import *
n=[]
app=Application()
app.start_("calc.exe")
app.calc.Button11.ClickInput()
app.calc.Button20.ClickInput()
app.calc.Button11.ClickInput()
app.calc.Button21.ClickInput()
n=app.calc.Static2.Texts()#here i expected to get the number
print n
Where i did wrong?
pywinauto is a set of python modules to automate the Microsoft Windows GUI. At its simplest it allows you to send mouse and keyboard actions to windows dialogs and controls.
You can check to see if there's a specific hotkey to close the program. However, the easiest way to do this is to send Alt-F4.
Try
text = app.calc.Static3.window_text()
As I can see in Spy++, Notepad.exe (Win7 version) has 4 static boxes. The third one has non-empty text. So you need to identify it by "Static3" name, because "Static1" and "Static0" identifies the same static box (that's a bit strange, yes - it's pywinauto feature).
For more detailed investigation use
app.calc.print_control_identifiers() # or .dump_tree()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With