Reputation:
I had a little trouble phrasing this title, but allow me to explain. PyAutoGUI
i allows you to automate anything by controlling your mouse and keyboard. However, if a pyAutoGUI
script is running, it means you cannot touch your keyboard/mouse as its being controlled by the script.
My question is how can you automate a program (thats not a window's program, for example Photoshop, Steam or other non-windows programs [to clarify, when I say non-windows programs, I mean default programs like notepad, paint etc]) without giving up your keyboard and mouse. I know there is PyWinAuto
, but that is only for windows programs only like notepad
). Meaning you can let the script run in the background while you can do something else on you computer.
A possible solution to this is to run the script in a virtual machine but I am looking for a solution which I don't have to do this. Is there a python module that something which may allow me to do this? I want to interact with the interface of photoshop, without me having to sit through and watch the script take over my computer and do its thing.
Example scenario with pyAutoGui:
// I run the python script.
// I can no longer touch the keyboard and mouse because
// if I do, it will mess up the script. Meaning the active window on my
// computer is photoshop and I am forced to look at the endless
// while loop
Open photoshop
i = 0
while(1) {
mouse click x=i y=i
type "hello world"
i++
}
Example of a solution I am seeking:
// I run the python script.
// A controlled window (similar to a selenium browser) opens up.
// In Selenium you can minimise a selenium browser while its doing its
// automated tasks and do whatever you wish.
//
// I minimise the controlled window and start doing my own thing while
// in the controlled window, its opens photoshop and does the while loop
Open photoshop
i = 0
while(1) {
mouse click x=i y=i
type "hello world"
i++
}
Upvotes: 7
Views: 1761
Reputation: 1090
A photoshop API is now available in 2020 and I also found this post that has a video walktrough detailing how to control photoshop using python. From briefly watching the video it appears that the code executes on the backend of windows so you're free to use your mouse and keyboard while the code is running without any interference.
Upvotes: 1