Search code examples
pythonpywinauto

Python 3 | automatic open new .exe window and get his position every frame


I'm trying to make a Python 3 code that's open .exe program and get the program window x and y position every frame ( in a while )

my code so far:

from pywinauto import application


app = application.Application()
app.start("D:/GameMaker/Progects/Games/tut to next/GMnet-ENGINE-master/Builds/GMnetBaseTemplate/GMnetBaseTemplate.exe")

--

so how do I get the window's x and y positions? Thanks :D


Solution

  • Use window() to get application window, and call rectangle() method of base_wrapper class.

    x = app.window().wrapper_object().rectangle().left
    y = app.window().wrapper_object().rectangle().top
    

    This also should work:

    x = app.window().rectangle().left
    y = app.window().rectangle().top