Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > DOS-Box script is running in set always on top

Reply
Thread Tools

DOS-Box script is running in set always on top

 
 
Daniel Kelber
Guest
Posts: n/a
 
      11-21-2006
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?

 
Reply With Quote
 
 
 
 
John Bokma
Guest
Posts: n/a
 
      11-21-2006
"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/
 
Reply With Quote
 
 
 
 
Daniel Kelber
Guest
Posts: n/a
 
      11-21-2006
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...

 
Reply With Quote
 
Daniel Kelber
Guest
Posts: n/a
 
      11-21-2006
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

 
Reply With Quote
 
John Bokma
Guest
Posts: n/a
 
      11-22-2006
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/
 
Reply With Quote
 
John Bokma
Guest
Posts: n/a
 
      11-22-2006
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/
 
Reply With Quote
 
Robert May
Guest
Posts: n/a
 
      11-22-2006
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.


 
Reply With Quote
 
Daniel Kelber
Guest
Posts: n/a
 
      11-23-2006
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Set the window always on top zaffran_ad@hotmail.com Perl Misc 1 09-18-2006 02:59 PM
sys.argv[0] doesn't always contain the full path of running script. gmax2006 Python 7 08-31-2006 09:12 PM
valign=top doesn't always work =?Utf-8?B?QXJuZQ==?= ASP .Net 2 12-06-2004 10:21 PM
Trying to create a CSS box that is always is always the width of an image placed inside it (and no wider) Deryck HTML 4 06-22-2004 08:25 PM
how to fix it:SelectBox always on top of dropdown menu item. Matthew ASP .Net 3 08-06-2003 05:23 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57