Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set The Window Position of an application via command line

I have an application which start in 0x0 position of my desktop. I want to open it in center of my desktop. I do not want to open it and use a move command to move it into center, just want my app to start immediately in center position.

Is there any way to do this via command prompt? Any other way?

like image 901
Inside Man Avatar asked Nov 02 '11 08:11

Inside Man


People also ask

How do I reset Windows location?

This can be done by holding the Shift key and right-clicking the program's taskbar icon. Select Move from the menu that appears, and begin pressing the arrow keys to force the window to move position.

How do I change the size of a window in a batch file?

If you just open the batch file, click on the window, and then click "properties", and then to "layout", and scroll down to "Window Size", you can edit it from there.


2 Answers

You'll need an additional utility such as cmdow.exe to accomplish this. Look specifically at the /mov switch. You can either launch your program from cmdow or run it separately and then invoke cmdow to move/resize it as desired.

like image 118
sorpigal Avatar answered Oct 05 '22 15:10

sorpigal


Have found that AutoHotKey is very good for window positioning tasks.

Here is an example script. Call it notepad.ahk and then run it from the command line or double click on it.

Run, notepad.exe WinWait, ahk_class Notepad WinActivate WinMove A,, 10, 10, A_ScreenWidth-20, A_ScreenHeight-20 

It will start an application (notepad) and then adjust the window size so that it is centered in the window with a 10 pixel border on all sides.

like image 32
FuzzyWuzzy Avatar answered Oct 05 '22 15:10

FuzzyWuzzy