win32::job window attributes

Discussion in 'Perl Misc' started by Cameron, Jul 3, 2004.

  1. Cameron

    Cameron Guest

    Hello All --

    I am trying to launch a windows application either in the background
    or with a minimized window using the following code:

    my $job = Win32::Job->new;

    $job->spawn(q{D:\Link32\Link32.exe}, q{Link32.exe}, {
    stdout => 'output.txt',
    stderr => 'error.txt',
    window_attr => 'hidden'
    });

    The app is spawned successfully, but no matter how I try to redirect
    stdout or set window_attr to hidden or minimized, it launches full screen.

    Any thoughts or suggestions appreciated. I am not married to this module, so
    if anyone has done this successfully in the past using something else, I'll
    give it a try.

    Thnx,

    Cameron
    Cameron, Jul 3, 2004
    #1
    1. Advertising

  2. Hello Cameron,

    Using your syntax, I was able to reproduce your problem. Of course, I don't
    have a D:\Link32\Link32.exe on my computer so I used Notepad.exe. Notepad
    would start but it would not be hidden or minimized. By the same token,
    output.txt and error.txt were not created. I went back to the documentation
    for Win32::Job and used the exact syntax. Here is a little sample that
    worked for me on W2K:

    ==== Beginning script sample =====
    use strict;
    use warnings;
    use Win32::Job;

    my $job = Win32::Job->new();
    my %opts=( window_attr=>'hidden',
    stdout => 'output.txt',
    stderr => 'error.txt');
    $job->spawn(q{c:\winnt\system32\notepad.exe}, q{notepad "d:\temp\temp.txt"},
    \%opts);
    $job->run(10);

    ==== End script sample =====

    As you noticed, the main difference with your script is that I defined the
    hash %opts. I was then able to successfully minimize or hide the window. Of
    course, output.txt and error.txt were also created successfully.

    You might want to give it a try and see if the syntax documented for
    Win32::Job does not fix your problem as well.

    I would be great if you could report your future failure/success. :)
    Additional questions are of course always welcome.

    MrReallyVeryNice
    MrReallyVeryNice, Jul 3, 2004
    #2
    1. Advertising

  3. Cameron

    Cameron Guest

    "MrReallyVeryNice" <> wrote in message news:<>...
    > Hello Cameron,
    >
    > Using your syntax, I was able to reproduce your problem. Of course, I don't
    > have a D:\Link32\Link32.exe on my computer so I used Notepad.exe. Notepad
    > would start but it would not be hidden or minimized. By the same token,
    > output.txt and error.txt were not created. I went back to the documentation
    > for Win32::Job and used the exact syntax. Here is a little sample that
    > worked for me on W2K:
    >
    > ==== Beginning script sample =====
    > use strict;
    > use warnings;
    > use Win32::Job;
    >
    > my $job = Win32::Job->new();
    > my %opts=( window_attr=>'hidden',
    > stdout => 'output.txt',
    > stderr => 'error.txt');
    > $job->spawn(q{c:\winnt\system32\notepad.exe}, q{notepad "d:\temp\temp.txt"},
    > \%opts);
    > $job->run(10);
    >
    > ==== End script sample =====
    >
    > As you noticed, the main difference with your script is that I defined the
    > hash %opts. I was then able to successfully minimize or hide the window. Of
    > course, output.txt and error.txt were also created successfully.
    >
    > You might want to give it a try and see if the syntax documented for
    > Win32::Job does not fix your problem as well.
    >
    > I would be great if you could report your future failure/success. :)
    > Additional questions are of course always welcome.
    >
    > MrReallyVeryNice


    Hey Nice --

    No go ..... I was able to reproduce your results with notepad as well,
    but the application (a bastardized copy of wIntegrate used by car
    dealers to access an old PICK system from Reynolds & Reynolds) still
    refuses to open in a minimised window. Thanks for your input!

    Cameron
    Cameron, Jul 3, 2004
    #3
  4. Cameron

    Petri Guest

    Petri, Jul 3, 2004
    #4
  5. Hello again,

    In addition to trying SendKeys as suggested by Petri, you might also
    validate if your application (Link32.exe) has not been built/compiled with
    the wrong switch. In which case no matter what you try, you will not be able
    to minimize/hide it.

    In the spirit of helping you debugging this problem, and certainly not
    trying to drive you away from Perl, I would suggest that you take a look at:
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/pla
    tform/shell/reference/objects/ishelldispatch2/shellexecute.asp. If you
    create a small VBScript, you will have a second data point. If you are
    successful with a VBScript then you can decide to debug Win32::Job or try to
    find another Perl module.

    Here is a little untested sample program with Link32:
    === Beginning Script ===
    Option Explicit
    fnShellExecuteVB()

    function fnShellExecuteVB()
    dim objShell
    set objShell = CreateObject("Shell.Application")
    objShell.ShellExecute "Link32.exe", "", "D:\Link32", "open", 2
    set objShell = nothing
    end function
    === End Script ===

    As earlier, please report your failures/successes.
    MrReallyVeryNice
    MrReallyVeryNice, Jul 4, 2004
    #5
  6. Cameron

    Cameron Guest

    "MrReallyVeryNice" <> wrote in message news:<>...
    > Hello again,
    >
    > In addition to trying SendKeys as suggested by Petri, you might also
    > validate if your application (Link32.exe) has not been built/compiled with
    > the wrong switch. In which case no matter what you try, you will not be able
    > to minimize/hide it.
    >
    > In the spirit of helping you debugging this problem, and certainly not
    > trying to drive you away from Perl, I would suggest that you take a look at:
    > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/pla
    > tform/shell/reference/objects/ishelldispatch2/shellexecute.asp. If you
    > create a small VBScript, you will have a second data point. If you are
    > successful with a VBScript then you can decide to debug Win32::Job or try to
    > find another Perl module.
    >
    > Here is a little untested sample program with Link32:
    > === Beginning Script ===
    > Option Explicit
    > fnShellExecuteVB()
    >
    > function fnShellExecuteVB()
    > dim objShell
    > set objShell = CreateObject("Shell.Application")
    > objShell.ShellExecute "Link32.exe", "", "D:\Link32", "open", 2
    > set objShell = nothing
    > end function
    > === End Script ===
    >
    > As earlier, please report your failures/successes.
    > MrReallyVeryNice



    Thanks to both of you ..... what I finally decoded to do was to
    execute the
    wIntegrate scripting command "Session Show 3" as soon as the app opens
    which basically accomplishes the same thing. I'm a bit disapointed
    that I couldn't do it with Perl, but I can waste too much time on it.

    Cheers,

    Cameron
    Cameron, Jul 4, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    673
  2. Julien Buratto

    [Job] Symbian C++ job

    Julien Buratto, Feb 3, 2004, in forum: C++
    Replies:
    2
    Views:
    558
    Julien Buratto
    Feb 3, 2004
  3. swordedotcom
    Replies:
    0
    Views:
    328
    swordedotcom
    Apr 23, 2006
  4. swordedotcom
    Replies:
    0
    Views:
    299
    swordedotcom
    Apr 23, 2006
  5. swordedotcom
    Replies:
    0
    Views:
    360
    swordedotcom
    Apr 23, 2006
Loading...

Share This Page