Post Reply

Forums -> UltraMon™ -> Weird/inconsistent script behaviour
Chris King   2004-01-20 02:45
Ok, so far I have only played with some of the sample vbscripts but running the script posted at the bottom of this thread:

Notepad always fires up on monitor number two regardless of which one I try to set it to. It does not maximize except...

If I run the script in debug mode, it still always goes to monitor tow but it does maximize.

I also note that if run notepad from a command prompt, it always fires up on monitor two. Running a couple other GUI EXEs in the system32 folder (Calc, Winver) I note that they always fire up on monitor 1.

Anyway-WinXP, UltraMon v.2.4.21.0

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 '[or 1]
wnd.ShowState = SHOWSTATE_MAXIMIZED
wnd.ApplyChanges 0
End If
End If
Chris King   2004-01-20 08:29
To follow up, I find in general, that things seem to fire up on random monitors regardless how I start them (shortcut/command line/etc.) or whrere I start them from (either monitor).

I have a NT Shell Script which basically calls explorer.exe (Windows Explorer not IE) and opens to different shares depending on the parameter.

One share opens in explorer on monitor 1 and another opens on monitor 2.

Does not seem to be any rhyme or reason here.

Is there some setting I should be checking or any advice from the dev guys?

One thing to add (though it should not matter) is that I am on day five of my eval so it is not yet licensed.

Help me out and it means a several copy purchase :)

Thanks in advance-ck
Christian Studer   2004-01-20 09:33
You'll need to use a non-zero timeout for the GetAppMainWindow call, otherwise Notepad might not have created its window when the function looks for it, and the call will fail (returns False).

10000 milliseconds (= 10 seconds) should work fine:

If wnd.GetAppMainWindow(util.ProcessID, 10000) = True Then

Christian Studer - www.realtimesoft.com
Chris King   2004-01-21 00:31
Actually, 1 second (1000 ms) did it.

Something to update in your help file :)

That explains why it works in debug mode as I am stepping through the code and thus introducing a time lag.

Still curious about why some programs always start on monitor 2 not matter how I start them (shortcut on either desktop/etc.).

Thanks-ck
Forums -> UltraMon™ -> Weird/inconsistent script behaviour

Post Reply