当前位置: 首页>>代码示例>>Python>>正文


Python PyMouse.screen_size方法代码示例

本文整理汇总了Python中pymouse.PyMouse.screen_size方法的典型用法代码示例。如果您正苦于以下问题:Python PyMouse.screen_size方法的具体用法?Python PyMouse.screen_size怎么用?Python PyMouse.screen_size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pymouse.PyMouse的用法示例。


在下文中一共展示了PyMouse.screen_size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Robot

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import screen_size [as 别名]
class Robot(object):

    def __init__(self):
        self.mouse = PyMouse()
        self.keyboard = PyKeyboard()
        self.przyciskPSP2klawiatura = {'up': 'w', 'right': 'd', 'down': 's', 'left': 'a', 'triangle': self.keyboard.enter_key,
                                       'circle': 'f', 'cross': 'g', 'square': 'h', 'l': self.keyboard.control_r_key, 'r': self.keyboard.shift_r_key, 'start': 'k', 'select': 'l'}

    def reaguj(self, x, y, przyciskPSP2Stan):
        self.reaguj_mysz(x, y)
        self.reaguj_klawiatura(przyciskPSP2Stan)

    def reaguj_mysz(self, x, y):
        max_predkosc_kursora = 0.00000000000000000000000000000000000000000000000000001
        x += int((x / float(128)) * max_predkosc_kursora +
                 self.mouse.position()[0])
        y += int((y / float(128)) * max_predkosc_kursora +
                 self.mouse.position()[1])
        x, y = min(self.mouse.screen_size()[0], x), min(
            self.mouse.screen_size()[1], y)
        x, y = max(0, x), max(0, y)
        self.mouse.move(x, y)

    def reaguj_klawiatura(self, przyciskPSP2Stan):
        for przycisk_psp, czyWcisniety in przyciskPSP2Stan.iteritems():
            przycisk_klawiaturowy = self.przyciskPSP2klawiatura[przycisk_psp]
            if czyWcisniety == '1':
                if przycisk_klawiaturowy == 'g':
                    self.mouse.click(*self.mouse.position())
                    break
                self.keyboard.press_key(przycisk_klawiaturowy)
            else:
                self.keyboard.release_key(przycisk_klawiaturowy)
开发者ID:ILoveMuffins,项目名称:psp-rmt-ctrl,代码行数:35,代码来源:Robot.py

示例2: show_mouse_position

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import screen_size [as 别名]
def show_mouse_position():
    # import the module
    from pymouse import PyMouse
    m = PyMouse()
    m.move(200, 200)

    # click works about the same, except for int button possible values are 1: left, 2: right, 3: middle
    m.click(500, 300, 1)

    # get the screen size
    m.screen_size()
    # (1024, 768)

    # get the mouse position
    m.position()
开发者ID:kamekame,项目名称:alpha,代码行数:17,代码来源:f.py

示例3: __init__

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import screen_size [as 别名]
class Mouse:
    def __init__(self):
        import autopy
        from pymouse import PyMouse

        self.m1 = autopy.mouse
        self.loc = [self.m1.get_pos()[0],self.m1.get_pos()[1]]
        self.m = PyMouse()
        self.m.move(self.loc[0], self.loc[1])

    def move(self,direction):
        #Move mouse
        self.loc[0] += direction[0]
        self.loc[1] += direction[1]
        #FIXME: Support multiple displays
        #Check horizontal bounds
        self.loc[0] = min(self.loc[0],3600)#self.m.screen_size()[0])
        self.loc[0] = max(self.loc[0],0)
        #Check vertical bounds
        self.loc[1] = min(self.loc[1],self.m.screen_size()[1])
        self.loc[1] = max(self.loc[1],0)
        self.m.move(int(self.loc[0]), int(self.loc[1]))

    def click(self,button):
        self.m1.click(button)
开发者ID:trafficone,项目名称:ControllerKeyboard,代码行数:27,代码来源:controller.py

