how to specify size of window? opening Textpad in bat file

Using the Java SDK with TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
AnilPhilip
Posts: 7
Joined: Thu Dec 23, 2004 8:59 pm
Contact:

how to specify size of window? opening Textpad in bat file

Post by AnilPhilip »

I need to open Textpad from the command line/batch script (actually from Java using Runtime.exec()). For example: "notepad.exe somefile.txt".
However the problem I have is - how do I specify the size of the new window that will be opened?Presently it opens full screen and hides my application. I want it to automatically open smaller size.
How can I do that?
Any help appreciated.
thanks,
Anil Philip :)
Olathe, KS
goodnewsforyou AT yahoo DOT com
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

In my installation TextPad always opens with the window size and position of the last TextPad application instance to be closed. Is this not how it behaves in your installation?

Please don't double-post.
AnilPhilip
Posts: 7
Joined: Thu Dec 23, 2004 8:59 pm
Contact:

Post by AnilPhilip »

ben_josephs wrote:In my installation TextPad always opens with the window size and position of the last TextPad application instance to be closed. Is this not how it behaves in your installation?

Please don't double-post.
Please read my post carefully - it is the Windows OS which controls the window size. And I have not double posted - it is a link to this post.
User avatar
talleyrand
Posts: 624
Joined: Mon Jul 21, 2003 6:56 pm
Location: Kansas City, MO, USA
Contact:

Post by talleyrand »

Welcome to the forums. As a general these forums are fairly low volume and the regulars tend to read all the forums instead of a single one so no need to cross post.

Looking at the options available under the help dialogue for command line, I don't see anything that will allow you to open it with specific window sizing. I'm guessing the sizing of Textpad windows will be dependent on how it was sized when it was closed last. If you find different in the help or find a solution to your quandry, please follow up and let others gain from your insight.
I choose to fight with a sack of angry cats.
AnilPhilip
Posts: 7
Joined: Thu Dec 23, 2004 8:59 pm
Contact:

solution

Post by AnilPhilip »

ben_josephs wrote:In my installation TextPad always opens with the window size and position of the last TextPad application instance to be closed. Is this not how it behaves in your installation?

Please don't double-post.
I am not double posting but simply put a link to it from the General forum because there may be a Windows programmer who knows the solution but may not go to the Java forum.
-----
From Peter who wrote ShellExec at http://www.heimetli.ch
"According to Microsoft, it is possible:
http://msdn.microsoft.com/library/defau ... rocess.asp
(Look at the parameter lpStartupInfo)
Regards
P. Tellenbach"
-----
From Tim Kingbury:
"That's a tricky one. I'm not sure of a good way to do
it from Java. The best answer that I have is that you will need to use JNI to call the underlying Win32 function "CreateProcess()" which gives you
extensive options for controlling the appearance of the new application's
window. Actually doing this from Java would be a bit tricky because you would have to map a number of C structs into the Java environment.
Your easiest bet is to build a very small C application to do the actual
work, and call that from Java using Runtime.exec()."
----
Actually, I am wondering if the best and simplest solution is to follow up on your point - simply have the user open the program eg. textpad and resize the window to a smaller size, and then exit.
Thereafter when my application runs, it will bring up the program (textpad) in the new resized window.

thanks,
Anil
User avatar
talleyrand
Posts: 624
Joined: Mon Jul 21, 2003 6:56 pm
Location: Kansas City, MO, USA
Contact:

Post by talleyrand »

I've never dug around but you might poke around in the registry and see if the coordinates and window sizes are stored there. I'm not sure where TP saves that information.
I choose to fight with a sack of angry cats.
Post Reply