Closed sgx-wb closed 1 year ago
Hi!
The short answer is using PyWinCtl module, like this:
import pywinctl as pwc
for win in pwc.getWindowsWithTitle("Lark"):
print("X:", win.left, "Y:", win.top, "WIDTH:", win.width, "HEIGHT:", win.height)
The long answer is:
kCGWindowOwnerName
, since it is not mandatory (see this). Even though you're interested only in "Lark" app, and it seems to fulfill this field by the moment, it is not guaranteed in the future.lark["X"]
or, as you were already doing with other values, like this: lark.get("X", None)
EDIT: Sorry I linked to the wrong page (kCGWindowName instead of kCGWindowOwnerName). kCGWindowOwnerName is mandatory, but you can not use it to address a single window in case the application launches several of them.
@Kalmat Thank you very much for your reply. This method works.
You're welcome! Just curious... which method are you eventually using?
@Kalmat It seems straightforward to obtain the value this way. lark["X"]
In macbook, I want to get the width, height and position of the software window, but the returned data type, python can not be taken directly, is there any way?