Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detecting if mouse is connected to PC

Status
Not open for further replies.

SkennyR

Programmer
Mar 7, 2004
157
US
I have searched for this, but cant find the answer.
Can a VB6 program detect if the mouse is plugged into the PS/2 port?
Thanks in advance.
 
GetSystemMetrics and SM_MOUSEPRESENT
But, it can be not sufficient.
 
Thanks.
But I cant get it to work, can you give me an example?
 
Thanks Johnwm!
That is pretty neat, except I copied and pasted the code to my form, and I added this bit:
Me.Print "Mouse present= " + Str$(GetSystemMetric_
s(SM_MOUSEPRESENT))
The mousepresent value doesnt change.
I am using a USB mouse. I start the code by pressing F5 when I have the mouse unplugged.
The only thing that changes is number of buttons. 3 if mouse plugged in, 2 if not.
Why do I want to do this?
I am throwing together a home arcade machine (80's style).
I would like to run the game "front end" on bootup, unless the mouse is plugged in, then it boots up on windows, for servicing.
Thanks for your help, it would be nice if this could be done from a dos batch file, but i dont know how to do it. (I will be using win98 on the machine.)
I thought about writing a small vb6 program that would run on boot-up and do the mouse check.
Any arcade enthusiasts out there?
 
Thanks BobRodes!
I found something called DEV_BROADCAST_HDR.
I think this might work, but Im not sure how to use it.
Im not sure if it is legal to paste the code examples here, but here is the link: (I found it in the link you posted).
As one can easily see, Im not a VB6 expert, but I am thankful there are places like this forum.
 
I'm not sure how to use it either, but I'm sure someone here is.
 
I guess no one can help me?
This has got to be simple, Windows detects if the mouse is not hooked up on boot-up.
This method would be useful not just for my arcade machine, but for any program that must have the mouse.
Well, if I come across the answer I will post it here, just in case someone else might want to know.
In the meantime, feel free to offer any ideas.
Thanks.
--ken
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top