in reply to Drawing an outline around a Win32 window
This is a long way shy of perfect, but it might help.
#! perl -slw use strict; use Win32::API; use Win32::GuiTest qw[:ALL]; use Win32::GUI; Win32::API->Import( 'user32', 'BOOL InvalidateRect( HWND hWnd, VOID, BOOL bErase )' ) or die $^E; my $hdc = new Win32::GUI::DC("DISPLAY") or die $^E; my $pen = new Win32::GUI::Pen( -style => 0, -width => 1, -color => [ 2 +55, 0, 0 ] ); $hdc->SelectObject( $pen ); $hdc->BkMode( 1 ); my $oldHwnd; while( my( $x, $y ) = GetCursorPos() ) { last unless $x or $y; my $hwnd = WindowFromPoint( $x, $y ); Win32::Sleep 10 and next if $hwnd == $oldHwnd; InvalidateRect( $oldHwnd, 0, 1 ); SendMessage( $oldHwnd, 0x0128, 0, 0 ) if $oldHwnd; my( $l, $t, $r, $b ) = GetWindowRect( $hwnd ); print "$hwnd: $hdc ($x, $y) : ( $l, $t, $r, $b )"; $hdc->MoveTo( $l, $t ); $hdc->LineTo( $r, $t ); $hdc->LineTo( $r, $b ); $hdc->LineTo( $l, $b ); $hdc->LineTo( $l, $t ); $oldHwnd = $hwnd; }
|
|---|