Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

It's possible to recognise hidden mouse cursor by game?



  • Hello, how can I recognise hidden cursor by game (minecraft)? In other games (no java games, ex. Arma3) I can use "GetCursorInfo Flags", but in this case it dont work (always print "visible").

    #include <iostream>
    #include <windows.h>
    
    int main()
    {
        while (true)
        {
            CURSORINFO ci = {sizeof(CURSORINFO)};
    
            if (GetCursorInfo(&ci))
            {
                if (ci.flags == 0)
                    std::cout << "hidden\n"; // cursor is hidden
                else if (ci.flags == 1)
                    std::cout << "visible\n"; // cursor is visible
                else if (ci.flags == 2)
                    std::cout << "suppressed\n"; // cursor is suppressed
                else
                    std::cout << "ERROR\n"; // this shouldn't happen!
            }
            else
            {
                std::cout << "Win32 error: " << GetLastError() << std::endl; // GetCursorInfo function failed
            }
        }
    }
    

    It's possible to "fix" it using Qt?


  • Lifetime Qt Champion

    Hi
    If the game is using a custom cursor, im not sure you can use GetCursorInfo on it.



  • What do you mean in "custom cursor"? It probably works like in other games, hide cursor to move camera, and show cursor when open inventory or open menu. I need to recognise when inventory open by cursor visibility. I tried with those code above, but it dont work in Minecraft (in for example Arma3 works good).


  • Lifetime Qt Champion

    @BD9a
    Hi
    A custom cursor is one where they do not use the system API for it.
    Like draw it as a sprite or other methods.
    In that case the API wont return useful info.


Log in to reply