How do I create a C# hotkey that can be triggered in my app but won't lock other running applications from using that hot key?
Is the only way to achieve this is by doing a key press check event on all the possible "focus-able" controls on my app?
How do I create a C# hotkey that can be triggered in my app but won't lock other running applications from using that hot key?
Is the only way to achieve this is by doing a key press check event on all the possible "focus-able" controls on my app?
In general, windows only sends keypresses to the window that has the focus. I don't program in C#, but I doubt that it works differently than a regular Win32 app in that regards.
In other words, if your application doesn't have the focus, then it won't receive keypresses, so you won't "block" other applications in any way.
bit∙hub [bit-huhb] n. A source and destination for information.
There is the RegisterHotKey command im user32.dll to register hotkeys as global, which will fire events regardless of who has focus. I put a check in which if my window did not have focus, I set the e.handled to false, however that had no effect at all.
I don't really want events to fire when my window is not focused, but I wanted them to fire regardless of what had focus within my application. Seems putting key press events on each object may do the job.
You might want to get this issue moved to the C# forum. What you want to do is really easy with regular Win32 programming, but I don't know how to help you with the C# stuff.
bit∙hub [bit-huhb] n. A source and destination for information.
I ended up getting what I needed by setting KeyPreview to true on my main form and then catching KeyDown on that form.
Thank you.