rmk08c

WinMove() works 2/3 times

2 posts in this topic

#1 ·  Posted

Hi all. I am new (first post), been lurking and learning for a while.

Every day for work, I have to manually load and position three IE windows (about 10 tabs total). My script attempts to automate this. However, autoit will only move the first two windows it creates, not the third. For example, if you rearrange my script so that $oIEUtilities is created first, WinMove() works; but when it is the third window, it does not. Am I missing something easy and obvious? Any help is appreciated. Running Windows 7, IE 11, 6 monitors.

PS - I have a much larger script that this will be a part of eventually, I am just testing/debugging before I add this code to that script.

 

#include <IE.au3>

While 1
sleep(20)
   HotKeySet("+{LEFT}", "setupwindows")
WEnd

Func setupwindows ()

   Opt("WinTitleMatchMode", 2)

   $oIENewsMontage = _IECreate("http://www.theflyonthewall.com/flyingMachineVertical.php")
   WinWait("FlyingMachine")
   __IENavigate($oIENewsMontage, "https://www.google.com/finance", 0, 0x800)
   WinWait("Google Finance")
   __IENavigate($oIENewsMontage, "http://www.cefconnect.com/", 0, 0x800)
   WinWait("CEF Connect")
   __IENavigate($oIENewsMontage, "http://www.stockhouse.com/", 0, 0x800)
   WinWait("Stockhouse")
   __IENavigate($oIENewsMontage, "http://seekingalpha.com/", 0, 0x800)
   WinWait("Seeking Alpha")
   __IENavigate($oIENewsMontage, "https://www.sec.gov/edgar/searchedgar/companysearch.html", 0, 0x800)
   WinWait("SEC")
   __IENavigate($oIENewsMontage, "https://www.bloomberg.com/markets/stocks/futures", 0, 0x800)
   WinWait("Bloomberg")
   WinWait("FlyingMachine")
   Sleep(500)
   Send("^{TAB}")
   Sleep(500)
   WinMove("FlyingMachine", "", 0, 0, 1280, 650)

   $oIEFlySearch = _IECreate("http://www.theflyonthewall.com/content_index.php?")
   WinWait("theflyonthewall")
   Sleep(500)
   WinMove("theflyonthewall.com", "", 1921, 343, 639, 681)

    $oIEUtilities = _IECreate("yahoo.com")
   WinWait("Yahoo")
   __IENavigate($oIEUtilities, "bing.com", 0, 0x800)
   WinWait("Bing")
   Sleep(1000)
   WinActivate("Bing")
   WinMove("Bing", "", -1280, 219, 641, 564)
;~    Sleep(1000)
;~    WinActivate("Yahoo")
;~    WinMove("Yahoo", "", -1280, 219, 641, 564)

   If(Not WinExists("Windsor")) then
      Run("C:\Program Files (x86)\Windsor Direct\terminal.exe")
   EndIf
   WinMove("Windsor", "", 1280, 132, 646, 943)

EndFunc

 

Share this post


Link to post
Share on other sites



#2 ·  Posted

Try:

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

Global $aMonitorInfo = MonitorInfo()
Global $hIENewsMontage, $hIEFlySearch, $hIEUtilities

Global $aIENewsMontage[8]
$aIENewsMontage[0] = 7
$aIENewsMontage[1] = "http://www.theflyonthewall.com/flyingMachineVertical.php"
$aIENewsMontage[2] = "https://www.google.com/finance"
$aIENewsMontage[3] = "http://www.cefconnect.com/"
$aIENewsMontage[4] = "http://www.stockhouse.com/"
$aIENewsMontage[5] = "http://seekingalpha.com/"
$aIENewsMontage[6] = "https://www.sec.gov/edgar/searchedgar/companysearch.html"
$aIENewsMontage[7] = "https://www.bloomberg.com/markets/stocks/futures"

Global $aIEFlySearch[2]
$aIEFlySearch[0] = 1
$aIEFlySearch[1] = "http://www.theflyonthewall.com/content_index.php?"

Global $aIEUtilities[3]
$aIEUtilities[0] = 2
$aIEUtilities[1] = "yahoo.com"
$aIEUtilities[2] = "bing.com"

_IEOpenUrl($hIENewsMontage, $aIENewsMontage, 1)
_IEOpenUrl($hIEFlySearch, $aIEFlySearch, 2)
_IEOpenUrl($hIEUtilities, $aIEUtilities, 3)

Func _IEOpenUrl($hWnd, $aUrl, $iMonitor)
    Local $oIE
    $oIE = _IECreate($aUrl[1])
    $hwnd = _IEPropertyGet($oIE, "hwnd")
    If UBound($aUrl) - 1 > 1 Then
        For $i = 2 To $aUrl[0]
            $oIE.Navigate2($aUrl[$i], 0x0800)
        Next
    EndIf
    WinMove($hWnd, "", $aMonitorInfo[$iMonitor][1], $aMonitorInfo[$iMonitor][2], $aMonitorInfo[$iMonitor][3], $aMonitorInfo[$iMonitor][4])
    WinSetState($hWnd, "", @SW_MAXIMIZE)
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

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