如果有人知道win32gui windowRec坐标是如何在多屏幕上运行的,文档中并没有太多说明:https://learn.microsoft.com/en-us/windows/win32/api/windef/ns-windef-rect
import json, win32gui
from typing import List, Optional
def getWindows() -> Optional[List]:
""" get all windows on desktop """
windowlist = []
def callback(hwnd, wl):
if win32gui.IsWindowVisible(hwnd):
dat = {}
dat['windowText'] = win32gui.GetWindowText(hwnd)
dat['x'], dat['y'], dat['x2'], dat['y2'] = win32gui.GetWindowRect(hwnd)
if dat['windowText'] == '':
return None
wl.append(dat)
print(json.dumps(getWindows(), indent=2, sort_keys=True))配置:屏幕0\#屏幕1\##.2
我在screen1上的一个窗口中运行,下面是screen0上的全屏:
{
"windowText": "xxxxx Mozilla Firefox",
"x": -32000,
"x2": -31871,
"y": -32000,
"y2": -31972
},我移动运行窗口screen0和运行,相同的窗口未动:
{
"windowText": "xxxx Mozilla Firefox",
"x": -8,
"x2": 2056,
"y": -8,
"y2": 1160
},发布于 2022-09-01 01:16:13
这将为您提供基于主监视器的参考。所以,如果你有3个显示器,你的中间一个是主显示器,左边一个是负X和弦。这就是原因所在。在一些软件(如ImageGrab等)中,0,0点不是主(中心监视器)的左上角,而是全局空间,是最左边监视器的左上角。
https://stackoverflow.com/questions/72027873
复制相似问题