11

Whenever I click somewhere to type some code, by definition that's exactly where my mouse cursor is, which is obscuring what I'm trying to type. Often, if I forget to move the cursor away before starting to type, I'll find myself moving my hand from my keyboard back to my mouse just to move the cursor out of the way and then go back to typing.

I know that there is an OS-level "hide cursor while typing" option, but that seems to have no effect in Visual Studio.

Also, I know of utilites that can run constantly in the background (I.e. CursorHider), but, for stability reasons, I'm hesistant to run yet another background service on top of the many that are already running.

Is there a solution?

3
  • Well, you could use a mac... Commented Oct 12, 2009 at 2:40
  • For me, moving the mouse away is a reflex I don't even think about. (that is, until I stopped using regular editors and started using vim)
    – hasen
    Commented Oct 12, 2009 at 7:08
  • Link gives 404, this is the only working program I found today. It works in Visual Studio. softexe.com Commented Jun 3, 2022 at 8:19

5 Answers 5

6

Like you, I've had this problem forever. So I have written a little script that hides the mouse cursor no matter what Windows application you are using.

Note that if you run Visual Studio (or anything) in elevated mode, you'll need to run my utility also in elevated mode.

7
  • I have doubts whether such a forceful method is correct in all situations. The cursor's disappearing whenever any key is typed can for example be very annoying with games.
    – harrymc
    Commented Jan 8, 2014 at 7:06
  • In that case you can just unload it during a game... that said, I believe most games implement their own cursor Commented Feb 23, 2014 at 15:15
  • Windows-Cursor-Hider works good so far. I was looking for something simple like a AHK script. Thanks @StefanZCamilleri!
    – russds
    Commented Feb 8, 2016 at 20:21
  • 1
    Link says the repo isn't there Commented Jun 3, 2022 at 8:20
  • 1
    I have submitted an edit with updated link, but in case it is not accepted for some reason, here is the current link to the repository, including AutoHotkey source code: github.com/Stefan-Z-Camilleri-zz/Windows-Cursor-Hider Commented Jul 15, 2022 at 17:26
3

It seems like the functionality of "hide pointer while typing" depends on the application.

This option is ticked in my mouse's pointer options, and does work for applications such as notepad, wordpad, Word and Visual Studio 6. But it doesn't work for other applications, like Firefox and Visual Studio 2008.

I believe that the applications where this doesn't work are wrongly programmed to show the cursor repeatedly. As a programmer, I can tell you that programming the cursor in Windows is a big mess, where finally the only way to keep sane is to repeatedly reconstitute the cursor upon certain events. Evidently, the programmers behind Visual Studio 2008 have taken the same shortcuts.

1
  • This is an incorrect assumption though, since if you hide the cursor at an OS level, it will remain hidden, voiding the idea of forcing the cursor to show (which would override it) - pls see my answer below Commented Jan 7, 2014 at 22:41
1

I know this isn't probably a viable solution for you but I like to not use the mouse at all by having key bindings for everything within the IDE. I can jump from pane to pane, error to error etc without having to touch the mouse. Also if your classes are nice and small, you won't have to be scrolling up and down classes too much (and even if you had to the arrow keys would suffice).

0

For those who will find this question 15 years later: I wrote a simple Win32 app that solves the problem: https://github.com/johnnyjob/single-cursor It doesn't require AutoHotkey and should work on any version of Windows.

-1

You can avoid the "hide pointer while typing" with catching the EN_UPDATE in WndProc of parent window of edit control, and setting the cursor position:

void CreateEdit( HWND hWnd )
{

    WNDCLASSEX wndClass;

    memset( &wndClass, 0, sizeof( wndClass ) );

    wndClass.cbSize = sizeof( wndClass );
    wndClass.style = CS_SAVEBITS;
    wndClass.lpfnWndProc = WndProcEditParent;
    wndClass.cbClsExtra = 0;
    wndClass.cbWndExtra = 0;
    wndClass.hInstance = GetModuleHandle( NULL );
    wndClass.hIcon = NULL;
    wndClass.hCursor = NULL;
    wndClass.hbrBackground = NULL;
    wndClass.lpszMenuName = NULL;
    wndClass.lpszClassName = L"EditParent";

    RegisterClassEx( &wndClass );

    HWND hWndEditParent = CreateWindowEx( 0
        , L"EditParent"
        , L""
        , WS_CHILD | WS_BORDER
        , 0
        , 0
        , 0
        , 0
        , hWnd
        , NULL
        , GetModuleHandle( NULL )
        , 0 );

    HWND hWndEdit = CreateWindowEx( 0
        , L"Edit"
        , L""
        , WS_CHILD
        , 0
        , 0
        , 0
        , 0
        , hWndEditParent
        , NULL
        , GetModuleHandle( NULL )
        , 0 );

    ...
}


LRESULT CALLBACK Edit::WndProcEditParent( HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam )
{
    switch( iMessage )
    {
        ...
        case WM_COMMAND:
            if( HIWORD( wParam ) == EN_UPDATE )
            {
            // this is the hack to avoid "hide pointer while typing"
                POINT point;

                GetCursorPos( &point );
                SetCursorPos( point.x, point.y );
            }
            break;
        ...
    }

    return DefWindowProc( hWnd, iMessage, wParam, lParam );
}
1
  • 2
    This might be a really great answer, but I have no idea how to use it.   Please add an explanation.   Do not respond in comments; edit your answer to make it clearer and more complete. Commented Dec 18, 2018 at 18:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .