Solved

Disable keyboard and mouse?

Posted on 2003-11-19
7
391 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
Technology Partners: 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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

696 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