[Python] Pywinauto find process window and focus it

Discussão em 'Python' iniciado por Stack, Março 21, 2025.

  1. Stack

    Stack Membro Participativo

    My current situation is that I open a process, which opens in a random location (thats how this process works).

    I have the process PID so I need to somehow focus this window, and move it to the center of my screen. Im doing something wrong as I can't even set focus on that window... tried it with different apps and got the same result...

    The way I select the window -

    appl = pywinauto.application.Application()
    appl.connect(process=824)
    app_dialog = appl.top_window_()
    app_dialog.Minimize()
    app_dialog.Maximize()

    ##app_dialog.SetFocus() ##doesn't work aswell
    ##pywinauto.win32functions.SetForegroundWindow(app_dialog)## doesn't work


    Thanks for reading :)

    Continue reading...

Compartilhe esta Página