Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Console window

Status
Not open for further replies.

vquick

IS-IT--Management
Jul 13, 2008
14
US
How can i stop console windows from popping up when i call a command in backticks? Im using nconvert to manupulate images and it pops up a console window. Ive tried using Win32::Console with the free option and cannot get it to work.
here is my code with win32::console:

Code:
my $cmd = "nconvert.exe -quiet -rotate $rotation -brigtness $brightness -contrast $contrast -o $out_file $in_file";

my $results = Win32::GUI->new($cmd);
$results->Hide();

This code is inside a Tk gui and when a button is pressed it changes either rotation,brightness, or contrast. All are increased by 10 when pressed.

if there is a better way to do this im up for suggestions. also perlmagick is not a option for me.

thanks

 
Prior to sending the command, try this:
Code:
$cmd = "start /B " . $cmd

From a Windows command shell, try "help start" for more info.
 
I tried "start /B" and still got the cmd prompt.

Code:
my $cmd = "nconvert.exe -quiet -rotate $rotation -brigtness $brightness -contrast $contrast -o $out_file $in_file";

$cmd = "start /B " . $cmd

 
Sorry about the mis-lead. Don't have Win32::GUI (or Win32::Shell) on my system. Was shooting from the hip on that one.

Another possibility may be to create an OS interface during startup and hide it but never close it.

Not sure if this applies to how you're using your application, however I did find the following snippet while surfing
perl-win32-gui.sourceforge.net said:
Win32::GUI::Hide($First); # correct
$First->Hide(); # wrong
 
this is was i tried:

Code:
my $cmd = "nconvert.exe -quiet -rotate $rotation -brigtness $brightness -contrast $contrast -o $out_file $in_file";

Win32::GUI::Hide($cmd);
I got a usage Error. so i guess im not reall sure how to use this module.

by the way thanks for the replies
 
Didn't include enough of that snippet. In your case, you would have wanted to try
Code:
my $results = Win32::GUI->new($cmd);
Win32::GUI::Hide($results);
Does $cmd generate some simple output? If so, there is always
Code:
open(FH, "$cmd |"); @results = <FH> ; close FH;
Bullet proofing left up to the reader

If $cmd doesn't truly exit, you'll need to be a little more creative than what I monkeyed out above. Again as assuming that you're just needing to get a command out to the OS.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top