Ruther Posted March 1, 2017 Posted March 1, 2017 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!
Subz Posted March 1, 2017 Posted March 1, 2017 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
ViciousXUSMC Posted March 1, 2017 Posted March 1, 2017 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)
Ruther Posted March 2, 2017 Author Posted March 2, 2017 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?
Ruther Posted March 2, 2017 Author Posted March 2, 2017 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?
Subz Posted March 2, 2017 Posted March 2, 2017 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. expandcollapse popup#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
Ruther Posted March 2, 2017 Author Posted March 2, 2017 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.
Subz Posted March 2, 2017 Posted March 2, 2017 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: Handle placeholder variable (for later usage if required) Url as a string 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). expandcollapse popup#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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now