本文整理匯總了Python中win32con.WM_LBUTTONDOWN屬性的典型用法代碼示例。如果您正苦於以下問題:Python win32con.WM_LBUTTONDOWN屬性的具體用法?Python win32con.WM_LBUTTONDOWN怎麽用?Python win32con.WM_LBUTTONDOWN使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類win32con
的用法示例。
在下文中一共展示了win32con.WM_LBUTTONDOWN屬性的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: mouse_drag_bg
# 需要導入模塊: import win32con [as 別名]
# 或者: from win32con import WM_LBUTTONDOWN [as 別名]
def mouse_drag_bg(self, pos1, pos2):
"""
後台鼠標拖拽
:param pos1: (x,y) 起點坐標
:param pos2: (x,y) 終點坐標
"""
if self.client == 0:
move_x = np.linspace(pos1[0], pos2[0], num=20, endpoint=True)[0:]
move_y = np.linspace(pos1[1], pos2[1], num=20, endpoint=True)[0:]
win32gui.SendMessage(self.hwnd, win32con.WM_LBUTTONDOWN,
0, win32api.MAKELONG(pos1[0], pos1[1]))
for i in range(20):
x = int(round(move_x[i]))
y = int(round(move_y[i]))
win32gui.SendMessage(
self.hwnd, win32con.WM_MOUSEMOVE, 0, win32api.MAKELONG(x, y))
time.sleep(0.01)
win32gui.SendMessage(self.hwnd, win32con.WM_LBUTTONUP,
0, win32api.MAKELONG(pos2[0], pos2[1]))
else:
command = str(pos1[0])+' ' + str(pos1[1]) + \
' '+str(pos2[0])+' '+str(pos2[1])
os.system('adb shell input swipe '+command)
示例2: click_drag
# 需要導入模塊: import win32con [as 別名]
# 或者: from win32con import WM_LBUTTONDOWN [as 別名]
def click_drag(x :int, y :int, x2 :int, y2 :int) -> None:
"""Click at pixel xy."""
x += Window.x
y += Window.y
x2 += Window.x
y2 += Window.y
lParam = win32api.MAKELONG(x, y)
lParam2 = win32api.MAKELONG(x2, y2)
# MOUSEMOVE event is required for game to register clicks correctly
win32gui.PostMessage(Window.id, wcon.WM_MOUSEMOVE, 0, lParam)
while (win32api.GetKeyState(wcon.VK_CONTROL) < 0 or
win32api.GetKeyState(wcon.VK_SHIFT) < 0 or
win32api.GetKeyState(wcon.VK_MENU) < 0):
time.sleep(0.005)
win32gui.PostMessage(Window.id, wcon.WM_LBUTTONDOWN,
wcon.MK_LBUTTON, lParam)
time.sleep(userset.LONG_SLEEP * 2)
win32gui.PostMessage(Window.id, wcon.WM_MOUSEMOVE, 0, lParam2)
time.sleep(userset.SHORT_SLEEP)
win32gui.PostMessage(Window.id, wcon.WM_LBUTTONUP,
wcon.MK_LBUTTON, lParam2)
time.sleep(userset.MEDIUM_SLEEP)
示例3: ctrl_click
# 需要導入模塊: import win32con [as 別名]
# 或者: from win32con import WM_LBUTTONDOWN [as 別名]
def ctrl_click(x :int, y :int) -> None:
"""Clicks at pixel x, y while simulating the CTRL button to be down."""
x += Window.x
y += Window.y
lParam = win32api.MAKELONG(x, y)
while (win32api.GetKeyState(wcon.VK_CONTROL) < 0 or
win32api.GetKeyState(wcon.VK_SHIFT) < 0 or
win32api.GetKeyState(wcon.VK_MENU) < 0):
time.sleep(0.005)
win32gui.PostMessage(Window.id, wcon.WM_KEYDOWN, wcon.VK_CONTROL, 0)
win32gui.PostMessage(Window.id, wcon.WM_LBUTTONDOWN,
wcon.MK_LBUTTON, lParam)
win32gui.PostMessage(Window.id, wcon.WM_LBUTTONUP,
wcon.MK_LBUTTON, lParam)
win32gui.PostMessage(Window.id, wcon.WM_KEYUP, wcon.VK_CONTROL, 0)
time.sleep(userset.MEDIUM_SLEEP)
示例4: click
# 需要導入模塊: import win32con [as 別名]
# 或者: from win32con import WM_LBUTTONDOWN [as 別名]
def click(hwnd):
'''
模擬鼠標左鍵單擊
:param hwnd: 要單擊的控件、窗體句柄
:return:
'''
win32gui.PostMessage(hwnd, win32con.WM_LBUTTONDOWN, None, None)
time.sleep(.2)
win32gui.PostMessage(hwnd, win32con.WM_LBUTTONUP, None, None)
time.sleep(.2)
示例5: click
# 需要導入模塊: import win32con [as 別名]
# 或者: from win32con import WM_LBUTTONDOWN [as 別名]
def click(x :int, y :int, button :str ="left", fast :bool =False) -> None:
"""Click at pixel xy."""
x += Window.x
y += Window.y
lParam = win32api.MAKELONG(x, y)
# MOUSEMOVE event is required for game to register clicks correctly
win32gui.PostMessage(Window.id, wcon.WM_MOUSEMOVE, 0, lParam)
while (win32api.GetKeyState(wcon.VK_CONTROL) < 0 or
win32api.GetKeyState(wcon.VK_SHIFT) < 0 or
win32api.GetKeyState(wcon.VK_MENU) < 0):
time.sleep(0.005)
if button == "left":
win32gui.PostMessage(Window.id, wcon.WM_LBUTTONDOWN,
wcon.MK_LBUTTON, lParam)
win32gui.PostMessage(Window.id, wcon.WM_LBUTTONUP,
wcon.MK_LBUTTON, lParam)
else:
win32gui.PostMessage(Window.id, wcon.WM_RBUTTONDOWN,
wcon.MK_RBUTTON, lParam)
win32gui.PostMessage(Window.id, wcon.WM_RBUTTONUP,
wcon.MK_RBUTTON, lParam)
# Sleep lower than 0.1 might cause issues when clicking in succession
if fast:
time.sleep(userset.FAST_SLEEP)
else:
time.sleep(userset.MEDIUM_SLEEP)
示例6: HookMessages
# 需要導入模塊: import win32con [as 別名]
# 或者: from win32con import WM_LBUTTONDOWN [as 別名]
def HookMessages(self):
self.HookMessage(self.OnLButtonUp, win32con.WM_LBUTTONUP)
self.HookMessage(self.OnLButtonDown, win32con.WM_LBUTTONDOWN)
self.HookMessage(self.OnLButtonDblClk, win32con.WM_LBUTTONDBLCLK)
self.HookMessage(self.OnNcLButtonDown, win32con.WM_NCLBUTTONDOWN)
self.HookMessage(self.OnNcLButtonDblClk, win32con.WM_NCLBUTTONDBLCLK)
self.HookMessage(self.OnMouseMove, win32con.WM_MOUSEMOVE)
self.HookMessage(self.OnNcPaint, win32con.WM_NCPAINT)
self.HookMessage(self.OnCaptureChanged, win32con.WM_CAPTURECHANGED)
self.HookMessage(self.OnWindowPosChanged, win32con.WM_WINDOWPOSCHANGED)
# self.HookMessage(self.OnSize, win32con.WM_SIZE)
示例7: click
# 需要導入模塊: import win32con [as 別名]
# 或者: from win32con import WM_LBUTTONDOWN [as 別名]
def click(hwnd):
'''
模擬鼠標左鍵單擊
:param hwnd: 要單擊的控件、窗體句柄
:return:
'''
win32gui.PostMessage(hwnd, win32con.WM_LBUTTONDOWN, None, None)
time.sleep(.2)
win32gui.PostMessage(hwnd, win32con.WM_LBUTTONUP, None, None)
示例8: mouse_click_bg
# 需要導入模塊: import win32con [as 別名]
# 或者: from win32con import WM_LBUTTONDOWN [as 別名]
def mouse_click_bg(self, pos, pos_end=None):
"""
後台鼠標單擊
:param pos: (x,y) 鼠標單擊的坐標
:param pos_end=None: (x,y) 若pos_end不為空,則鼠標單擊以pos為左上角坐標pos_end為右下角坐標的區域內的隨機位置
"""
if self.debug_enable:
img = self.window_full_shot()
self.img = cv2.rectangle(img, pos, pos_end, (0, 255, 0), 3)
if pos_end == None:
pos_rand = pos
else:
pos_rand = (random.randint(
pos[0], pos_end[0]), random.randint(pos[1], pos_end[1]))
if self.client == 0:
win32gui.SendMessage(self.hwnd, win32con.WM_MOUSEMOVE,
0, win32api.MAKELONG(pos_rand[0], pos_rand[1]))
win32gui.SendMessage(self.hwnd, win32con.WM_LBUTTONDOWN,
0, win32api.MAKELONG(pos_rand[0], pos_rand[1]))
time.sleep(random.randint(20, 80)/1000)
win32gui.SendMessage(self.hwnd, win32con.WM_LBUTTONUP,
0, win32api.MAKELONG(pos_rand[0], pos_rand[1]))
else:
command = str(pos_rand[0]) + ' ' + str(pos_rand[1])
os.system('adb shell input tap ' + command)
示例9: click
# 需要導入模塊: import win32con [as 別名]
# 或者: from win32con import WM_LBUTTONDOWN [as 別名]
def click(hwnd):
"""
模擬鼠標左鍵單擊
:param hwnd: 要單擊的控件、窗體句柄
:return:
"""
win32gui.PostMessage(hwnd, win32con.WM_LBUTTONDOWN, None, None)
time.sleep(0.2)
win32gui.PostMessage(hwnd, win32con.WM_LBUTTONUP, None, None)
time.sleep(0.2)
示例10: icon_wndproc
# 需要導入模塊: import win32con [as 別名]
# 或者: from win32con import WM_LBUTTONDOWN [as 別名]
def icon_wndproc(hwnd, msg, wp, lp):
""" Window proc for the tray icons """
if lp==win32con.WM_LBUTTONDOWN:
## popup menu won't disappear if you don't do this
win32gui.SetForegroundWindow(hwnd)
curr_desktop=win32service.OpenInputDesktop(0,True,win32con.MAXIMUM_ALLOWED)
curr_desktop_name=win32service.GetUserObjectInformation(curr_desktop,win32con.UOI_NAME)
winsta=win32service.GetProcessWindowStation()
desktops=winsta.EnumDesktops()
m=win32gui.CreatePopupMenu()
desktop_cnt=len(desktops)
## *don't* create an item 0
for d in range(1, desktop_cnt+1):
mf_flags=win32con.MF_STRING
## if you switch to winlogon yourself, there's nothing there and you're stuck
if desktops[d-1].lower() in ('winlogon','disconnect'):
mf_flags=mf_flags|win32con.MF_GRAYED|win32con.MF_DISABLED
if desktops[d-1]==curr_desktop_name:
mf_flags=mf_flags|win32con.MF_CHECKED
win32gui.AppendMenu(m, mf_flags, d, desktops[d-1])
win32gui.AppendMenu(m, win32con.MF_STRING, desktop_cnt+1, 'Create new ...')
win32gui.AppendMenu(m, win32con.MF_STRING, desktop_cnt+2, 'Exit')
x,y=win32gui.GetCursorPos()
d=win32gui.TrackPopupMenu(m,win32con.TPM_LEFTBUTTON|win32con.TPM_RETURNCMD|win32con.TPM_NONOTIFY,
x,y, 0, hwnd, None)
win32gui.PumpWaitingMessages()
win32gui.DestroyMenu(m)
if d==desktop_cnt+1: ## Create new
get_new_desktop_name(hwnd)
elif d==desktop_cnt+2: ## Exit
win32gui.PostQuitMessage(0)
win32gui.Shell_NotifyIcon(win32gui.NIM_DELETE, window_info[hwnd])
del window_info[hwnd]
origin_desktop.SwitchDesktop()
elif d>0:
hdesk=win32service.OpenDesktop(desktops[d-1],0,0,win32con.MAXIMUM_ALLOWED)
hdesk.SwitchDesktop()
return 0
else:
return win32gui.DefWindowProc(hwnd, msg, wp, lp)