1

I'm using ImGui v1.84, I wanted to disable any sort of keyboard or mouse input while my ImGui window is open. How can I do this? (I'm fairly new to ImGui, & using Kiero Hook Dx11)

I modified the WndProc function to handle input events but I don't think I did it correctly?

LRESULT __stdcall WndProc(const HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
    if (uMsg == WM_KEYDOWN && wParam == VK_INSERT) {
        showImGuiWindow = !showImGuiWindow;
        ImGui::GetIO().MouseDrawCursor = showImGuiWindow; // To Toggle Mouse Cursor
        return true;
    }

    if (showImGuiWindow) {
        if (ImGui_ImplWin32_WndProcHandler(hWnd, uMsg, wParam, lParam))
            return true;

        // Block all keyboard and mouse input events when ImGui window is open?
        if (uMsg == WM_KEYDOWN || uMsg == WM_KEYUP || uMsg == WM_CHAR ||
            uMsg == WM_MOUSEMOVE || uMsg == WM_LBUTTONDOWN || uMsg == WM_LBUTTONUP ||
            uMsg == WM_RBUTTONDOWN || uMsg == WM_RBUTTONUP || uMsg == WM_MBUTTONDOWN ||
            uMsg == WM_MBUTTONUP || uMsg == WM_MOUSEWHEEL || uMsg == WM_MOUSEHWHEEL) {
            return true;
        }
    }

    return CallWindowProc(oWndProc, hWnd, uMsg, wParam, lParam);
}
3
  • 1
    Why do you think that you didn't do it correctly? What is the problems you're having? Commented Jun 4, 2024 at 5:58
  • Apologies, I see my mistake, I was having issues with mouse input, when I inject my dll to my game, I am still able to look around, and I don't want to be able to do that. Commented Jun 4, 2024 at 6:14
  • 1
    Have you considered that your target process might not be relying on the WndProc to process input? The game loop can just as well query the mouse position itself. Commented Jun 4, 2024 at 7:26

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.