示例4: netflix_continue

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import screen_size [as 别名]
def netflix_continue():
    m = PyMouse()
    x, y = m.screen_size()
    m.click(x/2, y/2-60)
    time.sleep(0.33)
    m.move(x/2, 0)
    return ""
开发者ID:mhielscher,项目名称:htpc-control,代码行数:9,代码来源:htpc.py

示例5: __init__

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import screen_size [as 别名]
class MenuOjoData:

    DEGREEE_PATTERN = r"(?P<degree_data>[+-]\d{2})"

    def __init__(self):
        self.driver = PantojoBluetoothReceiver()
        self.pipes = [PantojoRealDataPipe()]
        self.mouse = PyMouse()
        (self.x_max, self.y_max) = self.mouse.screen_size()
        self.degree = re.compile(self.DEGREEE_PATTERN, re.VERBOSE)

    def open(self):
        self.driver.open()

    def recv(self):
        data = self.driver.recv()
        for pipe in self.pipes:
            data = pipe.apply(data)
        matched = self.degree.match(data)
        if matched:
            valor = int(data)
        (x, y) = self.mouse.position()
        if (valor != 0):
            #asumo que se mueve de a 15
            mov = (self.x_max / 7) * (valor / 15) + x
            self.mouse.move(mov, y)
        else:
            self.mouse.move(self.x_max / 2, y)
        return data

    def close(self):
        self.driver.close()
开发者ID:menuojo,项目名称:dev_python,代码行数:34,代码来源:movecursorbluetooth.py

示例6: main

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import screen_size [as 别名]
def main():
    mouse = PyMouse()

    # 	wm = cwiid.Wiimote("00:25:A0:CE:3B:6D")
    wm = cwiid.Wiimote()
    wm.rpt_mode = cwiid.RPT_BTN | cwiid.RPT_IR

    X, x = calibrate(wm)
    trans = getTransMatrix(x, X)

    screen = mouse.screen_size()
    lastTime = time.time()
    o = None

    state = NEUTRAL

    print("battery: %f%%" % (float(wm.state["battery"]) / float(cwiid.BATTERY_MAX) * 100.0))

    window = pygame.display.set_mode((200, 150))

    while True:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                sys.exit(0)

        pos = getWiiPointNonBlock(wm)

        if pos != None:
            ipt = numpy.matrix([[pos.x], [pos.y], [1]])
            optMat = trans.I * ipt
            o = Point(optMat[0] / optMat[2], optMat[1] / optMat[2])

            if o.x < 0:
                o.x = 0
            elif o.x >= screen[0]:
                o.x = screen[0] - 1

            if o.y < 0:
                o.y = 0
            elif o.y >= screen[1]:
                o.y = screen[1] - 1

            if state == NEUTRAL:
                state = FIRST_INPUT
                lastTime = time.time()
            elif state == FIRST_INPUT:
                if time.time() - FIRST_INPUT_TO_PRESSED > lastTime:
                    mouse.press(o.x, o.y)
                    state = PRESSED
            elif state == PRESSED:
                mouse.move(o.x, o.y)

        if state == FIRST_INPUT and pos == None and time.time() - FIRST_INPUT_TO_PRESSED < lastTime:
            mouse.click(o.x, o.y)
            time.sleep(0.2)
            state = NEUTRAL

        if state == PRESSED and pos == None and time.time() - 1 > lastTime:
            mouse.release(o.x, o.y)
            state = NEUTRAL
开发者ID:mrhubbs,项目名称:WiiTouch,代码行数:62,代码来源:WiiTouch.py

示例7: test_size

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import screen_size [as 别名]
 def test_size(self):
     for size in screen_sizes:
         try:
             disp = Display(visible=VISIBLE, size=size).start()
             mouse = PyMouse()
             eq_(size, mouse.screen_size())
         finally:
             disp.stop()
开发者ID:dsuarez,项目名称:PyMouse,代码行数:10,代码来源:test_unix.py

