{"id":19013,"date":"2009-02-26T10:00:00","date_gmt":"2009-02-26T10:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2009\/02\/26\/pressing-a-registered-hotkey-gives-you-the-foreground-activation-love\/"},"modified":"2009-02-26T10:00:00","modified_gmt":"2009-02-26T10:00:00","slug":"pressing-a-registered-hotkey-gives-you-the-foreground-activation-love","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20090226-00\/?p=19013","title":{"rendered":"Pressing a registered hotkey gives you the foreground activation love"},"content":{"rendered":"<p>One category of application that people complained about is <a href=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2009\/02\/20\/9435239.aspx#9436619\"> the application launcher which keys off a hotkey<\/a> and doesn&#8217;t get the foreground love.<\/p>\n<p> Well, except that windows with registered hotkeys <i>do<\/i> get the foreground love. <\/p>\n<p> After you call the <code>RegisterHotKey<\/code> function to register a hotkey, the window manager will send you a <code>WM_HOTKEY<\/code> message when the user presses that hotkey, and along with it, you will get the foreground love. If you call <code>SetForegroundWindow<\/code> from inside your hotkey handler, the foreground window will change according to your instructions. <\/p>\n<p> A <a href=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2009\/02\/20\/9435239.aspx#9436633\"> special administrator-only list of programs which are exempt from <code>SetForegroundWindow<\/code> rules<\/a> would just be adding another round to the <a href=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2004\/02\/16\/73780.aspx\"> game of walls and ladders<\/a>. All that&#8217;ll happen is that programs, when they install, will place themselves in the <i>Exempt from the normal rules<\/i> list, and you&#8217;re back where you started. <\/p>\n<p> &#8220;Oh no, I&#8217;ll super-protect that registry key so that the only way to add an entry to it requires a human being to respond to a dialog box confirming that the entry is being added.&#8221; <\/p>\n<p> Well, for one thing, that doesn&#8217;t actually stop installers with administrator privilege, since they can just remove the super-protection and update the key anyway. (Administrator privilege is like that.) And even if you somehow manage to super-protect the setting (how? beats me), the next stage is application vendors (or system administrators attempting to deploy the application across their company) asking for a programmatic way to add their program to your super-protected list of exemptions. And then you&#8217;re back to where you were. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>One category of application that people complained about is the application launcher which keys off a hotkey and doesn&#8217;t get the foreground love. Well, except that windows with registered hotkeys do get the foreground love. After you call the RegisterHotKey function to register a hotkey, the window manager will send you a WM_HOTKEY message when [&hellip;]<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[26],"class_list":["post-19013","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-other"],"acf":[],"blog_post_summary":"<p>One category of application that people complained about is the application launcher which keys off a hotkey and doesn&#8217;t get the foreground love. Well, except that windows with registered hotkeys do get the foreground love. After you call the RegisterHotKey function to register a hotkey, the window manager will send you a WM_HOTKEY message when [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/19013","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=19013"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/19013\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=19013"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=19013"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=19013"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}