DOS-Box script is running in set always on top

D

Daniel Kelber

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?
 
J

John Bokma

Daniel Kelber said:
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)?
 
D

Daniel Kelber

John said:
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)?

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...
 
D

Daniel Kelber

Hi Len,

l said:
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
 
J

John Bokma

l v said:
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.
 
J

John Bokma

l v said:
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.
 
R

Robert May

Daniel said:
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.
 
D

Daniel Kelber

Robert said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top