1

有什么方法可以使用 PyGTK 在 Windows 上获取任务栏的位置和大小?

如果没有,是否至少有一种方法可以确定特定显示器上的空闲客户区?(也就是说,任务栏占据的区域?)

4

2 回答 2

0

您可以最大化窗口,并在最大化后检查其几何形状。像这样的东西(适用于 Windows 和 Linux):

import gtk

size = (10, 10)
def expose(widget, *args):
    global size
    size = widget.get_size()
    if size != (10, 10):
        gtk.main_quit()

win = gtk.Window()
win.resize(*size)
win.connect('expose-event', expose)
win.show()
win.maximize()
gtk.main()
print size

这有点骇人听闻,但我不确定是否有可移植的方式(如果您在 Windows 上则不使用 Win32 API)来执行此操作。

于 2011-04-24T09:17:29.227 回答
0

稍微整洁(但仅限于窗口),因为这会创建一对动态变量,然后您可以使用它们来调整剩余代码的偏移量;

import win32gui

#discover where top left corner of active screen is
#return is a dictionary list of keys and values
monitors = win32api.EnumDisplayMonitors()
display1 = win32api.GetMonitorInfo(monitors[0][0])

#from the Work key, select the first and second values
x_adj=(display1['Work'][0])
y_adj=(display1['Work'][1])

然后,在您的代码的其余部分中,使用这些调整来优化您的导航点击。就我而言,我正在使用pyautogui

import pyautogui

#just move the mouse to a position
pyautogui.moveTo(x=103+x_adj, y=235+y_adj)

#move and click the mouse
pyautogui.click(x=103+x_adj, y=235+y_adj)

在您的情况下,您将希望在(或相对于)的坐标处创建新窗口的左上角(x_adj,y_adj)

于 2016-11-15T14:49:30.230 回答