简体   繁体   中英

pyautogui mouse click not working in certain programs

I have written a very short python-function (using pyautogui) which entails the following:

  • Move the mouse to the taskbar and click on a certain location within that taskbar, this "reopens" a certain program.
  • Then, within the opened program go to some location (moveTo...)

Now, I have noticed the following odd behavior: The first step always works, ie the specific program window is appears on the screen. However, depending on the specific program the second step either works or goes wrong. More specifically, I noticed that for notepad it works (ie the cursor moves to the specified location), whereas for a different program the mouse does not move at all.

Can anyone shed some light onto this behavior?

Thank you very much for your help!

You might have found the answer already, but if so, maybe someone else can use the answer i found.

I found using:

pyautogui.moveTo(x,y)
pyautogui.mouseDown()
time.sleep(0.5) #or whatever you need, if even needed
pyautoguii.mouseUp()

will do the click that pyautogui.click(x,y) will not. I cannot say if it will work in all situations, but its worth a try.

it seems like the program is overwriting the script as a security method.

could you try and convert the code into exe file and run as an admin. this should overwrite the program.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM