This function will allow you to make a window unfocusable. An unfocusable window can be interacted with, but not focused. Also, it doesn't appear in the Alt-Tab window list, nor does it appear in the Taskbar.

I use this on my Gaim Buddy List so that it doesn't get in the way when I'm Alt-Tabbing around.

use Win32::API; use Win32::GuiTest 'FindWindowLike'; use constant SW_SHOW => 0x5; use constant SW_HIDE => 0x0; use constant GWL_EXSTYLE => -20; use constant WS_EX_NOACTIVATE => 0x8000000; sub unfocusable_window { my $win = shift; my ($hwnd) = FindWindowLike(undef, $win) or die "Couldn't find window $win\n"; my $style = GetWindowLong($hwnd, GWL_EXSTYLE); $style |= WS_EX_NOACTIVATE; ShowWindow($hwnd, SW_HIDE); SetWindowLong($hwnd, GWL_EXSTYLE, $style); ShowWindow($hwnd, SW_SHOW); } sub focusable_window { my $win = shift; my ($hwnd) = FindWindowLike(undef, $win) or die "Couldn't find window $win\n"; my $style = GetWindowLong($hwnd, GWL_EXSTYLE); $style &= ~WS_EX_NOACTIVATE; ShowWindow($hwnd, SW_HIDE); SetWindowLong($hwnd, GWL_EXSTYLE, $style); ShowWindow($hwnd, SW_SHOW); }

In reply to Unfocusable windows on Win32 by bbfu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.