I'm looking for the best way to remember which external app window is currently active and how to make it focused/active, when it will be needed. There might be more then one window with the same name, so saving only name will not be enough.
I'm using pyautogui, mouse and keyboard modules to do mouse and keyboard events in specific app, and I want to make sure, the app window is currently active (beacause it must be).
My platform is Window 10, 64bit.
def click_element_1():
last_mouse_xy = mouse.get_position()
mouse.release(button='left')
mouse.move(element_1_x, element_1_y)
mouse.click(button='left')
mouse.move(last_mouse_xy[0], last_mouse_xy[1])
I just want to make the app window focused (when it's not), to do the clicks in it.
I don't have any problems with automation of the process, but I'm implementing functionatlity, which will allow user to do something on other applications, when actions in the target app will be only from time to time.
Even clicking on the taskbar applicaiton icon to show it window would be enough, if only I could be sure it's inactive now (in the background), because otherwise it will minimalize it :)