Hiding and showing the system mouse pointer

Hello Experts!

I'm trying to write an application that will hide the mouse cursor if it is idle (for more than, say, a second), and is shown when the mouse is moved.

I can set the system pointer, I just don't know how to get notification of when it's moving.
The application needs to show and hide the mouse even when using other applications.

There is an application that does this
http://www.softexe.com/cursorhider.html
but we can't afford licenses for every machine it will be installed on.

So I'm trying to do something similar.

I will also award points to anyone who can find a free application that does this.

Just to let you know the reason for this:
The systems will not have a keyboard and mouse, but Windows 98 (which we're using) insists on displaying the mouse cursor even if there is not a mouse attached.

Ok, I'll also award points for anyone who knows how to stop the mouse being displayed if there's not one attached :)
LVL 1
TimDSmithAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
ee_ai_constructConnect With a Mentor Commented:
PAQed, with points refunded (100)
ee_ai_construct - CS Mod
0
 
Nass89Commented:
Hi,
To hide mouse pointer, you may move it to right-bottom of screen. The following code hides and shows the mouse pointer:
   
      //m_pL is a Global or class member variable to save the last position of mouse  opointer
                POINT m_pL;

Hide_Pointer()
{
      GetCursorPos(&m_pL);
      SetCursorPos( 5000, 5000);
}

Show_Pointer()
{
      SetCursorPos(m_pL.x, m_pL.y);

}

Instead of detecting mouse attachment, write an Application to hide mouse cursor and run it at startup.

Good Luck!
0
 
waysideCommented:
The CursorHider program you referenced registers a hook (SetWindowsHookEx) .

I'm guessing it uses a mouse hook (WH_MOUSE) to turn the cursor back on (probably with ShowCursor() ) whenever it detects a mouse event (mouse moved or button click or whatever, and probably uses a timer to turn it off if it hasn't moved in a second or two.

See the MSDN pages for SetWindowsHookEx ( http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/hooks/hookreference/hookfunctions/setwindowshookex.asp ) and MouseProc (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/Windowing/Hooks/HookReference/HookFunctions/MouseProc.asp ).
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
vijay_visanaCommented:
Please clear following things

1) You want to make mouse disappear only from your application or whole system
2)  what type of application you lhave ? (i.e. Dialog -modal modless,doc view -SDI MDI or console application dll etc..)

I have tested one solution in moda/modeless dialog and it is working fine

TAKE NEW CURSOR AND DO NOT DRAW ANYTHING
OVERRIDE ONMOUSEMOVE AND ONSETCURSOR AND ONTIMER HANDLER FUNCTION
ON TIMER SET MOUSE (WHICH HAS NO DRAWING)
ON MOUSE MOVE SET CURRENT MOUSE TO ARROW
ON SET CURSOR
  SET CURRENT CURSOR CALLING SetCursor() function



0
 
TimDSmithAuthor Commented:
I decided to write my own from scratch.

Download it from:

http://www.ezblitz.com/TimsHideCursor/TimsHideCursor.exe

The application runs in the system tray.

Left click the arrow icon to disable/enable cursor hiding.
Right click and select Exit from the menu to close.

I only hide the normal cursor at present as that's all I need to do, but I'll update it as and when required.

Hope people can find a use for this as well as me.

Thanks for your comments.

Kind regards

Tim

0
 
waysideCommented:
So, how did you wind up doing it?
0
 
vijay_visanaCommented:
I think you have enough clue now

;-)
0
 
TimDSmithAuthor Commented:
I used a timer which fires every second. In the handler I call
GetCursorPos(&pos)
and compare it with the previous position. If it changes I show the mouse

HCURSOR cursor = app->LoadCursor(IDC_POINTER);
SetSystemCursor(cursor, 32512);

else I hide it and use a transparent icon.

I didn't bother using the hooks method, although this would have shown the mouse quicker when it began to move again.

Not sure who should get the points.
0
 
TimDSmithAuthor Commented:
Perhaps me :)
0
 
DCMEDIAroCommented:
I am looking for this kind of software too. Can U send the link again? The old domain is not working anymore.
Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.