Post Reply
Doug Coulter 2014-07-17 09:50
I am looking to launch 4 instances of Excel and open specific workbooks for each instance on startup using UltraMon.
To start simple, I started with the following script to open Notepad on Monitor 2:
Starts Notepad maximized on monitor 2.
Const SHOWSTATE_HIDDEN = 0 Const SHOWSTATE_MINIMIZED = 1 Const SHOWSTATE_NORMAL = 2 Const SHOWSTATE_MAXIMIZED = 3 Const SHOWSTATE_MAXIMIZED_DESKTOP = 4
Set util = CreateObject("UltraMon.Utility") If util.Run("%WINDIR%\notepad.exe") = True Then Set wnd = CreateObject("UltraMon.Window") If wnd.GetAppMainWindow(util.ProcessID, 0) = True Then wnd.Monitor = 2 wnd.ShowState = SHOWSTATE_MAXIMIZED wnd.ApplyChanges 0 End If End If
This works well. But I am not sure how to extend it to launch another program and position. I tried adding the following lines to the script, but an error is thrown at the util.Run line.
If util.Run("%WINDIR%\calc.exe") = True Then Set wnd = CreateObject("UltraMon.Window") If wnd.GetAppMainWindow(util.ProcessID, 0) = True Then wnd.Monitor = 1 wnd.ShowState = SHOWSTATE_MAXIMIZED wnd.ApplyChanges 0 End If End If
Any suggestions would be greatly appreciated. Thanks!
|
Christian Studer 2014-07-17 13:50
The folder is wrong for calc.exe, it's in %WINDIR%\System32, changing that should fix the problem.
Apart from that everything looks fine, though you wouldn't need to create a new Window object, you could also reuse the existing one for the second application.
Christian Studer - www.realtimesoft.com
|
Doug Coulter 2014-08-09 17:08
Thanks for the response Christian.
Per your recommendation, I modified the path of calc.exe. This time, Notepad starts maximized on Monitor 2, and calc.exe launches on Monitor 1, but not maximized. Then I realized that calc.exe cannot be maximized... so I changed it to mspaint.exe. But the same behavior results. It opens on Monitor 1, but not maximized.
|
Doug Coulter 2014-08-10 06:23
I was able to get this to work by adding in some timing delays to allow the applications to start before trying to access their Window Handles. Thanks again for the assistance.
|
Post Reply
|