Reputation: 1398
i have written a small form application, which contains textbox only. I have enabled shortcut key by using low level keyboard hook to give focus to application when needed. All is working fine, I press the short key i.e. (Left Control Key)+(Left Control Key) for the first time the application get proper control (focus). But when I deactivate and redo the shortcut key, the icon of the application on the taskbar starts blinking and the form doesn't get focus, the title bar is greyed out.
More Information :
I am giving focus to the application by using form.Activate() I have also tried from.Visible but with no luck. The activation works for the first time only, post that the icon in taskbar blinks.
Does any have any idea why is this happening?
Upvotes: 0
Views: 1436
Reputation: 9244
This answer applies to you as well: https://stackoverflow.com/a/3789985/64121 . You need to make use of the AttachThreadInput API function in order to steal focus away from another app.
Upvotes: 1