示例8: __init__

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import screen_size [as 别名]
class HostDeviceClass:

  def __init__(self):
    self.m = PyMouse()
    self.screen = HelperClasses.ScreenClass(self.m.screen_size()[0], self.m.screen_size()[1])
    self.cursor = HelperClasses.CursorClass(self.screen.width/2, self.screen.height/2)

  def moveCursorToCenter(self):
    self.cursor = HelperClasses.CursorClass(self.screen.width/2, self.screen.height/2)
    print "Updated Cursor Position to center of screen (" + str(self.cursor.x) + ", " + str(self.cursor.y) + ")."
    self.moveCursor()

  def moveCursor(self):
    self.m.move(self.cursor.x, self.cursor.y)

  def mousePress(self):
    print "PRESS"
    self.m.press(self.cursor.x, self.cursor.y)

  def mouseRelease(self):
    print "RELEASE"
    self.m.release(self.cursor.x, self.cursor.y)

  def displaceCursor(self, disp):
    # update cursor
    new_x = self.cursor.x + disp.x
    new_y = self.cursor.y + disp.y

    # screen limits
    if new_x > self.screen.width:
      new_x = self.screen.width
    if new_x < 0:
      new_x = 0
    if new_y > self.screen.height:
      new_y = self.screen.height
    if new_y < 0:
      new_y = 0

    actualMovement = HelperClasses.CursorClass(self.cursor.x - new_x, self.cursor.y - new_y)

    self.cursor.x = new_x
    self.cursor.y = new_y
    self.moveCursor()

    return actualMovement
开发者ID:Furkannn,项目名称:senior-design,代码行数:47,代码来源:HostDeviceClass.py

示例9: main

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import screen_size [as 别名]
def main():
	mouse = PyMouse()

#	wm = cwiid.Wiimote("00:25:A0:CE:3B:6D")
	wm = cwiid.Wiimote()
	wm.rpt_mode = cwiid.RPT_BTN | cwiid.RPT_IR

	X,x = calibrate(wm)
	trans = getTransMatrix(x, X)

	screen = mouse.screen_size()
	lastTime = time.time()
	o = None
	points = []

	print('battery: %f%%' % (float(wm.state['battery']) / float(cwiid.BATTERY_MAX) * 100.0))

	window = pygame.display.set_mode((200, 150))

	while True:
		for event in pygame.event.get():
			if (event.type == pygame.QUIT):
				sys.exit(0)

		while (time.time() < lastTime + 0.01):
			pos = getWiiPointNonBlock(wm)

			if (pos != None):
				points.append(pos)

		print(len(points))

		if (len(points) > 0):
			pos = avPoints(points)

			ipt = numpy.matrix([[pos.x], [pos.y], [1]])
			optMat = trans.I * ipt
			o = Point(optMat[0] / optMat[2], optMat[1] / optMat[2])

			if (o.x < 0):
				o.x = 0
			elif (o.x >= screen[0]):
				o.x = screen[0] - 1

			if (o.y < 0):
				o.y = 0
			elif (o.y >= screen[1]):
				o.y = screen[1] - 1

			mouse.move(o.x, o.y)

			if (wm.state['buttons'] & cwiid.BTN_A):
				mouse.click(o.x, o.y)

		lastTime = time.time()
		points = []
开发者ID:mrhubbs,项目名称:WiiTouch,代码行数:58,代码来源:WiiTouch2.py

示例10: __init__

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import screen_size [as 别名]
class MouseController:
    def __init__(self):
        self.mouse = PyMouse()

    def set_mouse_position(self,x,y):
        self.mouse.move(x,y)
    
    def get_mouse_position(self):
        return self.mouse.position()

    def get_screen_size(self):
        return self.mouse.screen_size()

    #x,y, button possible values are 1: left, 2: middle, 3: right
    def click_at_location(self,x,y,button_id):
        self.mouse.click(x,y,button_id)
开发者ID:jvarley,项目名称:remote_desktop_server_3,代码行数:18,代码来源:mouse_controller.py

