?
Solved

Disable keyboard and mouse?

Posted on 2003-11-19
7
Medium Priority
?
392 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

801 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