Command Prompt size and position?

T

Terry Pinnell

For a small project I'm having to work in the command prompt, an
unfamiliar environment for me nowadays. I was surprised to find that
there's no agreement between the size and position shown in its
Properties, versus that shown by other tools. Here's an example using a
regular macro I use written in Macro Express Pro.

https://dl.dropbox.com/u/4019461/CommandPrompt-Sizing-1.jpg

Nor does the Command Prompt window respond correctly to tools which size
and position it. For example, using Sizer to try making it 800x600 results
in 804x611 (and not positioned as per Sizer either).

Anyone have any insight into this stuff please?
 
J

JJ

For a small project I'm having to work in the command prompt, an
unfamiliar environment for me nowadays. I was surprised to find that
there's no agreement between the size and position shown in its
Properties, versus that shown by other tools. Here's an example using a
regular macro I use written in Macro Express Pro.

https://dl.dropbox.com/u/4019461/CommandPrompt-Sizing-1.jpg

Nor does the Command Prompt window respond correctly to tools which size
and position it. For example, using Sizer to try making it 800x600 results
in 804x611 (and not positioned as per Sizer either).

Anyone have any insight into this stuff please?

The size in that "Window Size" section is in characters and can't be larger
than the width of the screeb buffer (also in characters). The actual size of
a character depends on the selected font for that window.

The settings in "Window Position" section are in pixels.

All above apply to console based windows, and not just the Command Prompt
program's window.
 
T

Terry Pinnell

JJ said:
The size in that "Window Size" section is in characters and can't be larger
than the width of the screeb buffer (also in characters). The actual size of
a character depends on the selected font for that window.

The settings in "Window Position" section are in pixels.

All above apply to console based windows, and not just the Command Prompt
program's window.

Thanks JJ.

So it should be theoretically possible to calculate the actual pixel size
of the Command Prompt window if I could somehow find the current
pixels/character value? Know any way to find that please? Is it perhaps a
registry key value?

The reason I'm bothering with this obscure stuff is that I'm writing a
macro to run a command in the Command Prompt window. At one stage I need
to emulate right clicking and entering 'P' to invoke Paste, so that I can
enter clipboard text. (Is there an exclusively keystroke method of doing
that?) So to be 100% sure the right click is in the window, I'd like to
specify its position and size in familiar pixel terms.

In case you're wondering, I'm also considering a batch file approach as an
alternative. If I go that route, can I avoid opening a Command Prompt at
all?
 
P

Paul

Terry said:
Thanks JJ.

So it should be theoretically possible to calculate the actual pixel size
of the Command Prompt window if I could somehow find the current
pixels/character value? Know any way to find that please? Is it perhaps a
registry key value?

The reason I'm bothering with this obscure stuff is that I'm writing a
macro to run a command in the Command Prompt window. At one stage I need
to emulate right clicking and entering 'P' to invoke Paste, so that I can
enter clipboard text. (Is there an exclusively keystroke method of doing
that?) So to be 100% sure the right click is in the window, I'd like to
specify its position and size in familiar pixel terms.

In case you're wondering, I'm also considering a batch file approach as an
alternative. If I go that route, can I avoid opening a Command Prompt at
all?

The menu bar of the Command Prompt window has "Properties".

Right-click the bar, select Properties, then Font tab. The
size of character set is defined there. Mine is set to 10x20
"raster font". That might be a fixed width font.

Maybe that setting is stored in the Registry ?

Paul
 
M

Michael Asherman

Hi Terry,

I'm not sure if it's quite what you're after, but you might find Montage
helpful:

http://ideaxchg.com/montage/

You can use it to launch a command window to a consistent size and position,
and it can show you the exact pixel size and coordinates of the window.
There's a lot more it can do, if you find that sort of thing useful.

Mike
 
Z

Zaphod Beeblebrox

On Fri, 22 Mar 2013 14:50:02 +0000, "Terry Pinnell"
The reason I'm bothering with this obscure stuff is that I'm writing a
macro to run a command in the Command Prompt window. At one stage I need
to emulate right clicking and entering 'P' to invoke Paste, so that I can
enter clipboard text. (Is there an exclusively keystroke method of doing
that?) So to be 100% sure the right click is in the window, I'd like to
specify its position and size in familiar pixel terms.

ALT+Spacebar, E, P will paste the clipboard into a command prompt. I
can't really help with the size issues though.
 
J

J. P. Gilliver (John)

In message <[email protected]>, Terry Pinnell
So it should be theoretically possible to calculate the actual pixel size
of the Command Prompt window if I could somehow find the current
pixels/character value? Know any way to find that please? Is it perhaps a
registry key value?

