Home > other >  Python application win32api simulate the mouse to click operation, the normal call no problem, such
Python application win32api simulate the mouse to click operation, the normal call no problem, such

Time:09-28

 
Def dianji_shubiao () :
Win32api. SetCursorPos (,84 [68])
# the mouse to click
Win32api. Mouse_event (win32con MOUSEEVENTF_LEFTDOWN, 0, 0)
Time. Sleep (1)
Win32api. Mouse_event (win32con MOUSEEVENTF_LEFTUP, 0, 0)
Time. Sleep (1)
Print (" dianji_shubiao ")

Time. Sleep (delta_time)
Dianji_shubiao ()


Code as above, the normal call, there is no problem, click the simulation operations can be effective, if sleep is a very long time, and others go computer interest rates screen, will be an error is not successful, an error is as follows:
The File "D: \ test. Py," line 40, in dianji_shubiao
Win32api. SetCursorPos (,84 [68])
Pywintypes. Error: (0, 'SetCursorPos',' No error message is available ')

CodePudding user response:

Consult ah, no one answered

CodePudding user response:

 def dianji_shubiao () : 

Win32api. SetCursorPos (,84 [68]) # the mouse to click

Win32api. Mouse_event (win32con MOUSEEVENTF_LEFTDOWN, 0, 0)

Time. Sleep (1)

Win32api. Mouse_event (win32con MOUSEEVENTF_LEFTUP, 0, 0)

Time. Sleep (1)

Print (" dianji_shubiao ")

Time. Sleep (delta_time)
Dianji_shubiao ()

CodePudding user response:

So can use
 import ctypes 
Ctypes. Windll. User32. SetCursorPos,84 (68)
  • Related