I am using the pywinauto module in python (3.7.4) on Microsoft Windows to automate a window on desktop. I need to make various functionalities to perform tasks on a window opened on the desktop like getting a window, focus on a window , maximize and minimize, close a window,move and resize window or check if the window is active or not. Following is my code
from pywinauto import application
import time
app=application.Application()
app.start('Notepad.exe')
time.sleep(5)
app1 = app.top_window()
this is the basic code to open any application and then I need to make other tasks on separate scripts as user inputs.
The following is to focus on the window ,maximize or minimize or close the window application or resize a window
app1.set_focus()
time.sleep(2)
app1.maximize()
time.sleep(2)
app1.minimize()
app1.close()
app.Notepad.move_window(0,0,1280,700)
I need to work on more functionalities but can't seem to understand what to do
- How do I check if a window is active or not(state of the window)
- How do I get all the current windows opened on the desktop
- I am using move_window to resize the window , keeping x and y coordinates as 0 but how do I keep the size of the window same and just move it by the x and y coordinates
- And I am using app.start() to run an application but if I need to run an already existing excel file or a pdf file so do I need to put the executable paths of excel or adobe as well as the path of the file I need to open and if yes how do I perform that