DOS-Box script is running in set always on top

Discussion in 'Perl Misc' started by Daniel Kelber, Nov 21, 2006.

  1. I want a perl script to set the DOS-Box it is running in to be "always
    on top".
    Maybe I can use SetWindowPos from user32.dll but therefor I need the
    window handle of the DOS-Box. How can I get out this handle?
    Is there any easy way to get the window on top?
     
    Daniel Kelber, Nov 21, 2006
    #1
    1. Advertising

  2. Daniel Kelber

    John Bokma Guest

    "Daniel Kelber" <> wrote:

    > I want a perl script to set the DOS-Box it is running in to be "always
    > on top".
    > Maybe I can use SetWindowPos from user32.dll but therefor I need the
    > window handle of the DOS-Box. How can I get out this handle?
    > Is there any easy way to get the window on top?


    If you want to keep an eye on things, why not open your own window on top
    with Tk (I am quite sure this is possible)?

    --
    John Experienced Perl programmer: http://castleamber.com/

    Perl help, tutorials, and examples: http://johnbokma.com/perl/
     
    John Bokma, Nov 21, 2006
    #2
    1. Advertising

  3. John Bokma schrieb:

    > If you want to keep an eye on things, why not open your own window on top
    > with Tk (I am quite sure this is possible)?
    >
    > --
    > John


    Hi John,
    the aim is to drag a file from the windows explorer and drop it in the
    DOS-Box where the script is waiting with

    <STDIN>;

    When I drag the file from windows explorer the DOS box gets in
    background so dropping is more complicated...
     
    Daniel Kelber, Nov 21, 2006
    #3
  4. Hi Len,

    l v schrieb:
    > Is this option available in a native windows DOS box?


    Yes, this works: dropping a file from win explorer into a DOS box
    writes the path and filename to STDIN (tested under WinXP).

    > If you drag from windows explorer and hover over the dos box in the
    > taskbar, the dos box will open on top. You then drop on the now opened
    > dos box.


    It would be better an faster if hovering over the taskbar is not
    necessary.... :)

    Daniel
     
    Daniel Kelber, Nov 21, 2006
    #4
  5. Daniel Kelber

    John Bokma Guest

    l v <> wrote:

    > Sure it would. But then companies like Actual Tools couldn't sell their
    > product. :)


    There is a focus follows mouse power toy from Microsoft, for free, which
    probably does the same. I never understood why the window with focus has
    to pop to the front anyway.

    --
    John Experienced Perl programmer: http://castleamber.com/

    Perl help, tutorials, and examples: http://johnbokma.com/perl/
     
    John Bokma, Nov 22, 2006
    #5
  6. Daniel Kelber

    John Bokma Guest

    l v <> wrote:

    > John Bokma wrote:
    >> l v <> wrote:
    >>
    >>> Sure it would. But then companies like Actual Tools couldn't sell
    >>> their product. :)

    >>
    >> There is a focus follows mouse power toy from Microsoft, for free,
    >> which probably does the same. I never understood why the window with
    >> focus has to pop to the front anyway.
    >>

    >
    > I did not read


    It was a suggestion.

    > that the OP was looking for the X windows feel with the
    > focus follows mouse option within TweakUI. He can certainly drop
    > something from windows explorer right on the dos box in the
    > background, no need to raise it to the top


    If only the window chrome is visible, I get a "forbidden" sign. AFAIK,
    focus follows mouse will raise the window even if above window chrome.

    --
    John Experienced Perl programmer: http://castleamber.com/

    Perl help, tutorials, and examples: http://johnbokma.com/perl/
     
    John Bokma, Nov 22, 2006
    #6
  7. Daniel Kelber

    Robert May Guest

    Daniel Kelber wrote:
    > I want a perl script to set the DOS-Box it is running in to be "always
    > on top".
    > Maybe I can use SetWindowPos from user32.dll but therefor I need the
    > window handle of the DOS-Box. How can I get out this handle?


    On Win2000 and above there is an SPI call GetConsoleWindow() that gets
    the handle. From MSDN:

    The GetConsoleWindow function retrieves the window handle used by the
    console associated with the calling process.

    HWND GetConsoleWindow(void);

    Regards,
    Rob.
     
    Robert May, Nov 22, 2006
    #7
  8. Robert May schrieb:

    > The GetConsoleWindow function retrieves the window handle used by the
    > console associated with the calling process.
    >
    > HWND GetConsoleWindow(void);


    Hi Rob,
    this works very well! Thanks.

    Here the resulting code:

    #!/usr/bin/perl -w

    use strict;
    use Win32::API;

    my %wFlag = ( HWND_TOP => 0,
    HWND_BOTTOM => 1,
    HWND_TOPMOST => -1,
    HWND_NOTOPMOST => -2,
    SWP_NOSIZE => 1,
    SWP_NOMOVE => 2,
    SWP_NOZORDER => 4,
    SWP_NOREDRAW => 8,
    SWP_NOACTIVATE => 16,
    SWP_SHOWWINDOW => 64 );


    my $GetConsoleWindow = new Win32::API('kernel32', 'GetConsoleWindow',
    [],'N');
    my $SetWindowPos = new Win32::API('user32', "SetWindowPos",
    'NNNNNNN', 'N');

    if (defined($GetConsoleWindow) and defined($SetWindowPos)) {
    my $windowHandle = $GetConsoleWindow->Call();

    $SetWindowPos->Call($windowHandle,$wFlag{HWND_TOPMOST},0,0,0,0,
    $wFlag{SWP_NOSIZE} | $wFlag{SWP_NOMOVE} )
    if($windowHandle);
    }

    Daniel
     
    Daniel Kelber, Nov 23, 2006
    #8
    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:
    5
    Views:
    679
    jonck
    Apr 27, 2005
  2. Deryck
    Replies:
    4
    Views:
    551
    derek giroulle
    Jun 22, 2004
  3. Ben Fairbank
    Replies:
    2
    Views:
    5,498
  4. Tony C
    Replies:
    0
    Views:
    481
    Tony C
    Jan 11, 2004
  5. Replies:
    1
    Views:
    119
    Paul Lalli
    Sep 18, 2006
Loading...

Share This Page