Python 3 |自动打开新的.exe window 并每帧获取他的位置

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

我正在尝试制作一个 Python 3 代码,它打开 .exe 程序并获取程序 window 每帧的 x 和 y 位置(稍后)

到目前为止我的代码:

from pywinauto import application


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

--

那么如何获得 window 的 x 和 y 位置? 谢谢 :D

使用 base_wrapper class 的 window() to get application window, and call rectangle() 方法。

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

这也应该有效:

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