RE: Prevent console window
Is this approach also an option if I need the result that the child process generates in the main program? And if so, how do I obtain the result? I can see it on STDOUT. Thanks for your help! Nele -Original Message- From: bob davis [mailto:robert.da...@infor.com] Sent: Mittwoch, 13. Januar 2010 16:05 To: Nele Kosog Cc: par@perl.org Subject: Re: Prevent console window It gets set in this call so you can use it for things like this: $ProcessObj-Suspend(); $ProcessObj-Resume(); $ProcessObj-Wait(INFINITE); Nele Kosog wrote: Bob, where does the $ProcessObj come from? The documentation on CPAN doesn't explain it and I don't know what object is expected. Thank you! Regards, Nele Do you use 'system' to start the command line? How about something like this instead Win32::Process::Create($ProcessObj, $ExeName, $Args, 0, NORMAL_PRIORITY_CLASS, .) -- Bob Bob Davis | Infor |Office: 603.334.5060 | robert.da...@infor.com | cell: 603-479-4358 | home: 603-778-0781 | skype: rsdavis9
Re: Prevent console window
Redirect the command to a tmp file and then read it back $ExeName = ls.exe $Args = tmpfile.out Nele Kosog wrote: Is this approach also an option if I need the result that the child process generates in the main program? And if so, how do I obtain the result? I can see it on STDOUT. Thanks for your help! Nele -Original Message- From: bob davis [mailto:robert.da...@infor.com] Sent: Mittwoch, 13. Januar 2010 16:05 To: Nele Kosog Cc: par@perl.org Subject: Re: Prevent console window It gets set in this call so you can use it for things like this: $ProcessObj-Suspend(); $ProcessObj-Resume(); $ProcessObj-Wait(INFINITE); Nele Kosog wrote: Bob, where does the $ProcessObj come from? The documentation on CPAN doesn't explain it and I don't know what object is expected. Thank you! Regards, Nele Do you use 'system' to start the command line? How about something like this instead Win32::Process::Create($ProcessObj, $ExeName, $Args, 0, NORMAL_PRIORITY_CLASS, .) -- Bob Bob Davis | Infor |Office: 603.334.5060 | robert.da...@infor.com | cell: 603-479-4358 | home: 603-778-0781 | skype: rsdavis9
Re: Prevent console window
On 12/1/2010 4:10 μμ, Nele Kosog wrote: Hi, I have compiled an executable using the following command: pp -x --gui -o my_program.exe my_program.pl While --gui blocks the console window for the main application, it does not seem to prevent other console windows from opening. my_program.pl uses two command line tools to calculate something. When I run the pp'ed executable, the my_program.exe opens a new console window for each call to one of the command line tools. Are there means to prevent this? I have searched for this option, but only find the --gui switch description. Thank you for your help! Regards, Nele From activeperl's faq, other variants use some other technique maybe ? BEGIN { my ($DOS) = Win32::GUI::GetPerlWindow(); #hide console window if ( $DOS ) { Win32::GUI::Hide($DOS) unless ($ARGV[0] eq '--keep'); } # hide children windows if ( defined Win32::SetChildShowWindow ){ Win32::SetChildShowWindow(0); } }
Re: Prevent console window
Do you use 'system' to start the command line? How about something like this instead Win32::Process::Create($ProcessObj, $ExeName, $Args, 0, NORMAL_PRIORITY_CLASS, .) Nele Kosog wrote: Hi, I have compiled an executable using the following command: pp -x --gui -o my_program.exe my_program.pl While --gui blocks the console window for the main application, it does not seem to prevent other console windows from opening. my_program.pl uses two command line tools to calculate something. When I run the pp'ed executable, the my_program.exe opens a new console window for each call to one of the command line tools. Are there means to prevent this? I have searched for this option, but only find the --gui switch description. Thank you for your help! Regards, Nele -- Bob Bob Davis | Infor |Office: 603.334.5060 | robert.da...@infor.com | cell: 603-479-4358 | home: 603-778-0781 | skype: rsdavis9
RE: Prevent console window
Do you use 'system' to start the command line? No, I use back ticks my $result = `command`; How about something like this instead Win32::Process::Create($ProcessObj, $ExeName, $Args, 0, NORMAL_PRIORITY_CLASS, .) Thank you, this looks good. I'll try this approach. Regards, Nele
Re: Prevent console window
Nele Kosog wrote: Hi, I have compiled an executable using the following command: pp -x --gui -o my_program.exe my_program.pl While --gui blocks the console window for the main application, it does not seem to prevent other console windows from opening. my_program.pl uses two command line tools to calculate something. When I run the pp'ed executable, the my_program.exe opens a new console window for each call to one of the command line tools. Are there means to prevent this? I have searched for this option, but only find the --gui switch description. Thank you for your help! Regards, Nele This also works and basically calls the same win32 process api and is part of win32::gui wperl -MWin32::GUI -e 'Win32::GUI::ShellExecute(0, open, sleep, 10s, , 0);Win32::GUI::MessageBox(hello world)' If you need the output of the cmdline tool then redirect into a tmp file and then open it as a file. -- Bob Bob Davis | Infor |Office: 603.334.5060 | robert.da...@infor.com | cell: 603-479-4358 | home: 603-778-0781 | skype: rsdavis9
Re: Prevent console window
On 12/1/2010 5:04 μμ, Ben Morrow wrote: From activeperl's faq, other variants use some other technique maybe ? BEGIN { my ($DOS) = Win32::GUI::GetPerlWindow(); #hide console window if ( $DOS ) { Win32::GUI::Hide($DOS) unless ($ARGV[0] eq '--keep'); } This part is unnecessary if you already have a GUI executable (there will be no 'main' console window), which means you don't need to load WIn32::GUI. That's right , but I like to use it for debugging some times :-) see the --keep to keep the console active :-)
Re: Prevent console window
Quoth ange...@unix.gr (Angelos Karageorgiou): On 12/1/2010 4:10 μμ, Nele Kosog wrote: I have compiled an executable using the following command: pp -x --gui -o my_program.exe my_program.pl While --gui blocks the console window for the main application, it does not seem to prevent other console windows from opening. my_program.pl uses two command line tools to calculate something. When I run the pp'ed executable, the my_program.exe opens a new console window for each call to one of the command line tools. Are there means to prevent this? I have searched for this option, but only find the --gui switch description. From activeperl's faq, other variants use some other technique maybe ? BEGIN { my ($DOS) = Win32::GUI::GetPerlWindow(); #hide console window if ( $DOS ) { Win32::GUI::Hide($DOS) unless ($ARGV[0] eq '--keep'); } This part is unnecessary if you already have a GUI executable (there will be no 'main' console window), which means you don't need to load WIn32::GUI. # hide children windows if ( defined Win32::SetChildShowWindow ){ Win32::SetChildShowWindow(0); } } This is what is required. Win32::SetChildShowWindow should be defined on all current Win32 builds of perl. Ben