def mouse_click(x=None, y=None): if not x is None and not y is None: mouse_move(x, y) time.sleep(0.05) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0) time.sleep(0.05) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
def dtest05_floor2_scrolltip(self): driver = self.driver driver.get(self.testurl) self.initcookie(driver) driver.get(self.testurl) # js = "var q=document.documentElement.scrollTop=10000" # driver.execute_script(js) # time.sleep(2) floor2_gj = driver.find_element_by_xpath("//a[@class='floor2_anchor']") print floor2_gj.is_displayed() while(not floor2_gj.is_displayed()): driver.refresh() floor2_gj = driver.find_element_by_xpath("//a[@class='floor2_anchor']") # ActionChains(driver).move_to_element(cool_textlink). # js = "var q=document.documentElement.scrollTop=-100" # driver.execute_script(js) time.sleep(2) win32api.mouse_event(win32con.MOUSEEVENTF_WHEEL, 0 ,0 ,100) # win32api.mouse_event(win32con.MOUSEEVENTF_WHEEL, 0, 0, 100) # win32api.mouse_event(win32con.MOUSEEVENTF_WHEEL, 0, 0, 100) time.sleep(1) floor2_wave = driver.find_element_by_xpath("//div[@id='J_FloorWave']") assert floor2_wave.is_displayed() == True win32api.mouse_event(win32con.MOUSEEVENTF_WHEEL, 0, 0, 1000)
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)
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)
def send_input(n, action): s = control.nexus().comm.get_com("grids") int_a = int(action) response = None if int_a != 2: s.go(str(n)) elif int_a == 2: response = s.retrieve_data_for_highlight(str(int(n))) s.kill() grids.wait_for_death(settings.LEGION_TITLE) if int_a == 0: Playback([(["mouse", "left", "click"], 0.0)]).execute() elif int_a == 1: Playback([(["mouse", "right", "click"], 0.0)]).execute() elif int_a == 2: x1 = response["l"]+2 x2 = response["r"] y = response["y"] win32api.SetCursorPos((x1, y)) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x1, y, 0, 0) time.sleep(0.5) win32api.SetCursorPos((x2, y)) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x2, y, 0, 0)
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)
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)
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)
def clickWindow(hwnd, offset): left, top, right, bottom = win32gui.GetWindowRect(hwnd) win32api.SetCursorPos([left + offset, (bottom - top) // 2 + top]) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0) time.sleep(0.2) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0) time.sleep(0.2)
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)
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])
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
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
def LC(): #Left Down win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0) #Delay down signals, so it won't get ahead of itself time.sleep(.1) #Left Up win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0)
def RC(): #Right Down win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN,0,0) #Delay down signals so it won't get ahead of itself time.sleep(.1) #Right Up win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTUP,0,0)
def drag(x0, y0, x1, y1, delay=0): """Click and drag x0 y0 to x1 y1""" click(x0, y0, click=False) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x0,y0,0,0) time.sleep(delay) click(x1, y1, click=False) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,x1,y1,0,0)
def click(x,y): ''' 指定x,yでクリック操作をする ''' win32api.SetCursorPos((x,y)) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x,y,0,0) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,x,y,0,0)
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)
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)#弹起左键
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)
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)
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
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()
def MouseMoveAndClick(self,x,y): # 移动到坐标位置并点击 windll.user32.SetCursorPos(x,y) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x,y) time.sleep(0.05) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,x,y) time.sleep(0.5)
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)
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)
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))
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)
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)
def clickLeftCur(): win32api.mouse_event( win32con.MOUSEEVENTF_LEFTDOWN | win32con.MOUSEEVENTF_LEFTUP, 0, 0)
def zj(): win32api.mouse_event( win32con.MOUSEEVENTF_LEFTDOWN | win32con.MOUSEEVENTF_LEFTUP, 0, 0)
password.send_keys(passwOfLogin) submit = chrome.find_element_by_id("SubmitCreds") submit.click() time.sleep(60) win32api.keybd_event(win32con.VK_SPACE, 0, 0, 0) time.sleep(5) win32api.keybd_event(win32con.VK_TAB, 0, 0, 0) time.sleep(5) for num in range(count): win32api.keybd_event(win32con.VK_RETURN, 0, 0, 0) time.sleep(20) win32api.SetCursorPos((609, 215)) time.sleep(1) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 609, 215, 0, 0) time.sleep(1) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 609, 215, 0, 0) time.sleep(25) for number in range(9): win32api.keybd_event(win32con.VK_TAB, 0, 0, 0) time.sleep(1) press('3', '0') time.sleep(1) win32api.keybd_event(win32con.VK_RETURN, 0, 0, 0) time.sleep(2) # win32api.keybd_event(win32con.VK_RETURN, 0, 0, 0) time.sleep(2) for number in range(4):
def click(self, pos): startPos = win32api.GetCursorPos() win32api.SetCursorPos(pos) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0) win32api.SetCursorPos(startPos)
import win32api import win32con import time import win32gui #x, y = win32api.GetCursorPos() #print(x, " ", y) #zhujubing = win32gui.FindWindow(None, u'yd3') #win32gui.SetActiveWindow() while(1): win32api.SetCursorPos((1119, 452)) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 200, 200, 0, 0) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 200, 200, 0, 0) time.sleep(200) win32api.SetCursorPos((1121, 500)) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 200, 200, 0, 0) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 200, 200, 0, 0) time.sleep(900)
def PressKey(hexKeyCode): extra = ctypes.c_ulong(0) ii_ = Input_I() ii_.ki = KeyBdInput(0, hexKeyCode, 0x0008, 0, ctypes.pointer(extra)) x = Input(ctypes.c_ulong(1), ii_) ctypes.windll.user32.SendInput(1, ctypes.pointer(x), ctypes.sizeof(x)) def ReleaseKey(hexKeyCode): extra = ctypes.c_ulong(0) ii_ = Input_I() ii_.ki = KeyBdInput(0, hexKeyCode, 0x0008 | 0x0002, 0, ctypes.pointer(extra)) x = Input(ctypes.c_ulong(1), ii_) ctypes.windll.user32.SendInput(1, ctypes.pointer(x), ctypes.sizeof(x)) while True: print(pointToClick) print("test") color = [getPixel(p1), getPixel(p2), getPixel(p3), getPixel(p4)] if color[0] == Colors and color[1] == Colors and color[2] == Colors and color[3] == Colors: win32api.SetCursorPos(pointToClick) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, pointToClick[0], pointToClick[1], 0, 0) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, pointToClick[0], pointToClick[1], 0, 0) if keyboard.is_pressed('q'): exit(1)
def right_click(cls, x, y): original_position = win32api.GetCursorPos() win32api.SetCursorPos((x, y)) win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0) win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0) win32api.SetCursorPos(original_position)
def fj(): win32api.mouse_event( win32con.MOUSEEVENTF_RIGHTUP | win32con.MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0)
def right(x, y): win32api.SetCursorPos((x, y)) time.sleep(.5) win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN, x, y, 0, 0) win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTUP, x, y, 0, 0)
def leftClick(self): win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0) time.sleep(.1) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0)
def mouseDown(x, y): global isMouseDown isMouseDown = True win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y, 0, 0)
def mouseUp(x, y): global isMouseDown isMouseDown = False win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y, 0, 0)
def Click(x=None, y=None, sleepTime=0.5): if not x is None and not y is None: mouse_move(x, y) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0) time.sleep(sleepTime)
def ClickPos(pos, sleepTime=0.5): if not pos[0] is None and not pos[1] is None: mouse_move(pos[0], pos[1]) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0) time.sleep(sleepTime)
def mouse_down(x, y, btn="left"): win.mouse_event(get_mouse_event(btn, "down"), x, y, 0, 0)
def mouse_up(x, y, btn="left"): win.mouse_event(get_mouse_event(btn, "up"), x, y, 0, 0)
else: motionless = False # when the cursor has been motionless long enough, wiggle it. if et > motionthreshold: if debug: print("~wiggle~"*3) # wiggle dt = 0 while dt < wiggletime: dt = time.time() - currenttime # movement values in pixels xmove = int(wiggleintensity*(random.random() - 0.5)) ymove = int(wiggleintensity*(random.random() - 0.5)) currentposition[0] += xmove currentposition[1] += ymove # move cursor location win32api.SetCursorPos(currentposition) # trigger mouse event with zero relative offset win32api.mouse_event(mouseeventflags,0,0) time.sleep(wiggleperiod) motionless = False # if not in the 'motionless' state yet, check for motion and set starttime else: if currentposition == previousposition: motionless = True starttime = currenttime et = 0 # update latest position and sample once per second previousposition = currentposition time.sleep(1)
def slide_up(x, y, h): m = PyMouse() m.move(x, y) win32api.mouse_event(win32con.MOUSEEVENTF_WHEEL, 0, 0, -h) return
def click(x, y): win32api.SetCursorPos((x, y)) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0) time.sleep(0.1) #This pauses the script for 0.01 seconds win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0)
def click(x, y): win32api.SetCursorPos((x, y)) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0) time.sleep(0.02) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0)
def press(self, x, y, button=1): buttonAction = 2 ** ((2 * button) - 1) self.move(x, y) win32api.mouse_event(buttonAction, x, y)
def release(self, x, y, button=1): buttonAction = 2 ** ((2 * button)) self.move(x, y) win32api.mouse_event(buttonAction, x, y)
def mouse_click(x=None, y=None): if not x is None and not y is None: mouse_move(x, y) time.sleep(random.random()) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
def tclick(loc): win32api.SetCursorPos(loc) #move mouse to loc sleep(0.1) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, loc[0], loc[1], 0, 0) #click left mouse button sleep(0.05) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, loc[0], loc[1], 0, 0) #release left mouse button sleep(0.05) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, loc[0], loc[1], 0, 0) #click left mouse button sleep(0.05) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, loc[0], loc[1], 0, 0) #release left mouse button sleep(0.05) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, loc[0], loc[1], 0, 0) #click left mouse button sleep(0.05) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, loc[0], loc[1], 0, 0) #release left mouse button sleep(0.05) user32.keybd_event(0x08, 0, 0, 0) #Backspace press sleep(0.05) user32.keybd_event(0x08, 0, 2, 0) #Backspace press
def mouse_rclick(x=None, y=None): if not x is None and not y is None: mouse_move(x, y) time.sleep(0.05) win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0) win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0)
def click(tup): x = tup[0] y = tup[1] SetCursorPos((x, y)) mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0) mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0)
def click(self, x, y): x += self.BOX_LEFT y += self.BOX_TOP win32api.SetCursorPos((x,y)) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x,y,0,0) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,x,y,0,0)
def click(x, y): win32api.SetCursorPos((x, y)) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y, 0, 0) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y, 0, 0)
def hold_click(x,y,mouse_button): win32api.SetCursorPos((x,y)) if mouse_button == 'left': win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x,y,0,0) time.sleep(10) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,x,y,0,0)
def mouse_right_click(x=None, y=None): if not x is None and not y is None: mouse_move(x, y) win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0) win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0)
def move_mouse(self, x,y, click): win32api.SetCursorPos((int(float(x)),int(float(y)))) print(click) if (click == "1"): win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,int(float(x)),int(float(y)),0,0) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,int(float(x)),int(float(y)),0,0) print("arman")