?
Solved

disabling and enabling the mouse in VB

Posted on 2000-02-07
11
Medium Priority
?
252 Views
Last Modified: 2010-05-02
I need to know how to disable then re-enable the  mouse using vb code. I've tried using an API call to disable it but I can't enable it again. Any help would be very much appreciated.
0
Comment
Question by:ryan_bull
  • 3
  • 3
  • 3
  • +1
11 Comments
 
LVL 1

Accepted Solution

by:
jelliott720 earned 100 total points
ID: 2497292
If you are using a form and you just want to keep the user from clicking on a button or entering data while a procedure is being performed..

Add the following to the procedure..
 '
 Screen.MousePointer = vbHourglass
 Me.Enabled = False
 ' Perform your task here
 '
 Screen.MousePointer = vbDefault
 Me.Enabled = True          
0
 
LVL 12

Expert Comment

by:roverm
ID: 2497378
What API call did you use ?
0
 
LVL 1

Expert Comment

by:jelliott720
ID: 2497406
There is no API call necessary.. The
'Me.Enabled = False' disables the Form, therefore no keystrokes get accepted via the Form.. until your set Me.Enabled = True....
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
LVL 1

Expert Comment

by:jelliott720
ID: 2497447
This technique is very effective when the Form is displayed in the Modal mode..The user cannot do anything but Reboot the machine until your ready..
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 2500533
"The user cannot do anything but Reboot the machine until your ready"

In yer dreams. The only thing the user will not be able to do until you're ready is to access anything within the application. Outside the application, you're fine. Thankfully...
0
 

Author Comment

by:ryan_bull
ID: 2500829
The api call that I used was:

Shell "rundll32 mouse,disable"
to disable the mouse.

Shell "rundll32 keyboard,disable"
to disable the keyboard.

and

Shell "rundll32 mouse,enable"
to try to enable it again.

but this didn't work.

I'm sorry if I didn't explain it clear enough in my original question, but I need to enable / disable the mouse for the whole computer (not just for a VB form).

The problem is that when I disable the mouse & keyboard using this command I can't re-enable it again.

The reson why I need to do this is for a remote contol application for I.T. demonstrations that moves the mouse on a remote computer, and it would be usefull if the user on the remote computer doesn't use it at the same time as the person using the remote software.

Thanks for any help that you could provide.

Ryan Bull
0
 
LVL 12

Expert Comment

by:roverm
ID: 2501086
This works perfectly:
Place 2 command buttons on a form, named cmdHide and cmdShow then paste this code:

Private Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long

Private Sub cmdHide_Click()
Dim i As Integer
   
    Do
        i = ShowCursor(False)
    Loop While i > -1
   
End Sub

Private Sub cmdShow_Click()
Dim i As Integer
   
    Do
        i = ShowCursor(True)
    Loop Until i > 0

End Sub

Good Luck !
RoverM
0
 

Author Comment

by:ryan_bull
ID: 2507213
Thanks for that roverm, I tried it out and it worked! there was just one problem - the mouse cursor was still visible and could still be used when it was moved out of the area of the form.
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 2507262
"could still be used when it was moved out of the area of the form"

Absolutely. Windows is (supposed to be) a multi-tasking operating system. It would be horrendous if one application could lock up the whole machine. Those Windows 3.x days are over, and thanks be to Bill. Or whomever.
0
 
LVL 12

Expert Comment

by:roverm
ID: 2507398
Start the sub again within the mouseover event of the form ?

caraf q: who's Bill ;-)) ????

RoverM
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 2507467
Who's Bill... Now there's a Billosophical question with many possiBill answers: Billy The Kid, Bill Clinton, Bill Board, can I have The Bill please, Duck Bill, DeBillitating...

caraf_g
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month5 days, 20 hours left to enroll

589 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