本文整理汇总了Python中win32api.mouse_event函数的典型用法代码示例。如果您正苦于以下问题:Python mouse_event函数的具体用法?Python mouse_event怎么用?Python mouse_event使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mouse_event函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: close_alter_window
def close_alter_window(self, elapsed_seconds=1):
'''点击安全警告窗口中的“运行”按钮, 尝试3次失败后关闭该窗口
'''
try_num = 0
start = time.time()
while True:
hwnd = winGuiAuto.findTopWindows(u"安全警告".encode('gbk'))
if hwnd:
try:
(left, top, right, bottom) = win32gui.GetWindowRect(hwnd[0])
x = left + 460
y = top + 255
win32api.SetCursorPos((x, y))
win32api.ClipCursor((x, y, x, y))
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
win32api.ClipCursor((0, 0, 0, 0))
except Exception, e:
print e
win32api.ClipCursor((0, 0, 0, 0))
try_num += 1
if try_num > 3:
win32api.SendMessage(hwnd[0], win32con.WM_CLOSE, 0, 0)
break
time.sleep(3)
continue
if elapsed_seconds == 0:
break
if self.elapsed(start) > 10:
break
time.sleep(1)
开发者ID:miyalu,项目名称:python_tool,代码行数:31,代码来源:nmrdb.py
示例2: MoveToLocation
def MoveToLocation(pos, duration=0, tick=0.01):
"""Move the mouse cursor to a specified location, taking the specified time.
Args:
pos: position (in screen coordinates) to move to
duration: amount of time the move should take
tick: amount of time between successive moves of the mouse
Returns:
None
"""
# calculate the number of moves to reach the destination
num_steps = (duration/tick)+1
# get the current and final mouse position in mouse coords
current_location = ScreenToMouse(win32gui.GetCursorPos())
end_location = ScreenToMouse(pos)
# Calculate the step size
step_size = ((end_location[0]-current_location[0])/num_steps,
(end_location[1]-current_location[1])/num_steps)
step = 0
while step < num_steps:
# Move the mouse one step
current_location = (current_location[0]+step_size[0],
current_location[1]+step_size[1])
# Coerce the coords to int to avoid a warning from pywin32
win32api.mouse_event(
win32con.MOUSEEVENTF_MOVE|win32con.MOUSEEVENTF_ABSOLUTE,
int(current_location[0]), int(current_location[1]))
step += 1
time.sleep(tick)
开发者ID:AchironOS,项目名称:chromium-2,代码行数:35,代码来源:mouse.py
示例3: MouseDownMove
def MouseDownMove(self,x,y):
# 按下后拖住移动
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x,y)
time.sleep(0.05)
windll.user32.SetCursorPos(x,y)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,x,y)
time.sleep(0.5)
开发者ID:tgbmangel,项目名称:QuickMacro,代码行数:7,代码来源:WisonicPressKey.py
示例4: click
def click(cls, x, y):
win32api.SetCursorPos((x, y))
time.sleep(cls.IN_BETWEEN_DELAY)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y, 0, 0)
time.sleep(cls.IN_BETWEEN_DELAY)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y, 0, 0)
time.sleep(cls.AFTER_DELAY)
开发者ID:hanpeter,项目名称:windows-macro,代码行数:7,代码来源:mouse.py
示例5: mouseClick
def mouseClick(x,y):
if not x is None and not y is None:
mouseMove(x,y)
time.sleep(0.03)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0,0,0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0,0,0)
time.sleep(0.01)
开发者ID:YouZhang,项目名称:PowerTestSuite,代码行数:7,代码来源:common.py
示例6: FX_MouseLClick
def FX_MouseLClick(x, y):
if platform.system() == 'Windows':
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, int(x), int(y), 0, 0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, int(x), int(y), 0, 0)
else:
global g_m
g_m.click(x, y, 1)
开发者ID:qiangyi1989,项目名称:hello_git,代码行数:7,代码来源:chrome_test.py
示例7: disablescanner
def disablescanner(self):
autopy.mouse.move(933,39)
time.sleep(0.1)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0)
time.sleep(0.1)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0)
time.sleep(0.1)
开发者ID:avtarmoon,项目名称:eve_bot,代码行数:7,代码来源:evebot.py
示例8: click
def click(x, y):
""" click(x, y): click at (x,y) """
xx, yy = win32api.GetCursorPos()
win32api.SetCursorPos((x, y))
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y, 0, 0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y, 0, 0)
l.info("(%4d, %4d) --> (%4d, %4d) clicked" % (xx, yy, x, y))
开发者ID:WDavidX,项目名称:pyutil,代码行数:7,代码来源:wxu.py
示例9: left_click
def left_click(item_coordinates):
win32api.SetCursorPos((x_pad + item_coordinates[0], y_pad + item_coordinates[1]))
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0)
time.sleep(.02)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0)
# Gave the game a second to catch up
time.sleep(.2)
开发者ID:DigitalMockingbird,项目名称:Sushi-Go-Round-Bot,代码行数:7,代码来源:sushi_bot.py
示例10: mouse_fun
def mouse_fun(self):
mouse_click_delay = 1
anchor_pos = np.array((0, 0))
start_time = time.clock()
while 1:
ret, view = self.vid.read()
if not self.q_key.empty():
keypress = self.q_key.get_nowait()
if keypress == ord('q'):
self.q_frame.put(np.zeros([self.board_h, self.board_w], dtype=np.uint8))
return
elif keypress == ord('r'):
self.canvas = np.zeros([self.board_h, self.board_w], dtype=np.uint8)
print('canvas cleared')
board = cv2.warpPerspective(view, self.H, (self.board_w, self.board_h))
dt_view = self.find_dots(board)
key_points = self.detector(dt_view)
if len(key_points) > 0:
pos = np.array((int(key_points[0][0]) + win32api.GetSystemMetrics(0), int(key_points[0][1]) + 30))
win32api.SetCursorPos(pos)
if np.linalg.norm(pos - anchor_pos) > 30:
anchor_pos = pos
start_time = time.clock()
else:
if time.clock() - start_time > mouse_click_delay:
win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN, pos[0], pos[1], 0, 0)
win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTUP, pos[0], pos[1], 0, 0)
start_time = time.clock()
else:
start_time = time.clock()
开发者ID:kkawabat,项目名称:LaserBoard,代码行数:33,代码来源:LaserBoard_V8.py
示例11: _run
def _run(self):
# move mouse
insertState = self._appAttr["AppInfo"].keyMouseInputState["INSERT"].state
if insertState:
self.isEnabled = not self.isEnabled
if not self.isEnabled:
return
self.isFiring = self._appAttr["AppInfo"].keyMouseInputState["LMB"].state
if self.isFiring:
px, py = self.screenCenterX, self.screenCenterY
fScreenWidth = windll.user32.GetSystemMetrics(0) - 1.0 # SM_CXSCREEN
fScreenHeight = windll.user32.GetSystemMetrics(1) - 1.0 # SM_CYSCREEN
rx = 65535.0 / fScreenWidth
ry = 65535.0 / fScreenHeight
py += 130
#self.input.mi.dx = int( ceil(px * rx) )
#self.input.mi.dy = int( ceil(py * ry) )
#windll.User32.SendInput(1, byref(self.input), sizeof(self.input))
c_px = int(ceil(px))
c_py = int(ceil(py))
win32api.mouse_event(self.mouseMoveFlag, c_px, c_py)
self.frame += 1
else:
self.frame = 0
开发者ID:powergun,项目名称:EHF,代码行数:32,代码来源:keymouseinput.py
示例12: click
def click(x, y):
x = x_off + x * tile_dim
y = y_off + y * tile_dim
win32api.SetCursorPos((x, y))
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x, y, 0, 0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y, 0, 0)
time.sleep(speed)
开发者ID:andrew-zhao,项目名称:0hh1-solver,代码行数:7,代码来源:0hh1v.py
示例13: ClickPosition
def ClickPosition(ie, x, y):
win32api.SetCursorPos((x,y))
#sleep(2)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x,y,0,0)
#sleep(2)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,x,y,0,0)
sleep(1)
开发者ID:traceformula,项目名称:choopi,代码行数:7,代码来源:Choopi.py
示例14: printing_handler
def printing_handler(addr, tags, data, source):
left_hand_id = 7
right_hand_id = 11
#print "---"
print "received new osc msg from %s" % getUrlStr(source)
# print "with addr : %s" % addr
# print "typetags : %s" % tags
# print "---"
#print data
left_hand = data[1+left_hand_id].split(',')
right_hand = data[1+right_hand_id].split(',')
x = float(right_hand[0])
y = float(right_hand[1])
# x = (x-0.5)*1.2+0.5;
# y = (y-0.5)*1.2+0.5;
cx = int(x*65536)#win32api.GetSystemMetrics(0))
cy = int(y*65536)#win32api.GetSystemMetrics(1))
#print cx,cy
if start == True:
#win32api.SetCursorPos((cx,cy))
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN|win32con.MOUSEEVENTF_MOVE|win32con.MOUSEEVENTF_ABSOLUTE,cx,cy)
开发者ID:ChengliangDong,项目名称:KinServer,代码行数:26,代码来源:zen_mouse.py
示例15: clicker
def clicker():
"""Checks for keyboard combinations and handles clicking."""
global cps
global speed
while True:
if win32api.GetAsyncKeyState(81) != 0 and win32api.GetAsyncKeyState(16) != 0: #Check if Shift + Q is pressed
while True:
(x,y) = win32api.GetCursorPos() #Get the current position of the cursor
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x,y,0,0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,x,y,0,0)
cps += 1
time.sleep(speed)
if win32api.GetAsyncKeyState(38) != 0 and win32api.GetAsyncKeyState(16) != 0 and speed > 0.005: #Check if Shift + Up is pressed
speed -= 0.005
cps = 0
time.sleep(0.1)
if win32api.GetAsyncKeyState(40) != 0 and win32api.GetAsyncKeyState(16) != 0 and speed < 1: #Check if Shift + Down is pressed
speed += 0.005
cps = 0
time.sleep(0.1)
if win32api.GetAsyncKeyState(87) != 0 and win32api.GetAsyncKeyState(16) != 0: #Check if Shift + W is pressed
break
cps = 0
开发者ID:giorgos314,项目名称:py3-auto-clicker,代码行数:31,代码来源:py3-auto-clicker.py
示例16: flick
def flick(self, _start, _end):
logging.debug(" %.2f Flick from(%s,%s)to(%s,%s)" % (
(time.time() - recoder.BEGGINTIME), _start.x, _start.y, _end.x,
_end.y))
start = self._transformPosition(_start)
end = self._transformPosition(_end)
list = self._getIntermediatePoints(start, end)
startPoint = list[0]
endPoint = list[-1]
windll.user32.SetCursorPos(startPoint.x, startPoint.y)
#send down event
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, startPoint.x,
startPoint.y)
time.sleep(0.01)
for p in list:
windll.user32.SetCursorPos(p.x, p.y)
time.sleep(0.01)
endPoint = p
if (endPoint != end):
endPoint = end
windll.user32.SetCursorPos(endPoint.x, endPoint.y)
time.sleep(0.01)
#send up event
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, endPoint.x,
endPoint.y)
开发者ID:csusheep,项目名称:mouse_recorder,代码行数:29,代码来源:windowsEngine.py
示例17: enter_game_page
def enter_game_page():
scrn_w = win32api.GetSystemMetrics(0)
scrn_h = win32api.GetSystemMetrics(1)
win32api.SetCursorPos([scrn_w*2/3, scrn_h/2])
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0,0,0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0,0,0)
is_on_game_page = True
开发者ID:hightoon,项目名称:game_management,代码行数:7,代码来源:game_process_control.py
示例18: chickmouse
def chickmouse():
time.sleep(5)
win32api.SetCursorPos((150, 60))
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0)
time.sleep(0.05)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0)
time.sleep(0.05)
开发者ID:testlins,项目名称:python_script,代码行数:7,代码来源:copytjb.py
示例19: click_CurrentPlace
def click_CurrentPlace(self,lb_dx,lb_dy):
tmp=(string.atoi(lb_dx),string.atoi(lb_dy))
win32api.SetCursorPos(tmp)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,tmp[0], tmp[1])
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,tmp[0], tmp[1])
开发者ID:tok-gogogo,项目名称:Automation-Framework-for-devices,代码行数:7,代码来源:ctrl_waveQoE.py
示例20: mouse_dclick
def mouse_dclick(x=None,y=None):#鼠标点击
if not x is None and not y is None:
mouse_move(x,y)
time.sleep(0.01)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0)#按下左键
time.sleep(0.01)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0)#弹起左键
开发者ID:smile921,项目名称:Ciss921,代码行数:7,代码来源:mouse_click.py
注:本文中的win32api.mouse_event函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论