Window1 consists of a timerclass object which contains a timer running at 60hrz.
Expand|Select|Wrap|Line Numbers
- public Window1()
- {//in Window1.xaml.cs
- MainTimerClass = new TimerClass(); //my timer class object
- }
Keyboard class is defined as below.
Expand|Select|Wrap|Line Numbers
- class KeyboardHandle
- {
- public KeyboardHandle()
- {
- }
- public void ProcessKeyboardEvent(ref Hashtable MappedKeyTable)
- {
- foreach (DictionaryEntry de in MappedKeyTable)
- {
- Key TempKey = (Key)de.Key;
- if(Keyboard.IsKeyDown(TempKey))
- {
- int pq = (int)de.Value;
- }
- }
- }
Basically I want my code to check a given set of keyboard keys to see if they are pressed or not. I saw that the GUI element of WPF runs on a different thread and I have to use the Dispatcher.Invoke methods, but 1.) Why is the keyboard tied to a UI thread? two How can I use the dispatcher.Invoke to get the keyboard state? Any ideas on how to do this? I could just use windows hooks or Wnd_Proc, but I would prefer not to... Any ideas/suggestions? Let me know if you need anything else posted.