Command to trigger "long click" on left mouse button

Viewed 10757

I searched in win32gui and PyAutoGUI some commands that make "long - click" on the left mouse button, and I didn't find anything. I'm actually building a code that helps me to remote another pc's mouse so i need a command that makes a long click on a mouse.

I put *** on my code so you can see the parts where I need help:

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)
2 Answers

A solution might be:

pyautogui.dragTo(100, 200, button='left')     # drag mouse to X of 100, Y of 200 while holding down left mouse button
pyautogui.dragTo(300, 400, 2, button='left')  # drag mouse to X of 300, Y of 400 over 2 seconds while holding down left mouse button
pyautogui.drag(30, 0, 2, button='right')   # drag the mouse left 30 pixels over 2 seconds while holding down the right mouse button
Related