This can be possible using a 3rd party Window manipulation program. David
Candy posted this wonderful tip, along with a set of Window manipulation
tools he created. Works flawlessly. You can get the tools from hist
newsgroup post here:
news://msnews.microsoft.com/
[email protected]
You need to use a newsreader to view/download the attachment.
- - - -
These 7 commands allow batch files to manipulate windows.
Command Description
MoveWindow MoveWindow nnxnn window title
Changes the position of a window. 0,0 is top left.
Note the x in nnxnn must be lower case.
E.G.
MoveWindow 20x20 Untitled - Notepad
SizeWindow SizeWindow nnxnn window title
Changes the size of a window.
E.G.
SizeWindow 1024x768 Untitled - Notepad
Topmost Topmost window title
Sets a window to be Always On Top
NonTopMost NonTopMost window title
Make a Always On Top window normal.
HideWindow HideWindow window title
Hides a window.
ShowWindow ShowWindow window title
Shows a hidden window.
Case of window title is important. It must match exactly. If you recieve an
error 1400 you mistyped the Window Title. Quotes are not used.
Set objshell = CreateObject("Shell.Application")
objshell.TileHorizontally
Choose one from below
CascadeWindows Cascadess all of the windows on the desktop.
EjectPC Ejects the computer from its docking station.
FileRun Displays the Run dialog to the user.
FindComputer Displays the Find: Computer dialog box.
FindFiles Displays the Find: All Files dialog box.
Help Displays Microsoft® Windows® Help.
MinimizeAll Minimizes all of the windows on the desktop.
RefreshMenu Refreshes the contents of the Start Menu.
SetTime Displays the Date/Time Properties dialog box.
ShutdownWindows Displays the Shut Down Windows dialog box.
Suspend Suspends the computer.
TileHorizontally Tiles all of the windows on the desktop horizontally.
TileVertically Tiles all of the windows on the desktop vertically.
TrayProperties Displays the Taskbar Properties dialog box.
UndoMinimize ALL Restores all of the windows on the desktop to the
same state they were in before the last MinimizeAll command.
WSHShell.Run("c:\command.exe", 0, True)
=================================
With Param 1 being the command, Param 2 the window style (see below), and
Param 3 a flag to indicate if to wait at this command untill the program
started has exited - True it does and false it doesn't. Look in the
Shortcut's Properties of the Start Menu shortcuts to see some command lines.
You can also put document names in and have the Open command run on them.
Window Style
------------------
0 Hides the window and activates another window.
1 Activates and displays a window. If the window is minimized or maximized,
the system restores it to its original size and position. An application
should specify this flag when displaying the window for the first time.
2 Activates the window and displays it as a minimized window.
3 Activates the window and displays it as a maximized window.
4 Displays a window in its most recent size and position. The active window
remains active.
5 Activates the window and displays it in its current size and position.
6 Minimizes the specified window and activates the next top-level window in
the Z order.
7 Displays the window as a minimized window. The active window remains
active.
8 Displays the window in its current state. The active window remains
active.
9 Activates and displays the window. If the window is minimized or
maximized, the system restores it to its original size and position. An
application should specify this flag when restoring a minimized window.
10 Sets the show-state based on the state of the program that started the
application.
WSHShell.AppActivate "window title"
==============================
In determining which application to activate, the specified title is
compared to the title string of each running application. If no exact match
exists, any application whose title string begins with title is activated.
If an application still cannot be found, any application whose title string
ends with title is activated. If more than one instance of the application
named by title exists, one instance is arbitrarily activated.
Use this to switch between windows and to make sure your sendkeys go to the
right window.
WScript.Sleep 50
==============
Sends your program to sleep for the milliseconds specified. Sometimes you
may need to do this to give the recieving program the ability to process
your commands (as you are blocking it from running by sending it keystrokes)
or more frequently to give a process enough time to complete.
So put movewindows into c:\ (say) then create a file
set WshShell = WScript.CreateObject("WScript.Shell")
Set objshell = CreateObject("Shell.Application")
objshell.FileRun
WSHShell.AppActivate "Run"
WSHShell.Run "c:\MoveWindow 300x400 Run", 1, True
- - - -
And a post from me:
Third-party alternative.
SlickRun download and review - commandline launcher from SnapFiles:
http://www.snapfiles.com/get/slickrun.html
--
Regards,
Ramesh Srinivasan, Microsoft MVP [Windows XP Shell/User]
Windows® XP Troubleshooting
http://www.winhelponline.com
Thanks for the reply, but this just adds another step to the process,
which is what I am trying to get rid of (moving the dialog from behind
my taskbar or collapsing the taskbar).
I would like to have the run dialog open in the center of the screen in
the first place.
Thanks again for your input, it will be helpfull in other situations.