Python win32con.MOUSEEVENTF_LEFTUP Examples

The following are 16 code examples of win32con.MOUSEEVENTF_LEFTUP(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module win32con , or try the search function .
Example #1
Source File: steam.py    From Yugioh-bot with MIT License 14 votes vote down vote up
def tap(self, x, y):
        if self.run_time.stop:
            return
        x, y = int(x), int(y)
        self.root.debug("Tapping at location ({},{})".format(x, y))
        if self._debug:
            # Helper to debug taps
            input("waiting for confirmation press enter")
        ox, oy = win32api.GetCursorPos()
        curr_window = win32gui.GetForegroundWindow()
        win32gui.ShowWindow(self.win_handle, win32con.SW_RESTORE)
        x, y = int(x), int(y)
        cx, cy = win32gui.ClientToScreen(self.win_handle, (x, y))
        x, y = self.__calculate_absolute_coordinates__(cx, cy)
        win32api.mouse_event(win32con.MOUSEEVENTF_MOVE | win32con.MOUSEEVENTF_ABSOLUTE,
                             x, y, 0, 0)
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y, 0, 0)
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y, 0, 0)
        time.sleep(20 / 1000)
        win32api.SetCursorPos((ox, oy))
        win32gui.SetActiveWindow(curr_window) 
Example #2
Source File: very_secret_script.py    From ultra_secret_scripts with GNU General Public License v3.0 5 votes vote down vote up
def lmb_up():
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0) 
Example #3
Source File: play_jump_game.py    From PlayJumpGame with MIT License 5 votes vote down vote up
def mouse_click(x=None, y=None):
    """
    模拟鼠标点击
    :param x: int, 鼠标点击位置横坐标
    :param y: int, 鼠标点击位置纵坐标
    :return: 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)
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0) 
Example #4
Source File: play_jump_game.py    From PlayJumpGame with MIT License 5 votes vote down vote up
def mouse_pclick(x=None, y=None, press_time=0.0):
    """
    模拟式长按鼠标
    :param x: int, 鼠标点击位置横坐标
    :param y: int, 鼠标点击位置纵坐标
    :param press_time: float, 点击时间,单位秒
    :return: 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(press_time)
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0) 
Example #5
Source File: use_keyboard_and_mouse.py    From Automatic-minesweeping with MIT License 5 votes vote down vote up
def left_click(self, left_offset, top_offset):
        pos = self.window.get_box(left_offset, top_offset)
        SetCursorPos(pos)
        mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
        mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)

    # 单击鼠标右键
    # left_offset和top_offset表示
    # 从左往右第left_offset个,从上往下第top_offset个格子
    # 索引从0开始 
Example #6
Source File: use_keyboard_and_mouse.py    From Automatic-minesweeping with MIT License 5 votes vote down vote up
def left_and_right_click(self, left_offset, top_offset):
        pos = self.window.get_box(left_offset, top_offset)
        SetCursorPos(pos)
        mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
        mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0)
        mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0)
        mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)

    # 按下键盘F2 
Example #7
Source File: rescaletime.py    From cross3d with MIT License 5 votes vote down vote up
def clickPoint(self, id):
		if id:
			pnt = ClientToScreen(id,(5,5))
#			print 'ClickPoint', pnt
			currentCursorPos = GetCursorPos()
			SetCursorPos(pnt)
			mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,pnt[0],pnt[1],0,0)
			mouse_event(win32con.MOUSEEVENTF_LEFTUP,pnt[0],pnt[1],0,0)
			SetCursorPos(currentCursorPos)
			mxs.setWaitCursor()
#		else:
#			print "Could not find window to click on" 
Example #8
Source File: windows.py    From airtest with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def touch(self, x, y, duration=0.1):
        ''' Simulate touch '''
        (ox, oy) = self.mouseposition() # remember mouse position
        x, y = self._resetpt(x, y)
        win32api.SetCursorPos((x,y))

        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0)
        time.sleep(duration)
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0)
        win32api.SetCursorPos((ox,oy)) # move back mouse position 
Example #9
Source File: winguiauto.py    From pyautotrade_tdx with GNU General Public License v2.0 5 votes vote down vote up
def clickMenuButton(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.1)
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
    time.sleep(0.3) 
Example #10
Source File: run.py    From Auto-Lianliankan with Apache License 2.0 5 votes vote down vote up
def autoRelease(result,game_x,game_y):
    for i in range(0,len(result)):
        for j in range(0,len(result[0])):
            # 以上两个for循环,定位第一个选中点
            if result[i][j] != 0:
                for m in range(0,len(result)):
                    for n in range(0,len(result[0])):
                        if result[m][n] != 0:
                            # 后两个for循环定位第二个选中点
                            if matching.canConnect(i,j,m,n,result):
                            # 执行消除算法并返回
                                result[i][j] = 0
                                result[m][n] = 0
                                print('可消除点:'+ str(i+1) + ',' + str(j+1) + '和' + str(m+1) + ',' + str(n+1))
                                x1 = game_x + j*SQUARE_WIDTH
                                y1 = game_y + i*SQUARE_HEIGHT
                                x2 = game_x + n*SQUARE_WIDTH
                                y2 = game_y + m*SQUARE_HEIGHT
                                win32api.SetCursorPos((x1 + 15,y1 + 18))
                                win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x1+15, y1+18, 0, 0)
                                win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x1+15, y1+18, 0, 0)
                                time.sleep(TIME_INTERVAL)

                                win32api.SetCursorPos((x2 + 15, y2 + 18))
                                win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x2 + 15, y2 + 18, 0, 0)
                                win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x2 + 15, y2 + 18, 0, 0)
                                time.sleep(TIME_INTERVAL)
                                return True
    return False 
