Solved

Disable keyboard and mouse?

Posted on 2003-11-19
7
388 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

685 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