Goal: I want to retrieve with Python the IE instance that is running on my computer in order to listen to all click events inside the HTML Document.
Python interpreter: 3.7
My Solution: In order to retrieve the IE instance, I thought that one solution would be by means of the PID. Once I have the IE instance, I could create an event listener with this object and see where user has clicked and record the information of the button or element that was clicked.
For that reason, what I did so far was to retrieve the HWND of the current IE instance that is located on the foreground by means of Pyhook library. With this HWND and win32process I got the Process ID (PID).
Is there a better approach to do that?. Thanks for your help in advance
Current code:
Getting the pid of a particular HWND
tid,pid = win32process.GetWindowThreadProcessId(hwnd)
With Pyhook I can retrieve the HWND with Window property
hwnd = event.Window