2017-05-31 6 views
0

win32guiとPyAutoGUIでマウスの左ボタンで「ロングクリック」するコマンドを検索しましたが、何も見つかりませんでした。 私は実際にリモートの別のPCのマウスに私を助けるコードを構築している 私はマウスの長いクリックを行うコマンドが必要です。左マウスボタンで「長いクリック」をトリガーするコマンド

私はあなたが、私は助けを必要とする部品見ることができるように私のコードに***を置く:理論的には

import win32api 
import time 


state_left = win32api.GetKeyState(0x01) # Left button down = 0 or 1. Button up = -127 or -128 
while True: 
    a = win32api.GetKeyState(0x01) 
    if a != state_left: # Button state changed 
     state_left = a 
     print(a) 
     if a < 0: 
      # *** long click on left mouse button *** 
      print('Left Button Pressed') 
     else: 
      # *** stop click on left mouse button *** 
      print('Left Button Released') 
    time.sleep(0.001) 

答えて

-1

を、PyAutoGUIはmouseDown & mouseUp functionsでこれをカバーしています。

>>> pyautogui.mouseDown(); pyautogui.mouseUp() # does the same thing as a left-button mouse click 
>>> pyautogui.mouseDown() # press the left button down 
>>> pyautogui.mouseUp(x=100, y=200) # move the mouse to 100, 200, then release the button up. 
関連する問題