DJSchaffner
DJSchaffner

Reputation: 582

How would i go about simulating direct input to an inactive window?

I want to send direct input to a (possibly) inactive window in python. So far i have found a solution to send direct input via ctypes and i have a solution to simulate input to a window, which doesn't work with some games as the one i am testing with (GTA V) is using direct input, using postMessage()via py32win.

So how would i now go about simulating those direct inputs while the target window is possibly not active? Is this even possible?

I would think it should be, because AutoHotkey for example can manage to send direct in such a case.

If you would like to experiment yourself i can provide the postMessage() version, otherwise i would like to keep the question code-free.

Upvotes: 2

Views: 2964

Answers (1)

Reedinationer
Reedinationer

Reputation: 5774

As far as I can tell you cannot do this. A workaround (found at https://www.reddit.com/r/Python/comments/5wpxtt/automation_in_inactiveunfocused_window/) would be

  • get a VM on your machine
  • load the game and your script onto the VM
  • run game and have your script interact with active window (on VM)
  • minimize the VM window of your main machine

Upvotes: 2

Related Questions