[英]How to get the size and location of the taskbar with PyGTK?
有什么方法可以通过PyGTK在Windows上获取任务栏的位置和大小?
如果不是,是否至少有一种方法可以确定特定监视器上的空闲客户区? (换句话说,任务栏不占用该区域吗?)
稍微整洁(仅适用于Windows),因为这会创建一对动态变量,然后您可以使用它们来调整剩余代码的偏移量;
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
在窗口中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)
坐标处(或相对于该坐标)创建新窗口的左上角
您可以最大化窗口,并在最大化后检查其几何形状。 这样的事情(在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)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.