I'm trying to create a function that detects software signals within a game. However, my thread is a separate thread from the UI thread and should not affect the UI thread.
I've tested it by creating a message-only window and calling getmessage on my thread, I receive messages fine until I click on a game, but when I click on a game, all messages are not received.
My test code is below.
mythread.cpp
HINSTANCE instance = GetModuleHandle(nullptr);
WNDCLASSEX wndclass;
wndclass.cbSize = sizeof(WNDCLASSEX);
wndclass.lpfnWndProc = myproc;
wndclass.hInstance = instance;
wndclass.lpszClassName = "test";
DWORD ret = RegisterClassEx(&wndclass);
HWND hwnd = CreateWindowEx(0, "test", "dummy", 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, instance, 0);
RAWINPUTDEVICE device = { 0 };
devices.usUsagePage = 1;
devices.usUsage = 2;
devices.dwFlags = RIDEV_INPUTSINK;
devices.hwndTarget = hwnd;
RegisterRawInputDevices(devices, 1, sizeof(RAWINPUTDEVICE));
MSG msg;
while(true)
{
while (GetMessage(&msg, hwnd, 0, 0))
{
TranslateMessage(&msg);
DispatchMessageW(&msg);
}
}
myproc
LRESULT CALLBACK myproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
switch (msg)
{
case WM_INPUT:
{
...
}
}
return DefWindowProc(hwnd, msg, wparam, lparam);
}
Can you please let me know what I did wrong?