示例11: get_screen_size

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import screen_size [as 别名]
def get_screen_size():
    # returns [width, height]
    screen_size = None
    if system() == "Darwin":
        screen_size = sp.check_output(["./mac_os_helpers/get_screen_size"])
        screen_size = screen_size.split(",")
        screen_size = [float(screen_size[0]),float(screen_size[1])]
    else:
        try:
            from pymouse import PyMouse
            m = PyMouse()
            screen_size = m.screen_size()
        except ImportError as e:
            print "Error: %s" %(e)    
    
    return screen_size  
开发者ID:dyfer,项目名称:pupil-helpers,代码行数:18,代码来源:zmq_control_mouse.py

示例12: control_mouse

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import screen_size [as 别名]
def control_mouse():

    m = PyMouse()
    screen_width, screen_height = m.screen_size()
    cap = cv2.VideoCapture(0)
    mouse_img = cv2.imread('key.jpg')
    # plt.imshow(mouse_img)
    # surf = cv2.SURF(400)
    # kp1, des1 = surf.detectAndCompute(mouse_img, None)
    # print 'Starting with %d kp' % len(kp1)
    red = cv2.cv.CV_RGB(255,0,0)
    while True:
        flag, frame = cap.read()
        # kp2, des2 = surf.detectAndCompute(frame, None)
        # print 'Got %d kp' % len(kp2)
        # bf = cv2.BFMatcher(cv2.NORM_L2, crossCheck=True)
        # matches = bf.match(des1, des2)

        # pt_list = []

        # for match in sorted(matches, key=lambda x:x.distance)[:10]:
            # pt_list.append(kp2[match.trainIdx].pt)
            # pt = tuple(map(int, kp2[match.trainIdx].pt))
            # cv2.circle(frame, pt, 5, red)

        # median_x = int(np.median([x for x,y in pt_list]))
        # median_y = int(np.median([y for x,y in pt_list]))
        # m.move(median_x, median_y)

        frame_width, frame_height, depth = frame.shape
        match = cv2.matchTemplate(mouse_img, frame, cv2.cv.CV_TM_CCORR)
        smoothed = uniform_filter(match, size=5)
        print 'S:', smoothed.shape
        print 'F:', frame.shape
        # new_frame = match.resize((frame_width, frame_height))
        max_index = np.argmin(match)
        max_index_row = max_index / frame_width
        max_index_col = max_index % frame_width

        red = cv2.cv.CV_RGB(255,0,0)
        cv2.circle(frame, (max_index_row, max_index_col), 50, red)
        # cv2.imshow('frame', smoothed)
        plt.imshow(match)
        plt.show()

        if cv2.waitKey(1) & 0xFF == ord('q'):
            break
开发者ID:ben-eysenbach,项目名称:RandomBytes,代码行数:49,代码来源:mouse.py

示例13: PointerNode

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import screen_size [as 别名]
class PointerNode(Node):
    nodeName = "Pointer"

    def __init__(self, name):
        terminals = {
            'irXIn': dict(io='in'),
            'irYIn': dict(io='in'),
            'bPressed': dict(io='in'),
            'aPressed': dict(io='in'),
            'bRel': dict(io='in'),
        }

        self.mouse = PyMouse()
        self.screenSize = self.mouse.screen_size()
        self.dragging = False

        Node.__init__(self, name, terminals=terminals)

    def process(self, **kwds):
        self.irX = kwds['irXIn']
        self.irY = kwds['irYIn']
        self.isBPressed = kwds['bPressed']
        self.isAPressed = kwds['aPressed']
        self.isBReleased = kwds['bRel']

        # check if B button is pressed and ir data is not zero
        if self.isBPressed and self.irX != 0 and self.irY != 0:
            # recalculate the x and y pos of the mouse depending on the ir data and screen size
            xScreen = self.screenSize[0] - int((self.screenSize[0] / 1024) * self.irX)
            yScreen = int((self.screenSize[1] / 760) * self.irY)

            # check if x and y data is valid and move mouse to pos
            if xScreen <= self.screenSize[0] and xScreen >= 0 and yScreen <= self.screenSize[1] and yScreen >= 0:
                self.mouse.move(xScreen, yScreen)

        # when b is released and object is dragged, object is released
        if self.isBReleased and self.dragging:
            self.mouse.click(self.mouse.position()[0], self.mouse.position()[1])
            self.dragging = False
        # when b is not pressed and a is pressed, do a single click
        if self.isAPressed and not self.isBPressed:
            self.mouse.click(self.mouse.position()[0], self.mouse.position()[1])
            self.dragging = False
        # when b and a are pressed, do drag
        elif self.isAPressed and self.isBPressed:
            self.mouse.press(self.mouse.position()[0], self.mouse.position()[1])
            self.dragging = True
