Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How Can I Specify what Screen to Open an Application on?

Posted on 2012-09-17
10
Medium Priority
?
3,610 Views
Last Modified: 2016-11-14
I am running Windows 7 on a system with 4 monitors.  On login I currently have a batch file running using the Start command to fire up the application multiple times and open different files.  That part is working without issues but the problem I have is all the different sessions of the application open on the same screen/monitor.  I then have to move the files around to the screen I want them on.  I am wondering if there is a way by script (batch file, VBscript,etc) to open the application, specify what file to open, and finally which of the 4 monitors to open it on.  Below is a basic sample of the Start command I am using in my Batch file.

start "Screen1" /MAX /d "C:\Program Files\My Program" MyProgram.exe "\\mydomain\c$\MyFile"
0
Comment
Question by:rkneal
  • 5
  • 4
10 Comments
 
LVL 43

Expert Comment

by:Steve Knight
ID: 38410358
I don't know off hand.... and only got one screen at the mo. to check but I believe a shortcut that remembers where it was launched last time will show on the same monitor as the system sees it as one big screen X x Y pixels.

So if you create four shorcuts to your apps, or a batch file, or your one batch file with a parameter etc. that launch one screen each.  Open the command window, right click in the corner and the properties of that batch file and in the Layout tab turn off the "let the system position the window for me" tickbox.  The adjust the position of the window to where you want it and close it (you could do this on the shortcut instead without it open).

If this DOES work for you too then you should be able to launch the shortcut, which will be a .LNK file of whatever you name it, e.g.

START "System 1" "c:\myapp\screen1.lnk"
or
START "System 1" "%userprofile%\desktop\screen1.lnk"
etc.

hth

Steve
0
 

Author Comment

by:rkneal
ID: 38411024
Thanks for your reply.  I gave what you suggested a shot but it doesnt work for me.  Changing the paramaters on the Layout tab only seems to change where the command window is opened when the batch file is executed.  I also couldnt see any way to edit the Layout for a .LNK shortcut file.  It just keep defaulting to the last screen that i had the application loaded on.  Since I am trying to launch the same application 4 times, just with 4 different files, it opens on what Windows identified as the last screen it was open.

Any other ideas? Thanks.
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 38411096
Ahh Ok, sorry I thought these were command window applications, understood.

I will try when I have a dual monitor hooked later as I have a few ideas of what may work.

Aside from that I believe it is down to the app where it places it's window when it starts, i.e. it could choose to store its location, or not...

What sort of files are these -- if the application is programmable, i.e. VBA in word, excel etc. then it might be do-able by opening them from that.

Steve
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:rkneal
ID: 38411559
The program is called ProcessBook from OSISoft.  It is a graphics viewing tools for Process Control.  You probably won't have access to download it since it is licensed software but I would think if we could get this to work in another application then it should work in my application.i was lookign at programs liek UltraMon and DisplayFusion but I would rather not have to buy and depend on a third party software if I can do what i want with a simple script.
0
 
LVL 43

Accepted Solution

by:
Steve Knight earned 750 total points
ID: 38411729
Well there are API ways but I don't know of a commandline tool to do it.  Other option is something like AutoIt.  That is free and great at such things and use it for various production line processes to read colours from the screen and the like.  Have been using it for MANY years though it has been through a few versions of the language.

WinMove("Mail","",100,100,500,400)

will move the window titled "Mail" at the start of it to position 100,100 on the main monitor and make it 500 x 400 pixels.  You install auto-it, write this into their editor, or just notepad as whatever.au3, double click and run, or right click and compile into an exe.

You don't have to have autoit on this machine if you compile it elsewhere.

I have only used it with monitors to the right of the main one but afaik it is fairly logical with x being <0 for monitors to the left of the start button and x > 0 for those to the right.

You can soon have it start the apps too:

Run("C:\Program Files\My Program\MyProgram.exe \\mydomain\c$\MyFile")
WinMove("MyFile","",-1000,100,500,400)

Run("C:\Program Files\My Program\MyProgram.exe \\mydomain\c$\MyFile2")
WinMove("MyFile2","",100,100,500,400)

Is that do-able?  It can do so much more but useful for simple scripts like this too.

Steve
0
 

Author Comment

by:rkneal
ID: 38414575
Ok well I think I found where app is storing its location.  There is an INI that contains the following section with the location info.

[Startup]
WindowPos=2,3,-1,-1,-1,-1,23,166,983,884
Footer=0
GridSize=12
ConnectorsAvoidConnectors=0
EnableConnectorAttachments=0

The WindowPos is what i need to modify.  Do you you know if there is a way in a batch file to parse the .INI file and when it sees the line with WindowPos it will replace it with a different line?
0
 
LVL 43

Assisted Solution

by:Steve Knight
Steve Knight earned 750 total points
ID: 38414727
Certainly.  Is there much else in this file then?

Easiest way well be to keep multiple files if they are basically static, i.e something like:

copy /y screen1.ini yourfile.ini
start "Screen1" "C:\yourapp....."

copy /y screen2.ini yourfile.ini
etc.

Or we can read the file a line at a time and replace that line... or use util to do that.

Another easier way is to arrange it so that the [Startup] Section is at the bottom of the INI file, then:

copy /y yourini.ini yourini.old
find /v "WindowPos=" < yourini.old > yourini.ini
echo WindowPos=2,3,-1,-1,-1,-1,23,166,983,884 >>yourini.ini

That takes a copy of the INI file to .OLD, uses find to make a file called yourini.ini excluding the WindowPos line
then adds the line to the end of the file and removes the temp file

It may also be worth checking to see if there is a commandline option to point it at a different INI file, some apps that use ini do.

Steve
0
 

Author Closing Comment

by:rkneal
ID: 38427076
Solution was mostly what i needed and got me thinking about how to come to my final solution.
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 38427116
Sorry I couldn't come with anything more specific.  Did you get this working by editing those INI files in the end then?

Steve
0
 

Expert Comment

by:Temp Name
ID: 41886899
Could you post your final solution you are talking about?

Thanks
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question