Ruther

Launching Multiple IE Windows On Different, Multiple Monitors

9 posts in this topic

#1 ·  Posted

My apologies in advance, I'm a total newcomer with AutoIt. :)

I'm trying to launch three IE windows using AutoIt; however, I need them to open as a maximized window on three different monitors as well. I currently have this code with me:

ShellExecute ("iexplore", "http://www.google.com.au")
   Local $hWnd = WinWait("[CLASS:IEXPLORER]", "", 5)
      Local $aPos = WinGetPos($hWnd)
         WinMove($hWnd, "", 0, 0, 2000, 2000)

I'm able to launch the IE window, however I'm unable to move it to a part of my screen, or maximize it. Any help would be greatly appreciated , thanks! 

Share this post


Link to post
Share on other sites



#2 ·  Posted

Try:

#include <Array.au3>
#include <IE.au3>
#include <WinAPIGdi.au3>

Local $aPos, $aData = _WinAPI_EnumDisplayMonitors()

If IsArray($aData) Then
    ReDim $aData[$aData[0][0] + 1][5]
    For $i = 1 To $aData[0][0]
        $aPos = _WinAPI_GetPosFromRect($aData[$i][1])
        For $j = 0 To 3
            $aData[$i][$j + 1] = $aPos[$j]
        Next
    Next
EndIf

Local $aURLStrings[4] = [3, "http://www.google.com.au", "http://www.google.co.nz", "http://www.google.com"]
_IEOpenUrl()

Func _IEOpenUrl()
    Local $oIE, $hWnd, $aPos
    For $i = 1 To $aData[0][0]
        $oIE = _IECreate($aURLStrings[$i])
        $hwnd = _IEPropertyGet($oIE, "hwnd")
        WinMove($hWnd, "", $aData[$i][1], $aData[$i][2], $aData[$i][3], $aData[$i][4])
        WinSetState($hWnd, "", @SW_MAXIMIZE)
    Next
EndFunc

 

Share this post


Link to post
Share on other sites

#3 ·  Posted

You should be able to use WinMove() to get it on the monitor you want, and then use WinSetState() to maximize it.  It will full screen to that monitor if your desktop is setup as separate monitors in extended view.

 

If your using a multi monitor solution like eyefinity or matrox, etc where multiple monitors appear as one GIANT monitor to your OS then the best thing you can do is just use WinMove() and give it the full coordinates and size that you want it moved too.  Example 

WinMove($hWnd, "", 0, 0, 2000, 2000)

WinMove($hWnd, "", 0, 0, 1920, 1080)

 

Share this post


Link to post
Share on other sites

#4 ·  Posted

18 hours ago, Subz said:

Try:

#include <Array.au3>
#include <IE.au3>
#include <WinAPIGdi.au3>

Local $aPos, $aData = _WinAPI_EnumDisplayMonitors()

If IsArray($aData) Then
    ReDim $aData[$aData[0][0] + 1][5]
    For $i = 1 To $aData[0][0]
        $aPos = _WinAPI_GetPosFromRect($aData[$i][1])
        For $j = 0 To 3
            $aData[$i][$j + 1] = $aPos[$j]
        Next
    Next
EndIf

Local $aURLStrings[4] = [3, "http://www.google.com.au", "http://www.google.co.nz", "http://www.google.com"]
_IEOpenUrl()

Func _IEOpenUrl()
    Local $oIE, $hWnd, $aPos
    For $i = 1 To $aData[0][0]
        $oIE = _IECreate($aURLStrings[$i])
        $hwnd = _IEPropertyGet($oIE, "hwnd")
        WinMove($hWnd, "", $aData[$i][1], $aData[$i][2], $aData[$i][3], $aData[$i][4])
        WinSetState($hWnd, "", @SW_MAXIMIZE)
    Next
EndFunc

 

 

Thank you for this! 

One last question though, can it run in full screen mode automatically?

Share this post


Link to post
Share on other sites

#5 ·  Posted

Do you mean:

_IEPropertyGet($oIE, "fullscreen")

 

Share this post


Link to post
Share on other sites

#6 ·  Posted

Can't it automatically open on IE's kiosk mode?

Oh, and would I just change this:

...

$hwnd = _IEPropertyGet($oIE, "hwnd")

...

Part of the code?

Share this post


Link to post
Share on other sites

