Solved

Disable keyboard and mouse?

Posted on 2003-11-19
7
385 Views
Last Modified: 2007-12-19
I was wondernig if there is a way to disable mouse and keyboard entries temporarily.  I have written a macro program that moves the mouse pointer using mouse_event and causes keypresses using keybd_event.  

I would not like a person to come come along and insert extra mouse events and keystrokes while my macro is running, since it could cause errors in my macro executing.  

Is there a way to prevent user interference?

Thanks for your help!
0
Comment
Question by:Masurium
7 Comments
 
LVL 2

Expert Comment

by:MirkoLMV
ID: 9795768
Threaded applications seem to be a good answer for problems as yours. A thread should take care about the input and another one for processing. Various synchronization mechanisms (synchronizations, mutexes, etc) are available to prevent sending of wrong messages on wrong moments.
WinAPI allows threads, but I am not sure if there are some difference when using threads on other platforms.

Good luck !
0
 
LVL 16

Expert Comment

by:George Tokas
ID: 9795933
>>int result;
>>SystemParametersInfo(SPI_SCREENSAVERRUNNING, true, &result, NULL);//disables ALT-CTRL-DEL,ALT-TAB,etc
>>ShowCursor(false);//Mouse Invisible

Those of course are in your form not outside it(Windows desktop)
Since you block keyboard and mouse events you must haven't any problem.

>>int result;
>> SystemParametersInfo(SPI_SCREENSAVERRUNNING, false, &result, NULL);
>>ShowCursor(true);//Enable all keyboard and show mouse.

gtokas.
0
 

Author Comment

by:Masurium
ID: 9796654
I actually need to block the events outside of the executing window.  So I don't think your suggestion would help gtokas, but thanks anyways.

MirkoLMV:  I am not sure how multithreading my application would prevent the user from entering keyboard and mouse events.  If you could elaborate a bit, that would be helpful.

I am using WIndows platforms exclusively, so there is no problem using WinAPI.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 16

Expert Comment

by:George Tokas
ID: 9796930
Maximize your window b4 start and restore it after your application finishes...

gtokas
0
 

Author Comment

by:Masurium
ID: 9797533
Actually my macro has to interact with third party software through their GUI.  Maximizing my window would cover the GUI of their software.
0
 
LVL 9

Expert Comment

by:tinchos
ID: 10249314
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

PAQ with points refunded

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Tinchos
EE Cleanup Volunteer
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 10308149
PAQed, with points refunded (125)

modulo
Community Support Moderator
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

932 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

18 Experts available now in Live!

Get 1:1 Help Now