I want to control current MS Edge and visit a url, say, https://edition.cnn.com/
.
Here is the code:
import pywinauto
import psutil
ids = [p.info for p in psutil.process_iter(attrs=['pid', 'name']) if 'MicrosoftEdge' in p.info['name']]
app = pywinauto.Application().connect(process=ids[0]['pid'])
Is the above correct?
How to input the url?
Thank you.
The only way I could quickly find is using Desktop
object:
from pywinauto import Desktop
d = Desktop(backend='uia')
main_window = d.window(title_re='.*- Microsoft Edge', control_type="Window")
#main_window.dump_tree() # print long output with control identifiers
# after some experiments I could find this is correct edit box
address_edit = main_window.child_window(auto_id="addressEditBox", control_type="Edit")
address_edit.set_edit_text('www.google.com')
# could not find another way to start loading the page yet
address_edit.type_keys('{ENTER}')