Jump to content

Moving Screens


Go to solution Solved by ioa747,

Recommended Posts

We a have computer that display 8 differernt web pages and I would like them move to a specfic screen in order then go full screen.  I set this as only 3 generic web pages .  Chrome is our primary browser so that is what I have to use.  I have scrubbed all the company specific stuff off for the most part but I want to open 8 different web pages (google docs) and I want to display them on 8 different monitors in order.  The resolution on my monitors is 2160.  So am looking to move one screen to Screen 1 to 0 Screen to to 2160 and screen 3 to 4320...  and so on.   I tried WinMove but I don't think that right or im doing it wrong.

I would like to wrap it around a fucntnion moveScreen so I can re-use in the future.

Is there an AUTIT option for this?  >>I am a beginner so I am not really looking for the solution just enough to get me started

#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <Excel.au3>

Global $exitChrome
Global $moveScreen
Global $terminate


Global $hGui = GUICreate('Au3Gui', 180, 50, -1, -1, -1, $WS_EX_TOPMOST)
GUISetState(@SW_SHOW, $hGui)


        ; Button to opens web pages and places them where on screen in a specific order
        Global $idButton_OpenQCDM = GUICtrlCreateButton("QCDM", 95, 10, 80, 30)
        GUICtrlSetBkColor(-1, 0x99B4D1)

        ; Button to close chrome
        Global $idButton_Close = GUICtrlCreateButton("Close", 5, 10, 80, 30)
        GUICtrlSetBkColor(-1, 0x99B4D1)


While 1
    Switch GUIGetMsg()



        ;Opens Webpages Chrome
        Case $idButton_OpenQCDM

        ;opens web pages
            opensScreens()

            moveScreen()


        ;exits application
        Case $idButton_Close
        ;Close Chrome
        Exit



    EndSwitch
        WEnd


Func exitChrome()
        $runString = StringFormat("TASKKILL /F /IM chrome.exe /T")


EndFunc

;terminates script
Func Terminate()

    Exit


EndFunc

func opensScreens()

# Screen 1 Finance
Run ('"C:\Program Files\Google\Chrome\Application\chrome.exe" www.amazon.com  --start-fullscreen --new-window --force-device-scale-factor=1.15')
# Screen 2 VPS
Run ('"C:\Program Files\Google\Chrome\Application\chrome.exe" www.google.com @sw_maximize --start-fullscreen --new-window --force-device-scale-factor=1.15')
# Screen 3 Quality
Run ('"C:\Program Files\Google\Chrome\Application\chrome.exe" www.yahoo.com  --start-fullscreen --new-window --force-device-scale-factor=1.15')

EndFunc

Func moveScreen()


# Delay to let all browser windows open
 Sleep (10000)

# Position Screens Moving Sreens to proper locations

# Screen 1
sleep (5000)

# Screen 2
sleep (5000)
WinMove( "Google - Google Chrome", " ", 0, 0, 0, 0)
WinSetState("Google - Google Chrome", "", @SW_MAXIMIZE)

# Screen 3#
Sleep (5000)

    EndFunc

suppoted browser.

Edited by MichaelCrawley
Link to comment
Share on other sites

  • Solution

 

:)

 

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
#include <WindowsConstants.au3>
#include <WinAPIGdi.au3>

Global $hGui = GUICreate('Au3Gui', 500, 500, -1, -1, $WS_OVERLAPPEDWINDOW)
WinSetTrans($hGui, '', 100)
Global $Label1 = GUICtrlCreateLabel("", 200, 200, 300, 300)
GUICtrlSetFont(-1, 200, 900, 0, "MS Sans Serif")
GUISetState(@SW_SHOW, $hGui)

Global $aMon = _GetMonitorsArray()
If IsArray($aMon) Then
    For $i = 1 To $aMon[0][0]
        WinMove($hGui, "", $aMon[$i][1], $aMon[$i][2])
        GUISetState(@SW_MAXIMIZE, $hGui)
        GUICtrlSetData($Label1, $i)

        ConsoleWrite("  index: " & $i & @CRLF)
        ConsoleWrite("- [0]=handle=" & $aMon[$i][0] & @CRLF)
        ConsoleWrite("- [1]=left=" & $aMon[$i][1] & @CRLF)
        ConsoleWrite("- [2]=top=" & $aMon[$i][2] & @CRLF)
        ConsoleWrite("- [3]=width=" & $aMon[$i][3] & @CRLF)
        ConsoleWrite("- [4]=height=" & $aMon[$i][4] & @CRLF)
        ConsoleWrite("" & @CRLF)

        _GetMonitorInfo($hGui)

        Sleep(2000)
    Next
EndIf

;----------------------------------------------------------------------------------------
Func _GetMonitorInfo($hWindow)
    Local $hMonitor = _WinAPI_MonitorFromWindow($hWindow, $MONITOR_DEFAULTTONULL)
    Local $aData = _WinAPI_GetMonitorInfo($hMonitor)
    ConsoleWrite('MonitorInfo **********************' & @CRLF)
    If Not @error Then
        ConsoleWrite('Handle:      ' & $hMonitor & @CRLF)
        ConsoleWrite('Rectangle:   ' & DllStructGetData($aData[0], 1) & ', ' & DllStructGetData($aData[0], 2) & ', ' & DllStructGetData($aData[0], 3) & ', ' & DllStructGetData($aData[0], 4) & @CRLF)
        ConsoleWrite('Work area:   ' & DllStructGetData($aData[1], 1) & ', ' & DllStructGetData($aData[1], 2) & ', ' & DllStructGetData($aData[1], 3) & ', ' & DllStructGetData($aData[1], 4) & @CRLF)
        ConsoleWrite('Primary:     ' & $aData[2] & @CRLF)
        ConsoleWrite('Device name: ' & $aData[3] & @CRLF)
        ConsoleWrite("**********************************" & @CRLF & @CRLF)

    EndIf
EndFunc   ;==>_GetMonitorInfo
;----------------------------------------------------------------------------------------
Func _GetMonitorsArray()
    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   ;==>_GetMonitorsArray
;----------------------------------------------------------------------------------------

 

I know that I know nothing

Link to comment
Share on other sites

  • 4 weeks later...

Oh my, I did not even see this I really apreciate the work you put into this.   This is awesome, If you don't mind I am going to save this reuse it in other areas because I certain I will use it.    I am going to see if I can break it down into smaller componets to ame sure I understand it.

Link to comment
Share on other sites

  • 4 weeks later...

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...