I don't like cmd.exe's bunching up in my taskbar,
so I set out to write podcmd
So I create Win32::Process (cmd.exe) and
find its window ($cmd) using FindWindowLike.
I create a GUI::Window, and set it as the parent of $cmd.
This magically gets cmd.exe out of the taskbar (yay!).
Now the problem, if I resize the $cmd the GUI::Window paints over it.
How do I resolve this
(stop the GUI::Window from painting over the cmd window)?
How do I get at the constants SW_MAXIMIZE and SW_SHOW
(other than typing the numbers by hand)?
I eventually want to have the cmd.exe window in a TabStrip...
here's what I got so far
#podcmd.pl
use strict;
use warnings;
use Win32::API;
use Win32::GuiTest qw( FindWindowLike PostMessage );
use Win32::GUI;
use Win32::Process;
my $SETPARENT = Win32::API::->new("user32","SetParent","NN","N")
or die "Failed to load SetParent from user32.dll";
Win32::Process::Create(
my $cmdp,
"$ENV{WINDIR}\\system32\\cmd.exe",
'/K title steal_me ',
0,# don't inherit nothing
NORMAL_PRIORITY_CLASS | CREATE_NEW_CONSOLE,
'.'
)
or die "DAMMIT ",Win32::FormatMessage( Win32::GetLastError() ),$/;
sleep 1;
my( $cmd ) = FindWindowLike(undef,'steal_me','ConsoleWindowClass',0,0);
#my( $cmd ) = Win32::GUI::FindWindow('ConsoleWindowClass','steal_me');# don't
work
die " can't find steal_me, killing it ",$cmdp->Kill(0)
unless $cmd and $cmd =~ /\d+/;
# cross fingers (actually works :D)
$cmd = bless( {
'-type' => 0,
'-name' => 'TheDangCMD',
'-handle' => $cmd,
'-accel' => 0
}, 'Win32::GUI::Window' );
warn "classname ", $cmd->GetClassName;
#fonked from Win32-GUI/samples/tabstrip.pl
my $W = GUI::Window::->new(
-title => "Win32::GUI::TabStrip test",
-left => 100,
-top => 100,
# -width => 300,
# -height => 200,
-name => "Window",
);
if(@ARGV){
$W->AddTabStrip(
-name => "Tab",
-left => 0,
-top => 0,
-width => $cmd->ScaleWidth,
-height => $cmd->ScaleHeight,
);
$W->Tab->InsertItem(
-text => "First",
);
$SETPARENT->Call($cmd->{-handle}, $W->Tab->{-handle});
} else {
$SETPARENT->Call($cmd->{-handle}, $W->{-handle});
}
$W->Show(); # SW_MAXIMIZE | SW_SHOW );
$cmd->Show(); #SW_MAXIMIZE | SW_SHOW );
$cmd->Update;
$W->Dialog;
#while (Win32::GUI::DoEvents() != -1) {
# $cmd->Update;
#}
warn "killing $cmdp ", $cmdp->Kill(0);
use Data::Dumper;
local $Data::Dumper::Indent=1;
die Dumper( $W ),$/;
sub Window_Terminate {
return -1;
}
__END__
$VAR1 = bless( {
'-type' => 0,
'-name' => 'Window',
'-handle' => 2164436,
'-accel' => 0
}, 'Win32::GUI::Window' );
__________________________________
Do you Yahoo!?
Yahoo! Mail - More reliable, more storage, less spam
http://mail.yahoo.com