From its properties menu, the Font tab will show the current font it is
using - 8 by 12 is what mine defaults to and looks most like the "real
thing" IMO. It also defaults to 80 characters wide by 25 lines high, so
you can work out the character-mode window size from those; that doesn't
include the window border furniture of course.
The reason I'm bothering with this obscure stuff is that I'm writing a
macro to run a command in the Command Prompt window. At one stage I need
to emulate right clicking and entering 'P' to invoke Paste, so that I can
enter clipboard text. (Is there an exclusively keystroke method of doing

The old Alt-space menu is your friend (in this case, Alt-space, E, P).
[]
 
J

JJ

The reason I'm bothering with this obscure stuff is that I'm writing a
macro to run a command in the Command Prompt window. At one stage I need
to emulate right clicking and entering 'P' to invoke Paste, so that I can
enter clipboard text. (Is there an exclusively keystroke method of doing
that?) So to be 100% sure the right click is in the window, I'd like to
specify its position and size in familiar pixel terms.

In case you're wondering, I'm also considering a batch file approach as an
alternative. If I go that route, can I avoid opening a Command Prompt at
all?

In that case... Basically, you'll need to do these:

1. Make sure that the console window is not minimized

2. Get the window position.

3. Add the X and Y coordinate by 50. Or experiment it until the cordinate is
not on the border nor title area. i.e.: the client area.

4. Issue a mouse right click using the modified coordinate to open the popup
menu.

5. Issue the "P" key press to choose the "Paste" menu item (if it's
enabled).

I don't know much about Macro Express, but after taking a quick peek of its
functions, it doesn't seem to be capable of retrieving a window size for the
step #2. If it's not, you may want to use AutoIt instead.

A more simpler method is using key presses entirely. Replacing step #2 to #4
with these:

2. Activate the window.

3. Issue the Applications/Menu key press (usually at the right side of right
Windows key). Technically, this is named VK_APPS.

4. Skip to step #5.
 
T

Terry Pinnell

J. P. Gilliver (John) said:
In message <[email protected]>, Terry Pinnell
So it should be theoretically possible to calculate the actual pixel size
of the Command Prompt window if I could somehow find the current
pixels/character value? Know any way to find that please? Is it perhaps a
registry key value?

From its properties menu, the Font tab will show the current font it is
using - 8 by 12 is what mine defaults to and looks most like the "real
thing" IMO. It also defaults to 80 characters wide by 25 lines high, so
you can work out the character-mode window size from those; that doesn't
include the window border furniture of course.
The reason I'm bothering with this obscure stuff is that I'm writing a
macro to run a command in the Command Prompt window. At one stage I need
to emulate right clicking and entering 'P' to invoke Paste, so that I can
enter clipboard text. (Is there an exclusively keystroke method of doing

The old Alt-space menu is your friend (in this case, Alt-space, E, P).
[]

Zaphod, John: Thanks both, completely forgot about Alt+Space! Avoids the
need for sizing/positioning entirely.
 
T

Terry Pinnell

JJ said:
In that case... Basically, you'll need to do these:

1. Make sure that the console window is not minimized

2. Get the window position.

3. Add the X and Y coordinate by 50. Or experiment it until the cordinate is
not on the border nor title area. i.e.: the client area.

4. Issue a mouse right click using the modified coordinate to open the popup
menu.

5. Issue the "P" key press to choose the "Paste" menu item (if it's
enabled).

I don't know much about Macro Express, but after taking a quick peek of its
functions, it doesn't seem to be capable of retrieving a window size for the
step #2. If it's not, you may want to use AutoIt instead.

A more simpler method is using key presses entirely. Replacing step #2 to #4
with these:

2. Activate the window.

3. Issue the Applications/Menu key press (usually at the right side of right
Windows key). Technically, this is named VK_APPS.

4. Skip to step #5.

Thanks JJ. As you say, the keystroke method avoids the issue entirely.

"Macro Express...doesn't seem to be capable of retrieving a window
size..."

Yes, it can do that. The window titled 'Window size' in my screenshot
earlier was displayed by a simple macro that included these commands:

Variable Set Integer X: Set to the Current Window's Left
Variable Set Integer Y: Set to the Current Window's Top
Variable Set Integer %WindowWidth%: Set to the Current Window's Width
Variable Set Integer %WindowHeight%: Set to the Current Window's Height
Text Box Display: Window size

The last just displayed the 4 variables.
 
T

Terry Pinnell

Paul said:
The menu bar of the Command Prompt window has "Properties".

Right-click the bar, select Properties, then Font tab. The
size of character set is defined there. Mine is set to 10x20
"raster font". That might be a fixed width font.

Maybe that setting is stored in the Registry ?

Paul

Thanks Paul, I hadn't thought to examine that Font tab. Further study
shows that the conversion rules are as follows:

1. Under Properties > Font note the font size, e.g. 8 x 12 = Fw x Fh
2. Under Properties > Layout note the Windows Size, e.g. 100 x 75 = W x H
3. Tests show that the fixed extra width and height values are 28 and 47

So the pixel size is ((Fw x W) + 28) x ((Fh x H) + 47)

Examples, all with Font size 8 x 12:

Layout > Window size Calculation Size in pixels
-------------------- -------------------------- --------------
120 x 60 120x8+28=988, 60x12+47=767 988 x 767

100 x 75 100x8+28=828, 75X12+47=947 828 x 947


All that's happily redundant now that I can achieve what I want with
keystrokes and no mouse clicks, but my curiosity is satisfied!
 
J

J. P. Gilliver (John)

In message <[email protected]>, Terry Pinnell
1. Under Properties > Font note the font size, e.g. 8 x 12 = Fw x Fh
2. Under Properties > Layout note the Windows Size, e.g. 100 x 75 = W x H
3. Tests show that the fixed extra width and height values are 28 and 47
[]
I think 3. will vary depending on your theme (or whatever it's called)
settings, for window border size, window title font size, and the like.
(I have a feeling those can only be tweaked in Classic theme - in which
case 28 and 47 may apply for all the others - BICBW about that.)
--
J. P. Gilliver. UMRA: 1960/<1985 MB++G()AL-IS-Ch++(p)Ar@T+H+Sh0!:`)DNAf

.... back in the olden days ... Britain was entirely made of wood and lit by
one enormous candle, tended by the Queen
- Steven Moffat, Radio Times, 24-30 July 2010
 

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

Top