#7 ·  Posted

You can use the following:
nb: Uncomment _ArrayDisplay to view the monitor information and you can assign the third parameter of _IEOpenUrl to the monitor you want it displayed.  You probably don't require the hwnd but have left it there in case you want to make changes later on.

#include <Array.au3>
#include <IE.au3>
#include <WinAPIGdi.au3>

Global $hMonitor01, $hMonitor02, $hMonitor03
Global $aMonitorInfo = MonitorInfo()
;~ _ArrayDisplay($aMonitorInfo)

_IEOpenUrl($hMonitor01, "http://www.google.com", 1)
_IEOpenUrl($hMonitor02, "http://www.google.co.nz", 2)
_IEOpenUrl($hMonitor03, "http://www.google.com.au", 3)

Func _IEOpenUrl($hWnd, $sURL, $iMonitor)
    Local $oIE
    $oIE = _IECreate($sURL)
    $hwnd = _IEPropertyGet($oIE, "hwnd")
    With $oIE
        .Left = $aMonitorInfo[$iMonitor][1]
        .Top = $aMonitorInfo[$iMonitor][2]
        .Menubar = False
        .Resizable = False
        .StatusBar = False
        .TheaterMode = True
        .Toolbar = False
        .Visible = True
        .Fullscreen = True
    EndWith
EndFunc

Func MonitorInfo()
    Local $aPos, $aData = _WinAPI_EnumDisplayMonitors()

    If IsArray($aData) Then
        ReDim $aData[$aData[0][0] + 1][5]
        For $i = 1 To $aData[0][0]
            $aPos = _WinAPI_GetPosFromRect($aData[$i][1])
            For $j = 0 To 3
                $aData[$i][$j + 1] = $aPos[$j]
            Next
        Next
    EndIf
    Return $aData
EndFunc

 

Share this post


Link to post
Share on other sites

#8 ·  Posted

Using the code above, and just changing the links, I've encountered this error (please see attached):

 

Quote

Line 18, (File "C:\Users\(USERNAME)\Desktop\Test2.au3

.Left = $aMonitorInfo[$iMonitor][1]

.Left = ^ ERROR

Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.

 

 

Share this post


Link to post
Share on other sites

#9 ·  Posted

Uncomment _ArrayDisplay and make sure you have at least 4 lines otherwise it will fail, if you look at the _IEOpenUrl function it has 3 parameters:

  1. Handle placeholder variable (for later usage if required)
  2. Url as a string
  3. MonitorInfo line number

The code below should manage and errors in future it will just assign the $iMonitor to 0 if it is greater than the MonitorInfo line number (assume one of the monitors is switched off).

#include <Array.au3>
#include <IE.au3>
#include <WinAPIGdi.au3>

Global $hMonitor01, $hMonitor02, $hMonitor03
Global $aMonitorInfo = MonitorInfo()
;~ _ArrayDisplay($aMonitorInfo)

_IEOpenUrl($hMonitor01, "http://www.google.com", 1)
_IEOpenUrl($hMonitor02, "http://www.google.co.nz", 2)
_IEOpenUrl($hMonitor03, "http://www.google.com.au", 3)

Func _IEOpenUrl($hWnd, $sURL, $iMonitor)
    Local $oIE
    If $iMonitor > UBound($aMonitorInfo) - 1 Then $iMonitor = 0
    $oIE = _IECreate($sURL)
    $hwnd = _IEPropertyGet($oIE, "hwnd")
    With $oIE
        .Left = $aMonitorInfo[$iMonitor][1]
        .Top = $aMonitorInfo[$iMonitor][2]
        .Menubar = False
        .Resizable = False
        .StatusBar = False
        .TheaterMode = True
        .Toolbar = False
        .Visible = True
        .Fullscreen = True
    EndWith
EndFunc

Func MonitorInfo()
    Local $aPos, $aData = _WinAPI_EnumDisplayMonitors()

    If IsArray($aData) Then
        ReDim $aData[$aData[0][0] + 1][5]
        For $i = 1 To $aData[0][0]
            $aPos = _WinAPI_GetPosFromRect($aData[$i][1])
            For $j = 0 To 3
                $aData[$i][$j + 1] = $aPos[$j]
            Next
        Next
    EndIf
    Return $aData
EndFunc

 

MonitorInfo.jpg

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now