Solved

Hiding and showing the system mouse pointer

Posted on 2004-04-27
11
347 Views
Last Modified: 2013-11-20
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 :)
0
Comment
Question by:TimDSmith
  • 3
  • 2
  • 2
  • +3
11 Comments
 
LVL 5

Expert Comment

by:Nass89
ID: 10927718
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
 
LVL 14

Expert Comment

by:wayside
ID: 10928037
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
 
LVL 7

Expert Comment

by:vijay_visana
ID: 10936868
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
 
LVL 1

Author Comment

by:TimDSmith
ID: 10936991
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
 
LVL 14

Expert Comment

by:wayside
ID: 10937742
So, how did you wind up doing it?
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 7

Expert Comment

by:vijay_visana
ID: 10937904
I think you have enough clue now

;-)
0
 
LVL 1

Author Comment

by:TimDSmith
ID: 10938173
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
 
LVL 1

Author Comment

by:TimDSmith
ID: 10938175
Perhaps me :)
0
 

Accepted Solution

by:
ee_ai_construct earned 0 total points
ID: 11155921
PAQed, with points refunded (100)
ee_ai_construct - CS Mod
0
 

Expert Comment

by:DCMEDIAro
ID: 24305686
I am looking for this kind of software too. Can U send the link again? The old domain is not working anymore.
Thanks.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now