如何知道我是否有多个显示器和所有分辨率

时间:2014-12-13 10:10:18

标签: python macos multiple-monitors

我有那个代码让我移动光标并点击屏幕上的一个点。

import sys
try:
        xclick=int(sys.argv[1])
        yclick=int(sys.argv[2])
except:
        print "USAGE mouseclick [int x] [int y]"
        exit()
from Quartz.CoreGraphics import CGEventCreateMouseEvent
from Quartz.CoreGraphics import CGEventPost
from Quartz.CoreGraphics import kCGEventMouseMoved
from Quartz.CoreGraphics import kCGEventLeftMouseDown
from Quartz.CoreGraphics import kCGEventLeftMouseDown
from Quartz.CoreGraphics import kCGEventLeftMouseUp
from Quartz.CoreGraphics import kCGMouseButtonLeft
from Quartz.CoreGraphics import kCGHIDEventTap
def mouseEvent(type, posx, posy):
        theEvent = CGEventCreateMouseEvent(None, type, (posx,posy), kCGMouseButtonLeft)
        CGEventPost(kCGHIDEventTap, theEvent)
def mousemove(posx,posy):
        mouseEvent(kCGEventMouseMoved, posx,posy);
def mouseclick(posx,posy):
        mouseEvent(kCGEventLeftMouseDown, posx,posy);
        mouseEvent(kCGEventLeftMouseUp, posx,posy);
mouseclick(xclick, yclick);

不幸的是,我有一些我不想要解决的要求:

  • 如何知道屏幕分辨率以避免点击外边界。
  • 如果我在多台显示器电脑上,有没有办法知道连接的显示器数量及其分辨率?

0 个答案:

没有答案