How to send key
-
Hi All, I have developed a simple WPF application, where I want to send key (i.e. F5) so that all controls gets filled with updated data from DB. I have already written code for this and it works fine when i press F5. What i want to do now is that I want some way to send F5 key through code so that after doing some action it does F5 through code. [I cannot directly call the method which performs repaint task because I am in another class] Any help? Thanks, AksharRoop
-
Hi All, I have developed a simple WPF application, where I want to send key (i.e. F5) so that all controls gets filled with updated data from DB. I have already written code for this and it works fine when i press F5. What i want to do now is that I want some way to send F5 key through code so that after doing some action it does F5 through code. [I cannot directly call the method which performs repaint task because I am in another class] Any help? Thanks, AksharRoop
-
There is a SendKeys in .Net http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.aspx[^] But, I would recommend you change your structure so you don't need to send key strokes to your own application.
Does this works for WPF window as well? Because when i tried using this it gives error that your application is not set to handle window messages? I cannot change structure of application because drag-drop framework is designed such that there are different classes, so when item is moved from Window, it is handled by framework class and once processed I want framework to send key.
-
Does this works for WPF window as well? Because when i tried using this it gives error that your application is not set to handle window messages? I cannot change structure of application because drag-drop framework is designed such that there are different classes, so when item is moved from Window, it is handled by framework class and once processed I want framework to send key.
Well... I didn't verify that it would or would not work. I thought "why would it not?" The message about the application not handling window messages is ridiculous. Every window in Windows must send and receive Windows messages on some level. That is the way Windows works. I also tried using SendWait like the error suggests but that doesn't work. The only thing I can think of is to have some class with a static/shared event and method that raises that event. Then your window that needs the refresh could register to that event and the class that needs to send the refresh could call the method that sends the event. I hope that is not too confusing. It doesn't seem like a great solution but it will work.