Example #11
Source File: windows.py    From ATX with Apache License 2.0 5 votes vote down vote up
def _input_left_mouse(self, x, y):
        left, top, right, bottom = self.rect
        width, height = right - left, bottom - top
        if x < 0 or x > width or y < 0 or y > height:
            return

        win32gui.SetForegroundWindow(self.hwnd)
        pos = win32gui.GetCursorPos()
        win32api.SetCursorPos((left+x, top+y))
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0)
        win32api.Sleep(100) #ms
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0)
        win32api.Sleep(100) #ms
        # win32api.SetCursorPos(pos) 
Example #12
Source File: game_ctl.py    From onmyoji_bot with GNU General Public License v3.0 5 votes vote down vote up
def mouse_click(self):
        """
        鼠标单击
        """
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
        time.sleep(random.randint(20, 80)/1000)
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0) 
Example #13
Source File: winguiauto.py    From pyAutoTrading with GNU General Public License v2.0 5 votes vote down vote up
def clickWindow(hwnd, offset):
    left, top, right, bottom = win32gui.GetWindowRect(hwnd)
    # print('left, top, right, bottom', left, top, right, bottom)
    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) 
Example #14
Source File: win32_helper.py    From pySPM with Apache License 2.0 5 votes vote down vote up
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) 
Example #15
Source File: game_ctl.py    From onmyoji_bot with GNU General Public License v3.0 4 votes vote down vote up
def mouse_drag(self, pos1, pos2):
        """
        鼠标拖拽
            :param pos1: (x,y) 起点坐标
            :param pos2: (x,y) 终点坐标
        """
        pos1_s = win32gui.ClientToScreen(self.hwnd, pos1)
        pos2_s = win32gui.ClientToScreen(self.hwnd, pos2)
        screen_x = win32api.GetSystemMetrics(win32con.SM_CXSCREEN)
        screen_y = win32api.GetSystemMetrics(win32con.SM_CYSCREEN)
        start_x = pos1_s[0]*65535//screen_x
        start_y = pos1_s[1]*65535//screen_y
        dst_x = pos2_s[0]*65535//screen_x
        dst_y = pos2_s[1]*65535//screen_y
        move_x = np.linspace(start_x, dst_x, num=20, endpoint=True)[0:]
        move_y = np.linspace(start_y, dst_y, num=20, endpoint=True)[0:]
        self.mouse_move(pos1)
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
        for i in range(20):
            x = int(round(move_x[i]))
            y = int(round(move_y[i]))
            win32api.mouse_event(win32con.MOUSEEVENTF_MOVE |
                                 win32con.MOUSEEVENTF_ABSOLUTE, x, y, 0, 0)
            time.sleep(0.01)
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0) 
Example #16
Source File: Email My PC.py    From Email_My_PC with MIT License 4 votes vote down vote up
def button_event(content):
	key_table = {'BACKSPACE':8, 'TAB':9, 'TABLE':9, 'CLEAR':12, 'ENTER':13, 'SHIFT':16, 'CTRL':17, 
		'CONTROL':17, 'ALT':18, 'ALTER':18, 'PAUSE':19, 'BREAK':19, 'CAPSLK':20, 'CAPSLOCK':20, 'ESC':27, 
		'SPACE':32, 'SPACEBAR':32, 'PGUP':33, 'PAGEUP':33, 'PGDN':34, 'PAGEDOWN':34, 'END':35, 'HOME':36, 
		'LEFT':37, 'UP':38, 'RIGHT':39, 'DOWN':40, 'SELECT':41, 'PRTSC':42, 'PRINTSCREEN':42, 'SYSRQ':42, 
		'SYSTEMREQUEST':42, 'EXECUTE':43, 'SNAPSHOT':44, 'INSERT':45, 'DELETE':46, 'HELP':47, 'WIN':91, 
		'WINDOWS':91, 'F1':112, 'F2':113, 'F3':114, 'F4':115, 'F5':116, 'F6':117, 'F7':118, 'F8':119, 
		'F9':120, 'F10':121, 'F11':122, 'F12':123, 'F13':124, 'F14':125, 'F15':126, 'F16':127, 'NMLK':144, 
		'NUMLK':144, 'NUMLOCK':144, 'SCRLK':145, 'SCROLLLOCK':145, 'LEFTCLICK':999, 'RIGHTCLICK':1000}
	unrecognized = ''
	key_values = []
	keys = content.split('+')
	for key in keys:
		raw_key = key
		key = key.strip().replace(' ','').upper()
		if key in key_table:
			key_values.append(key_table.get(key))
		elif len(key) == 1:
			key_values.append(ord(key))
		else:
			if key != '':
				unrecognized = raw_key
	for key_value in key_values:
		if key_value == 999:
			win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
		elif key_value == 1000:
			win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0)
		else:
			win32api.keybd_event(key_value, 0, 0, 0)
		time.sleep(1)
	for i in range(len(key_values)-1, -1, -1):
		if key_value == 999:
			win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
		elif key_value == 1000:
			win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0)
		else:
			win32api.keybd_event(key_values[i], 0, win32con.KEYEVENTF_KEYUP, 0)
		time.sleep(1)
	return unrecognized

#设置开机启动快捷方式