Reply to topic  [ 5 posts ] 
Batch files 
Author Message
Doesn't have much of a life
User avatar

Joined: Sat Apr 25, 2009 9:17 pm
Posts: 741
Reply with quote
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.

_________________
A Mac user Image


Sun Jul 12, 2009 8:45 pm
Profile
Site Admin
User avatar

Joined: Thu Apr 23, 2009 5:53 pm
Posts: 8603
Location: location, location
Reply with quote
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

_________________
Support X404, use our Amazon link
Get your X404 tat here
jonlumb wrote:
I've only ever done it with a chicken so far, but if required I wouldn't have any problems doing it with other animals at all.


Mon Jul 13, 2009 12:04 pm
Profile WWW
Doesn't have much of a life
User avatar

Joined: Sat Apr 25, 2009 9:17 pm
Posts: 741
Reply with quote
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.

_________________
A Mac user Image


Mon Jul 13, 2009 9:08 pm
Profile
Doesn't have much of a life
User avatar

Joined: Sat Apr 25, 2009 9:17 pm
Posts: 741
Reply with quote
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.

_________________
A Mac user Image


Tue Jul 14, 2009 8:09 am
Profile
What's a life?
User avatar

Joined: Thu Apr 23, 2009 8:25 pm
Posts: 10691
Location: Bramsche
Reply with quote
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. ;)

_________________
"Do you know what this is? Hmm? No, I can see you do not. You have that vacant look in your eyes, which says hold my head to your ear, you will hear the sea!" - Londo Molari

Executive Producer No Agenda Show 246


Tue Jul 14, 2009 8:24 am
Profile ICQ
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 22 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software.