x404.co.uk
http://www.x404.co.uk/forum/

Batch files
http://www.x404.co.uk/forum/viewtopic.php?f=4&t=1720
Page 1 of 1

Author:  pg2114 [ Sun Jul 12, 2009 8:45 pm ]
Post subject:  Batch files

Hello all,

I have created a very simple batch file this evening to open three Internet Explorer webpages simultaneously. The code from this batch file is as follows, with the numbers representing different websites.

Code:
start iexplore http://www.1.co.uk
start iexplore http://www.2.co.uk
start iexplore http://www.3.co.uk


I am looking for one of the websites in the batch file to actually launch on my second monitor. I have UltraMon, which means I can move the windows between monitors with a single click, but it would just finish off the script if it happened automatically.

My initial thoughts were to set Internet Explorer's window location using a .reg file, open one of the sites, and change it back using another .reg file before launching the other two sites. I hit a brick wall with this because the window location is stored in a complicated binary format, which I cannot understand.

Is there a simple way of doing this, please?

Thanks,

Peter.

Author:  saspro [ Mon Jul 13, 2009 12:04 pm ]
Post subject:  Re: Batch files

You need to make a vbs file with the following code in then launch that from the batch file

Code:
Const TIMEOUT = 15 'time in seconds the script will try to find the application's main window

Const WNDCHANGE_CLIP_TO_WORKSPACE = 2
If WScript.Arguments.Count <> 2 Then
   MsgBox "Usage: <application> <monitorNumber>" & vbNewline & "application: can include command-line arguments",, WScript.ScriptName
   WScript.Quit
End If

Set util = CreateObject("UltraMon.Utility")
If util.Run(WScript.Arguments(0)) = True Then
   Set wnd = CreateObject("UltraMon.Window")
   If wnd.GetAppMainWindow(util.ProcessId, TIMEOUT * 1000) = True Then
      wnd.Monitor = CLng(WScript.Arguments(1))
      wnd.ApplyChanges WNDCHANGE_CLIP_TO_WORKSPACE
   End If
End If


Scripts are here

Author:  pg2114 [ Mon Jul 13, 2009 9:08 pm ]
Post subject:  Re: Batch files

That's brilliant, thanks, saspro. I'll give that a go later in the week and let you know how I get on!

Thanks again,

Peter.

Author:  pg2114 [ Tue Jul 14, 2009 8:09 am ]
Post subject:  Re: Batch files

Maybe I'm being a bit thick here, but I can't get it to work, sorry.

I have created two files, one called Test.bat and another called Test.vbs. The code for each file is below.

Code:
** Test.bat **
start C:\Test.vbs
start iexplore http://www.1.co.uk

** Test.vbs **
Const TIMEOUT = 15 'time in seconds the script will try to find the application's main window
Const WNDCHANGE_CLIP_TO_WORKSPACE = 2
If WScript.Arguments.Count <> 2 Then
MsgBox "Usage: <application> <monitorNumber>" & vbNewline & "application: can include command-line arguments",, WScript.ScriptName
WScript.Quit
End If
Set util = CreateObject("UltraMon.Utility")
If util.Run(WScript.Arguments(0)) = True Then
Set wnd = CreateObject("UltraMon.Window")
If wnd.GetAppMainWindow(util.ProcessId, TIMEOUT * 1000) = True Then
wnd.Monitor = CLng(WScript.Arguments(1))
wnd.ApplyChanges WNDCHANGE_CLIP_TO_WORKSPACE
End If
End If


When I run the batch file, I receive the error below.

Image

Am I missing something here?

Thanks,

Peter.

Author:  big_D [ Tue Jul 14, 2009 8:24 am ]
Post subject:  Re: Batch files

You need to adjust the

"start C:\Test.vbs"

to include the command line parameters you need.

E.g.

start C:\Test.vbs iexplore 2

or

start C:\Test.vbs iexplore http://www.test.com 2

Look at the text in the dialog box. ;)

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/