Jump to content
Wendallwoof

Whats going wrong with my rotation script?

Recommended Posts

Wendallwoof

Hi all,

So I've created a script that rotates between two browser sessions and a local app. Initially the script does the following: opens the local app and uses key strokes to ensure the correct page is displayed. Opens two browsers and logs in with relevant credentials. This part all works fine, so good so far.

Essentially what I then need the script to do is rotate between browser session 1, browser session 2 and the local app (order is not relevant to be honest just need it to rotate). The issue is that script appears to rotate from local app to the next browser but then either usually gets stuck (doesnt rotate to the next browser or back to the local app)

Any ideas? Passwords and URLS removed

#include <IE.au3>

#RequireAdmin



Run("C:\Users\Integration\AppData\Roaming\Oak Telecom\display\OakWallboard.exe", "", @SW_MAXIMIZE) ; Opens the telephony logging system,
Local $displayX = ("Warning"); The error title displayed by the two error windows
WinWait($displayX, "", 10)
Send("{Enter}")
WinWait($displayX, "", 10)
Send("{Enter}") ; Enter keystrokes are sent to remove the two error windows that keep appearing when loading Oak Telecom software

Func DisplayXTitle()
    ; Retrieve the window title of the active window.
    Local $windowTitle = WinGetTitle("[ACTIVE]")
    WinActivate($windowTitle)
EndFunc   ;==>DisplayXTitle

Sleep(5000)

Local $focusSupportPage = _IECreate("http://support.******.co.uk/helpdesk/tickets")
$focusSupportHandle = _IEPropertyGet($focusSupportPage, "hwnd") ; Get Handle of the IE window
WinSetState($focusSupportHandle, "", @SW_HIDE) ; Minimizes The focus support window in IE
Sleep(5000)

Local $dropTask = _IECreate("www.droptask.com/projects/54d0d3cf44778b030075c0a8")
$dropTaskHandle = _IEPropertyGet($dropTask, "hwnd") ; Get Handle of the IE window
WinSetState($dropTaskHandle, "", @SW_HIDE) ; Minimize the drop task IE window
$dropTaskUsername = _IEGetObjByName($dropTask, "email")

_IEFormElementSetValue($dropTaskUsername, "****@****.co.uk")
$dropTaskPassword = _IEGetObjByName($dropTask, "password")
_IEFormElementSetValue($dropTaskPassword, "*****")

$oForm = _IEFormGetCollection($dropTask, 0) ; Submits IE form
_IEFormSubmit($oForm)

While 1

    DisplayXTitle()
    MouseClick("left", 690, 15, 1); Set Co-ordinates to 690,15 and clicks once where the drop down option is required to set the Team to integration.
    MouseClick("left", 161, 87, 1); As above
    Send("{f11}"); full screen
    Sleep(120000)
    Send("{f11}"); full screen
    Local $windowTitle = WinGetTitle("[ACTIVE]")
    WinSetState($windowTitle, "", @SW_HIDE) ; Minimizes the Oak window

    WinSetState($focusSupportHandle, "", @SW_MAXIMIZE); Maximizes The focus support window in IE
    WinActivate($focusSupportHandle)
    Send("{f11}"); full screen
    Sleep(120000)
    Send("{f11}"); full screen
    WinSetState($focusSupportHandle, "", @SW_HIDE) ; Minimizes The focus support window in IE

    WinSetState($dropTaskHandle, "", @SW_MAXIMIZE) ; Mazimize the drop Task IE window
    WinActivate($dropTaskHandle)
    Send("{f11}") ; full screen
    Sleep(120000)
    Send("{f11}"); full screen
    WinSetState($dropTaskHandle, "", @SW_HIDE) ; Minimize the drop task IE window

WEnd

 

Edited by Melba23
Added code tags

Share this post


Link to post
Share on other sites
Melba23

Wendallwoof,

When you post code please use Code tags - see here how to do it.  Then you get a scrolling box and syntax colouring as you can see above now I have added the tags.


M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Shane0000

I ran the below code with no problems. 

Maybe try a try a loop with WinActive that calls the next window until successful.

 

#include <IE.au3>
Local $dropTask = _IECreate("www.google.com/")
Local $focusSupportPage  = _IECreate("www.msn.com/")
WinSetState($dropTask.HWND,"", @SW_Minimize)
WinSetState($focusSupportPage.HWND,"", @SW_Minimize)


While 1
    While Not(WinGetState($dropTask.HWND) = 47)
        WinSetState($dropTask.HWND,"", @SW_Maximize)
        WinActivate($dropTask)
    WEnd
    Send("{f11}"); full screen
    Sleep(10000)
    Send("{f11}"); full screen
    WinSetState($dropTask.HWND,"", @SW_Minimize)

    While Not(WinGetState($focusSupportPage.HWND) = 47)
        WinSetState($focusSupportPage.HWND,"", @SW_Maximize)
        WinActivate($focusSupportPage)
    WEnd
    Send("{f11}"); full screen
    Sleep(10000)
    Send("{f11}"); full screen
    WinSetState($focusSupportPage.HWND,"", @SW_Minimize)
WEnd

 

  • Like 1

Share this post


Link to post
Share on other sites
Wendallwoof

Worth noting, im using windows 8 (not my choice!). the script works fine on 7 but acts a bit irrationally on 8.

Apologies Melba, i'll note that for future posting.

 

The browsers seem to work fine but it must be this local app thats causing me the headache..

Share this post


Link to post
Share on other sites
Wendallwoof

also, thank you for your input Shane

  • Like 1

Share this post


Link to post
Share on other sites
Wendallwoof

Also what does the 47 relate to in the following line of code? 

While Not(WinGetState($dropTask.HWND) = 47)

Is this a browser status code or such?

Share this post


Link to post
Share on other sites
reb

From the help file (I need it all the time)

WinGetState

Retrieves the state of a given window.

WinGetState ( "title" [, "text"] )

Parameters

titleThe title/hWnd/class of the window to get the state. See Title special definition.
text[optional] The text of the window to get the state. Default is an empty string. See Text special definition.

Return Value

Success:a value indicating the state of the window. Multiple values are added together so use BitAND() to examine the part you are interested in:
    1 = Window exists
    2 = Window is visible
    4 = Window is enabled
    8 = Window is active
    16 = Window is minimized
    32 = Window is maximized
  • Like 1

MEASURE TWICE - CUT ONCE

Share this post


Link to post
Share on other sites
Wendallwoof

Brill, Cheers reb

Share this post


Link to post
Share on other sites
Shane0000

With a search I found a little code to retrieve the HWND of the application

$theWinlist = Winlist()
    Do
        For $i = 1 To $theWinlist[0][0]
            If $theWinlist[$i][0] <> "" Then
                $iPID2 = WinGetProcess($theWinlist[$i][1])
                If $iPID2 = $aPID Then
                    $hWnd2 = $theWinlist[$i][1]
                    ExitLoop
                EndIf
            EndIf
        Next
    Until $hWnd2 <> 0

You should be able to get the HWND like above and use the same loop to call your application to be active, maximized.

 

Edit:

$aPID = run("C:\Users\Integration\AppData\Roaming\Oak Telecom\display\OakWallboard.exe", "", @SW_MAXIMIZE)

Edited by Shane0000
defined $aPID

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

×