Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Unfocusable windows on Win32

by bbfu (Curate)
on Jul 03, 2004 at 07:57 UTC ( #371558=snippet: print w/ replies, xml ) Need Help??
Description:

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);
}
Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: snippet [id://371558]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (8)
As of 2016-06-28 09:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (354 votes). Check out past polls.