Hey! Not sure if this is the right place to post this, but thought Id give it a shot.
I'm making a chatbot which sends hotkeys to OBS using the PostMessage function from user32.dll in C#. Im getting it to work... sort of.
It works only after I open and close the setting window in OBS. And it stays working after that until I click and manually change something (Like a scene). At that point Ill have to open and close the Settings window again to get the hotkeys to work from my app.
They work as they should without issues when I actually click the keys on my keyboard.
So my question is. Is there a message, command or in some way something Im missing to send to OBS that makes it bug out?
As an example. Pushing the A key:
When actually pusing the key on my keyboard it registers the following keyboard events in spy++
WM_KEYDOWN with a wParam 00000041 and lParam 001E0001
WM_CHAR with the A character
WM_KEYUP with a wParam 00000041 and a lParam C01E0001
Ive been able to recreate these very messages in the bot Im creating. And as mentioned over, they work. BUT its that issue with having to click the settings button once to make it work in the first place and any time I click anything else I have to reopen the settings window.
Am I missing something stupidly easy here like a message of sorts? Is there a bug there?
If you want the whole sourcecode just poke at me, but the part that does the actual message sending (the "keystrokes") looks like so:
I'm making a chatbot which sends hotkeys to OBS using the PostMessage function from user32.dll in C#. Im getting it to work... sort of.
It works only after I open and close the setting window in OBS. And it stays working after that until I click and manually change something (Like a scene). At that point Ill have to open and close the Settings window again to get the hotkeys to work from my app.
They work as they should without issues when I actually click the keys on my keyboard.
So my question is. Is there a message, command or in some way something Im missing to send to OBS that makes it bug out?
As an example. Pushing the A key:
When actually pusing the key on my keyboard it registers the following keyboard events in spy++
WM_KEYDOWN with a wParam 00000041 and lParam 001E0001
WM_CHAR with the A character
WM_KEYUP with a wParam 00000041 and a lParam C01E0001
Ive been able to recreate these very messages in the bot Im creating. And as mentioned over, they work. BUT its that issue with having to click the settings button once to make it work in the first place and any time I click anything else I have to reopen the settings window.
Am I missing something stupidly easy here like a message of sorts? Is there a bug there?
If you want the whole sourcecode just poke at me, but the part that does the actual message sending (the "keystrokes") looks like so:
Code:
[DllImport("user32.dll")]
static extern bool PostMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);
...
PostMessage(*mainwindowhandle from OBS proc*, 0x0100, (IntPtr)*hotkeyvalue(0x41 for a), (IntPtr)0x001E0001);
PostMessage(*mainwindowhandle from OBS proc*, 0x0101, (IntPtr)*hotkeyvalue(0x41 for a), (IntPtr)0xC01E0001);