Post Reply
Gary Law 2002-01-20 18:54
Hello there, I followed your example code and come with with my own VB program.
The notepad.exe moved to the second window but not my VB exe. Would you please help me out?
The script that I used:
Set util = CreateObject("UltraMon.Utility") If util.Run("C:\download\test.exe") = True Then Set wnd = CreateObject("UltraMon.Window") If wnd.Find("", "", FINDWND_CLASS, util.ProcessID, 5000) = True Then 'MsgBox "found it" & wnd.title & " l = " & wnd.left Set sys = CreateObject("UltraMon.System") Set mon = sys.Monitors("2") wnd.Monitor = 2 util.Sleep 200 wnd.ApplyChanges 0
End If End If
The test.exe is only a form in the VB, I created it by just created a new form and then compiled the program to become test.exe
If you need it, I can email it to you.
Thanks for your help in advance!
|
Christian Studer 2002-01-20 23:49
The problem is that you're calling Window.Find with the FINDWND_CLASS flag, but you're not specifying a class name.
The following code should work fine:
Set util = CreateObject("UltraMon.Utility") If util.Run("C:\download\test.exe") = True Then Set wnd = CreateObject("UltraMon.Window") If wnd.Find("", "", 0, util.ProcessID, 5000) = True Then wnd.Monitor = 2 wnd.ApplyChanges 0 End If End If
Christian Studer - www.realtimesoft.com
|
Gary Law 2002-01-21 16:41
Thanks for your quick response!
Unfortunately I still cannot get it working even I cut and paste your script.
And I tried to use the short cut feature of version 2 of ultramon, still no luck.
The result is form1 appear but does not move to the second window, plus there is also another box appear said "DDR Server" which I have no idea where does it come from.
But then, I uninstall v2 of ultramon and put v1 back in, then the shortcut works!
Any ideas?
|
Christian Studer 2002-01-22 00:34
I just tested this with a simple VB app consisting only of a single form. As you said, the app doesn't get moved.
The problem is that even a simple VB app like this creates multiple windows (a total of 5). The code above just moves the first window created by the app it finds, which causes the problems you mentioned.
To move this app, you'll have to specify the window title and/or class name. Here is code that should work fine, assuming the title of your form is Form1:
Const FINDWND_TITLE = 1 Set util = CreateObject("UltraMon.Utility") If util.Run("C:\download\test.exe") = True Then Set wnd = CreateObject("UltraMon.Window") If wnd.Find("Form1", "", FINDWND_TITLE, util.ProcessID, 5000) = True Then wnd.Monitor = 2 wnd.ApplyChanges 0 End If End If
Christian Studer - www.realtimesoft.com
|
Post Reply
|