Solved

Disable keyboard and mouse?

Posted on 2003-11-19
7
384 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
Comment Utility
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
Comment Utility
>>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
Comment Utility
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 16

Expert Comment

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

gtokas
0
 

Author Comment

by:Masurium
Comment Utility
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
Comment Utility
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
Comment Utility
PAQed, with points refunded (125)

modulo
Community Support Moderator
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
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 user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

744 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

14 Experts available now in Live!

Get 1:1 Help Now