Script to send input to non-focused window?

I am curious as to how one would go about coding something that can send inputs (and possibly even interpret outputs) to a window that isn’t focused. I would like to be able to perform tedious repetitive motions automatically on an application, while actually having a different window in focus.

Is it possible? Googling about this has mostly come up empty (surprisingly).
If so, would it be doable with python? If not, what would be the ideal language?
Would running the target application in a virtual machine environment simplify this, by leaving said application in focus inside the VM and running the script from inside the VM?

1 Like

Script can only run in the single namespace that contains it. Cross-site scripting is a security concern that most browsers (if not all) will not allow.

It may be possible if you have a server to act as the middle man. Connect both clients and have them talk to the server. Way over my head, though, so belay, belay if this is mere speculation.

1 Like

Assuming you mean windows desktop (I imagine pretty much any user of anything else would mention their platform) you’re probably looking for ahk

1 Like

Yes, it’s for Windows 10. Is AHK able to send inputs to non-focused windows? I’ve used it before briefly but wasn’t aware it could do that.