Page 1 of 1
how to specify size of window? opening Textpad in bat file
Posted: Sun Nov 06, 2005 4:17 am
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
Posted: Sun Nov 06, 2005 9:14 am
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.
Posted: Sun Nov 06, 2005 1:18 pm
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.
Posted: Sun Nov 06, 2005 3:40 pm
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.
solution
Posted: Mon Nov 07, 2005 2:29 pm
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
Posted: Mon Nov 07, 2005 3:38 pm
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.