开发者ID:mopat,项目名称:A7,代码行数:49,代码来源:magic_wand.py

示例14: runScript

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import screen_size [as 别名]
def runScript(delay, SCRIPT_PATH, SCRIPT_NAME):
    screen = wnck.screen_get(0)
    #screen = wnck.screen_get_default()

    while gtk.events_pending():
        gtk.main_iteration()

    windowTitle = re.compile('.*Board.*')

    for window in screen.get_windows():
        if windowTitle.match(window.get_name()):
            window.activate(int(time.time()))
            window.maximize()

    #MOUSE CLICK TO ACTUALLY FOCUS EAGLE BOARD
    m = PyMouse()
    x, y = m.screen_size()
    #m.click(x/4, y/4, 1)

    #KEYBOARD INPUT
    k = PyKeyboard()

    caps_flag = 0
    if int(commands.getoutput('xset q | grep LED')[65]) % 2:
        k.tap_key(k.caps_lock_key)
        caps_flag = 1

    #BRING UP ALT-FILE MENU
    k.press_key(k.alt_key)
    k.type_string('f')
    k.release_key(k.alt_key)

    #PRESS T TO RUN SCRIPT FROM ALT-FILE MENUs
    k.type_string('t')

    time.sleep(delay)

    #TYPE IN SCRIPT NAME TO DIALOG BOX
    k.type_string(SCRIPT_PATH + SCRIPT_NAME)

    time.sleep(delay)
    time.sleep(delay)

    k.tap_key(k.enter_key)

    if caps_flag:
        k.tap_key(k.caps_lock_key)
开发者ID:abcinder,项目名称:st-pattern-gen,代码行数:49,代码来源:EagleCLI.py

示例15: ScreenShot

# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import screen_size [as 别名]
class ScreenShot(Thread):

    # CONFIGURATION
    SCALE_RATIO_X = 1.4
    SCALE_RATIO_Y = 2
    MAX_SCREENSHOT_COUNT = 5
    # DELAY IN SECONDS
    DELAY_BETWEEN_SCREENSHOTS = 2.0

    slide_counter = 0

    def __init__(self, event):
        Thread.__init__(self)

        # set wx for screenshot
        self.screen = wx.ScreenDC()
        self.size = self.screen.GetSize()
        self.bmp = wx.EmptyBitmap(self.size[0], self.size[1])

        # set mouse click settings
        self.stopped = event
        self.mouse = PyMouse()
        self.width, self.height = self.mouse.screen_size()
        self.set_coordinates()

    def set_coordinates(self):
        self.x = self.width / self.SCALE_RATIO_X
        self.y = self.height / self.SCALE_RATIO_Y

    def perform_click(self):
        self.mouse.click(self.x, self.y)

    def take_screenshot(self):
        mem = wx.MemoryDC(self.bmp)
        mem.Blit(0, 0, self.size[0], self.size[1], self.screen, 0, 0)
        del mem
        self.bmp.SaveFile('screenshot{0}.png'.format(self.slide_counter), wx.BITMAP_TYPE_PNG)

    def run(self):
        while not self.stopped.wait(self.DELAY_BETWEEN_SCREENSHOTS):
            self.slide_counter += 1
            self.perform_click()
            self.take_screenshot()

            if self.slide_counter > self.MAX_SCREENSHOT_COUNT:
                self.stopped.set()
开发者ID:bnbwn,项目名称:click-and-screenshot,代码行数:48,代码来源:click_and_screenshot.py


注:本文中的pymouse.PyMouse.screen_size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。