Matt M
Matt M

Reputation: 48

Windows: Open program in specific screen location

At work, I have a set of batch files and scripts which I use to automate all the programs I need to open in the morning (and others to close them all down at night) in order to save time and effort. The problem is, the windows all open in whatever location they so choose, since most of the information is cleared out overnight on the Virtual Desktop.

I have seen people talking of desktop managers and additional programs that make such tasks easier, but due to the restrictions at play, I do not have the ability to install programs like that. I also do not have access to edit registry files, and I can never be sure if the registry files will stay the same or be wiped and reimaged at night. So re-opening at the stored previous location seems to be out. This means that AutoHotKey , cmdow , and most .exe program options are out of the running.

Essentially what I am looking for is a way to reposition open windows, or open windows in a specific position, using either batch files or vbs. Preferably with a location relative to the screen rather than other windows, as I use multiple monitors.

I'm open to using powershell or potentially other options, but those would likely fall outside my experience. It seems like what I'm asking is either nonexistent or impossible, but I'm hoping maybe someone has an idea. I don't mind complicated code, but I have no idea where to begin on this one guys, any suggestions?

Upvotes: 2

Views: 21114

Answers (2)

Tim
Tim

Reputation: 2892

Batch files can't do this. A VBScript can sort of do this using Windows Script Host Object Model.

Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run(strCommand, [intWindowStyle: See below], [bWaitOnReturn: TRUE/FALSE])
Set WshShell = Nothing

intWindowStyle values:

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.

Not sure about PowerShell. :/

Upvotes: 0

jboo
jboo

Reputation: 374

It look like someone as already answer that kind of question here :

Other post on set many programs window size and position

You can also use C# and map powershell on it using cmdlet in powershell and c# as backend. Here is an exemple in c# and just google how to make cmdlet in powershell.

Example in c#

Upvotes: 1

Related Questions