1

So I'm writing a VB.NET Windows Form application and I have a WebBrowswer control in it. When the user presses CTRL + D I would like for the debug information to show, no matter what control is in focus.

Currently, I have this working for when the focus is on the form; however, it doesn't work when focus is on the WebBrowser control (such as when they are entering information into a text box).

I looked up global hotkeys and found a couple things on that, but I don't think that's what I'm looking for since, from what I understand, they work when even the application itself is not in focus and works on a global OS scale with the application.

I've also tried to do a few little things like try to force focus to the form when something else happens, but it doesn't always work.

Is this possible? Thanks for any help.


EDIT:
The answer to this question can be found here.
Then, in combination with this answer the I got the exact result I'm looking for (since I have a settings form that pops up and I don't want to trigger it in that case).

Community
  • 1
  • 1
Josh Braun
  • 490
  • 2
  • 16
  • You could determine if the application is in focus when the global hotkey is pressed using GetActiveWindow (http://msdn.microsoft.com/en-us/library/ms646292%28VS.85%29.aspx). –  Mar 21 '14 at 13:56
  • Oh, ya. That would work. I didn't even think about that. – Josh Braun Mar 21 '14 at 14:15
  • Yup, that is exactly what I was looking for. Dang, I thought I looked better than I did. My bad. – Josh Braun Mar 21 '14 at 15:05
  • You have to use windows API. There is the same question: [global-windows-key-press][1] [1]: http://www.stackoverflow.com/questions/11752254/global-windows-key-press – Aik Mar 21 '14 at 15:52
  • @Aik No you don't. I already said I had found stuff on global/system-wide hotkeys and that wasn't what I was looking for since I only wanted it to deal with my application (and honestly, I didn't want to have to detect my which window was open and wanted to keep it all in VB and not go "outside" to make it work). If you read the "EDIT" section I added I link to the answer that solved the issue. – Josh Braun Mar 21 '14 at 15:57

0 Answers0