I would like to send DirectInput keys to an inactive window without interfering with my actual mouse. I tried using PostMessage, SendInput and SendMessage but pywin32 uses virtual keycodes while ctypes does work with DirectInput. I have no idea how I can make it send in an inactive window.
            Asked
            
        
        
            Active
            
        
            Viewed 926 times
        
    3
            
            
        - 
                    1[\[SO\]: How to create a Minimal, Reproducible Example (reprex (mcve))](https://stackoverflow.com/help/minimal-reproducible-example). Can you post your code to get an idea what's working and what's not? – CristiFati Feb 25 '21 at 09:05
 - 
                    I have no code, I don't know how I can do this. – The Laggy Tablet Feb 25 '21 at 15:09
 - 
                    Hmm, then some statements are misleading: "*I tried using PostMessage, SendInput and SendMessage but pywin32 uses virtual keycodes while ctypes does work*". – CristiFati Feb 25 '21 at 17:27
 - 
                    Well, I did write that code, but it does nothing related to *directinput* it uses vk – The Laggy Tablet Feb 25 '21 at 17:29
 - 
                    Then, you'd better post it here in order to reduce the chances of getting this question closed. Check [\[SO\]: How do I ask a good question?](https://stackoverflow.com/help/how-to-ask) or [\[SO\]: How to create a Minimal, Reproducible Example (reprex (mcve))](https://stackoverflow.com/help/minimal-reproducible-example) for more asking related details. Otherwise you'll get lots of *-1* s. – CristiFati Mar 05 '21 at 03:58
 
1 Answers
-1
            
            
        Try using this, it manages to work for me send the keystrokes to the inactive window,
Use (but add error checking) hwndMain = win32gui.FindWindow("notepad", "prueba.txt: log keys") hwndEdit = win32gui.FindWindowEx
- 
                    I know how to send keys to an inactive window, I just want to send DirectInput keys to an inactive window – The Laggy Tablet Feb 16 '21 at 10:59
 - 
                    Try this post https://stackoverflow.com/questions/55387230/how-would-i-go-about-simulating-direct-input-to-an-inactive-window – Michiel Feb 16 '21 at 11:03
 - 
                    I have seen that post, but I do not want to use that workaround. – The Laggy Tablet Feb 16 '21 at 14:07