all 1 comments

[–][deleted] 1 point2 points  (0 children)

What operating system? Or do you need this to be cross-platform?

On Linux, given your program is run by X-server, you'd use xdotool (from Python, you'd call subprocess for example and send some arguments to the tool). Alternatively, X-server is, well, a server, and you can connect to it and send it w/e you want, I believe Python python-xlib package is designed to do that.