Application not responding to Windows API events?

2019-05-30 02:50发布

问题:

I was working on a project where I wanted to automate a GUI using python, but the windows program I was trying to automate does not respond to pyautogui mouse clicks. Is it possible that the company that made this application intentionally blocked windows API events?

The particular program I am trying to automate is Blackbaud's Raiser's Edge.

I am asking because I am planning on potentially modding a mouse with a raspberry pi to control mouse clicks and then SSH to it from my computer if there is no other work-around for this issue.

回答1:

Windows 10 has made this more difficult. If the application you are trying to automate is running as Admin, you cannot control it with a program running as a regular user.

Try running your python program as administrator.

But, yes, it is possible for a program to distinguish between real mouse events and simulated ones. If it is a highly sensitive program, they may have. Or, if it is a video game, they may just poll the hardware directly and ignore windows messages.

EDIT: Also, many applications want more than a "click" message. They want the mouseenter/mousemove/mousedown/mouseup. If you don't have all of those messages being sent, it won't activate as a "click". pyautogui.click should simulate it properly, but if you experiment with the app and look at how it responds (click mouse without release, what happens?) you might be able to improve the simulation. Maybe put a delay between pyautogui.mouseDown() and pyautogui.mouseUp().

But my hunch is the app is running as a different user than the python script.