By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,950 Members | 989 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,950 IT Pros & Developers. It's quick & easy.

How to ignore user click?

P: 5

How can I make all user clicks (mouse and keyboard) to be ignored on a windows form (using C#), while a computer bot is still able to do so? All buttons, listbox, textbox, etc. need to stay enabled. A computer bot selections, changes and click animations need to be and stay viewable by the user, but only able to be done by the bot. It should be like the computer is having the full control over the form and the user is only watching him work on it.

Mar 4 '09 #1
Share this Question
Share on Google+
6 Replies

P: 179
If you have an OnMouseDown and on OnKeyDown method on your Form that don't do anything, you could override each control and ensure that their methods just call the form methods. Or I believe you could add events to each of the controls to fire on a MouseDown or KeyDown as they're added to the form, call the main Forms methods to process the events, and cancel the Eventargs afterwards so the original control does not process the message.
Mar 4 '09 #2

P: 5
I don't know how to do that.
If i leave those events empty on each control, it still works as normal.
And not always the bot works on the form. Sometimes user gets the control over it, but when bot does (bot turn) that behavior should be.
Plus, does that prevent user to select something?
Mar 4 '09 #3

P: 47
you could add something like the following code to all the functions, but it might be a bit bothersome to do on many controls.
and you would need an extra boolean to tell wether its the bots turn

Expand|Select|Wrap|Line Numbers
  1. if(botTurn == true)
  2. {
  3.      //Do nothing or tell the user its not his/her turn
  4.      return;
  5. }
  6. //Code you want done if it is your turn
Mar 4 '09 #4

P: 5
Well it is not that kind if ignoring the click i need.
I still can see the button icon animating by my click and on a dialog it will return a result.
To make the understanding on it how it should behave, imagine that you have an opened dialog of some child form. At that point u can't do anything to the parent. That is behavior i need. As a parent form, but still not to have that child.
Mar 4 '09 #5

P: 179
You mean you want a Parent to display a Child form, and for only the Child form to respond to any events?

If so... do you mean you want to do Form.ShowDialog(); ?
Mar 4 '09 #6

P: 5
I know what ShowDialog() means. what i need is my form to act as if it had a child opened with ShowDialod and not to have that child actually. User actions to be ignored by the form. Only my background computer logic to work as a user could work normally. To see all animation on button clicks and selections by that logic.
Mar 4 '09 #7

Post your reply

Sign in to post your reply or Sign up for a free account.