1
votes

I have performed some tasks on an application and now I want to close it's window but I don't want to kill the process (ie. it should keep running in system tray).

What's the correct way to do it in pywinauto? I am thinking about using pyautogui as a last resort.

NOTE: The application does not have a file menu.

1

1 Answers

3
votes

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.

app.type_keys("%{F4}") # Alt-F4

or

app.send_keys("{VK_MENU}{F4}")

This is explained in the documentation