WinAPI help - DirectInput to inactive window

Talk about things C#, some related to AutoHotkey
Xiaojiba
Posts: 2
Joined: 02 Jan 2021, 14:32

WinAPI help - DirectInput to inactive window

Post by Xiaojiba » 02 Jan 2021, 16:28

Hello everyone !
I'm developing an application that converts text to keystroke (to a specific window) => in my discord for example if I want to run !press F It should press f on the specific window

however, the specific window has no Windows Message processing loop (GetMessage), it only detects raw input from a keyboard

I want to be able to reproduce it, using c# (I could run a AHK process, to fullfil this, but it's not the idea)

I try reading AutoHotKey_L code on github (keyboard_mouse.cpp specifically but could not comprehend what was going on)

Thanks a lot for any help ! :heart:

This is the current code i'm using (I don't know which subprocess to send the message so I send to all of them)

Code: Select all

private static void loop_child(IntPtr current, int keycode, bool down = false, int level = 0)
{
    List<IntPtr> children = GetChildWindows(current);
    // This ↓ is debugging
    Console.WriteLine(new string('\t', level) + current);
    
    if (down)
        PostMessage(current, WM_KEYDOWN, keycode, 0x00000001);
    PostMessage(current, WM_KEYUP, keycode, 0xC0000001);

    foreach (var child in children)
        loop_child(child, keycode, down, level + 1);
}
https://github.com/TASVideos/desmume/issues/411

All of this is on DeSmuMe Emulator
Last edited by gregster on 02 Jan 2021, 16:42, edited 1 time in total.
Reason: Moved to 'Other Programming Languages' since it's mainly a C# question.
gregster
Posts: 5837
Joined: 30 Sep 2013, 06:48

Re: WinAPI help - DirectInput to inactive window

Post by gregster » 02 Jan 2021, 17:17

I would take the relevant C++ from AHK's source and ask on a C# forum, tbh.
Sure, we have some C/C++/C# programmers here - and they might chime in (or not), but this is not really an AHK support question, imho.
Good luck!
Xiaojiba
Posts: 2
Joined: 02 Jan 2021, 14:32

Re: WinAPI help - DirectInput to inactive window

Post by Xiaojiba » 02 Jan 2021, 17:20

Hey thanks for your answer,

The problem is not the actual c++ code, I could manage understanding it
However, I don't know where to look at, as said previously, I read mouse_keyboard.cpp

but it's like 2000 lines and I don't know where to look at for direct input ?

Thansk for your answer !
gregster
Posts: 5837
Joined: 30 Sep 2013, 06:48

Re: WinAPI help - DirectInput to inactive window

Post by gregster » 02 Jan 2021, 17:23

I see. Well, perhaps one of the few users who actually know their way around the AHK source can help out.
Post Reply

Return to “C#”