本文整理汇总了Python中pymouse.PyMouse.click方法的典型用法代码示例。如果您正苦于以下问题:Python PyMouse.click方法的具体用法?Python PyMouse.click怎么用?Python PyMouse.click使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymouse.PyMouse
的用法示例。
在下文中一共展示了PyMouse.click方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import click [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
示例2: netflix_play
# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import click [as 别名]
def netflix_play():
m = PyMouse()
m.move(150, 640)
time.sleep(0.25)
m.click(150, 640)
m.move(300, 0)
return ""
示例3: draw_arc
# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import click [as 别名]
def draw_arc(self, window):
#self.drawing_area.window.draw_arc(self.context, False, self._x, self._y, 70, 70, 0, 360*64)
window.set_keep_below(True)
window.hide()
m = PyMouse()
m.move(self._x, self._y)
m.click(self._x, self._y, 1)
示例4: WinMouseControl
# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import click [as 别名]
class WinMouseControl():
mouseObject=''
def __init__(self):
self.mouseObject=PyMouse()
print "mouse init success"
pass
def __del__(self):
pass
def mouseMove(self,x,y,button=None):
self.mouseObject.move(x, y)
return 0
def mouseClick(self,x,y,button):
self.mouseObject.click(x, y, button) #button:1 left, button2: middle button3:right
return 0
def mousePress(self,x,y,button):
self.mouseObject.press(x, y, button) #button:1 left, button2: middle button3:right
return 0
def mouseRelease(self,x,y,button):
self.mouseObject.release(x, y, button) #button:1 left, button2: middle button3:right
return 0
示例5: vis
# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import click [as 别名]
class Mouse:
@property
def vis(self):
return self._vis
def __init__(self,vis):
self._vis = vis
self.pm = PM()
""" Takes a board coordinate (x,y) and uses self._vis to calculate the
screen coordinates to click there. Then it waits 5.7 ms, and takes a
screenshot"""
def left_click(self,x,y):
#print "clicking at",x,y
x0, y0 = self.vis.edge_coords
x1, y1 = (x0 + 8 + x * 16, y0 + 8 + y * 16)
self.pm.move(x1,y1)
self.pm.click(x1,y1,1)
#time.sleep(0.25)
def right_click(self,x,y):
x0, y0 = self.vis.edge_coords
x1, y1 = (x0 + 8 + x * 16, y0 + 8 + y * 16)
self.pm.click(x1,y1,2)
#time.sleep(0.05)
""" Uses self._vis to determine the position of the smiley reset button"""
def reset_board(self):
(resx, resy) = self.vis.get_reset()
self.pm.move(resx,resy)
self.pm.press(resx,resy,1)
time.sleep(0.5)
self.pm.release(resx,resy,1)
示例6: netflix_continue
# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import click [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 ""
示例7: Robot
# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import click [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)
示例8: mouse_simulate
# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import click [as 别名]
def mouse_simulate():
try:
class event(PyMouseEvent):
def move(self, x, y):
pass
def click(self, x, y, button, press):
if press:
print("Mouse pressed at", x, y, "with button", button)
else:
print("Mouse released at", x, y, "with button", button)
e = event()
e.start()
except ImportError:
print("Mouse events are not yet supported on your platform")
m = PyMouse()
t_corr = (1173,313)
i_pos = t_corr
m.move(i_pos[0] , i_pos[1])
while(True):
if is_run is False:
time.sleep(1)
else:
time.sleep(0.2)
m.click(i_pos[0], i_pos[1])
try:
e.stop()
except:
pass
示例9: click
# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import click [as 别名]
def click(pos):
'''
pos: (x, y) # (0, 0) for top left piece
'''
m = PyMouse()
m.click(RECT[0] + PIECE_X / 2 + PIECE_X * pos[0], RECT[1] + PIECE_Y / 2 + PIECE_Y * pos[1])
time.sleep(0.5)
示例10: on_message
# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import click [as 别名]
def on_message(self, message):
m = PyMouse()
data = json.loads(message)
source = data['from']
destination = data['to']
offset = data['offset']
m.click(source['x'] + offset, source['y'] + offset)
m.click(destination['x'] + offset, destination['y'] + offset)
示例11: click
# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import click [as 别名]
def click(p, t = 0.6):
x = p.x
y = p.y
m = PyMouse()
m.move(x, y)
m.click(x, y, 1)
# m.press(x, y)
# m.release(x, y)
time.sleep(t)
示例12: main
# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import click [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 = []
示例13: all_in
# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import click [as 别名]
def all_in(a=None):
m = PyMouse()
if a:
time.sleep(a)
k = (679,558)
m.click(k[0],k[1], 1)
for a in range(0,13):
wsh.SendKeys("9")
wsh.SendKeys("{ENTER} ")
wsh.SendKeys("{F3}")
示例14: MouseRemote
# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import click [as 别名]
class MouseRemote(AweRemPlugin):
"""
Print "RedButton Triggered"
"""
def activate(self):
self.realMouse = PyMouse()
self.handler = MouseHandler(self)
self.info = {"title": "Mouse", "category": "utils",
"priority": 0}
def getHandler(self):
return self.handler
def getInfo(self):
return self.info
def getIconPath(self, dpi):
return ""
def click(self, button, x=None, y=None):
curx, cury = self.realMouse.position()
if x is None:
x = curx
if y is None:
y = cury
self.realMouse.click(x, y, button)
def press(self, button, x=None, y=None):
curx, cury = self.realMouse.position()
if x is None:
x = curx
if y is None:
y = cury
self.realMouse.press(x, y, button)
def release(self, button, x=None, y=None):
curx, cury = self.realMouse.position()
if x is None:
x = curx
if y is None:
y = cury
self.realMouse.release(x, y, button)
def move(self, deltaX, deltaY):
curx, cury = self.realMouse.position()
if deltaX is not None:
curx += deltaX
if deltaY is not None:
cury += deltaY
self.realMouse.move(curx, cury)
def moveAbsolute(self, x, y):
self.realMouse.move(x, y)
示例15: set_mouse
# 需要导入模块: from pymouse import PyMouse [as 别名]
# 或者: from pymouse.PyMouse import click [as 别名]
def set_mouse(x=0,y=0,click=0):
if system() == "Darwin":
sp.Popen(["./mac_os_helpers/mouse", "-x", "%s" %x, "-y", "%s" %y, "-click", "%s" %click])
else:
try:
from pymouse import PyMouse
m = PyMouse()
m.move(0,0) # hack to init PyMouse -- still needed
except ImportError as e:
print "Error: %s" %(e)
if click:
m.click(x,y)
else:
m.move(x,y)