Jump to content
Sign in to follow this  
Aequitas

Script hangs up on while loop

Recommended Posts

Aequitas

I have tried this so many different ways, but I cannot seem to get out of this while loop and have my script continue.  My script gets to this function and executes the code within the while loop fine. I just cannot seem to get it to exit this while loop. I have also tried Do..Until loops, setting to while winexists() = false.

Func _FixOfficeID()
    $pop = 12
    While 1
        If WinExists("Google - Windows Internet Explorer") Then
            ExitLoop
        EndIf
        $pop += 1
        _IELinkClickByIndex($oIE, $pop)
        Sleep(500)
        _SendEx("{backspace}")
        Sleep(200)
    WEnd
    _WinWaitActivate($TITLE, $TEXT)
    _SendEx("{enter 2}")
    _SendEx("{left 5}")
    _SendEx("{CTRLDOWN}c{CTRLUP}")
EndFunc   ;==>_FixOfficeID

$TITLE, $TEXT, and $oIE are set up as global from earlier in script. The bottom part of the function works correctly when tested without the while loop.

Thank you in advance for your help

Share this post


Link to post
Share on other sites
November

Hi there and welcome to AutoIT forum.

Did you tried to output the winexists to see if is sucessufull?

The winexists is the only condition tha get you out of the loop and continue your script.

Try consolewrite(@error & @CRLF) after that statement.

 

Cheers


Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Share this post


Link to post
Share on other sites
tommytx

why not add something like this to see what the heck the loop is up to..

While 1
        If WinExists("Google - Windows Internet Explorer") Then
                $cnt=$cnt+1
                consolewrite($cnt & @CRLF)
                if $cnt> 5 then exit
            ExitLoop
        EndIf

At least this way you will know for sure if the loop is able to intrepret the WinExists result or not.. and if not it quits after 5 loops

or make it as many loops as you like but bottom line if its looping over and over then the WinExists is not qalifying

Share this post


Link to post
Share on other sites
Aequitas

Thank you for the responses.

The WinExists does work i tested with

If WinExists("Google - Windows Internet Explorer") Then
    MsgBox(1, "abc", "abc")
Else
    MsgBox(1, "def", "def")
EndIf

i get nothing with the consolewrite(@error & @CRLF) because I do not think it errors out, it just stays stuck in the loop.

​A little more background to see if you have any other ideas.

What the while loop is doing is clicking an undetermined amount of links on the page that it is on.  The first 13 links I do not want pressed.The links after that are JavascriptForm:Submit(******). Those are the ones I need to cycle through. The last on the page is always a link to a specific webpage (hence the WinExists to exit the loop)

Share this post


Link to post
Share on other sites
Aequitas

it does not execute the commands listed under the loop that were tested seperately and work

_WinWaitActivate($TITLE, $TEXT)
    _SendEx("{enter 2}")
    _SendEx("{left 5}")
    _SendEx("{CTRLDOWN}c{CTRLUP}")

Share this post


Link to post
Share on other sites
Aequitas

Func _WinWaitActivate($TITLE, $TEXT = "", $TIMEOUT = 3600)
    If WinWait($TITLE, $TEXT, $TIMEOUT) Then
        If Not WinActive($TITLE, $TEXT) Then
            WinActivate($TITLE, $TEXT)
        EndIf
        WinWaitActive($TITLE, $TEXT)
    EndIf
EndFunc   ;==>_WinWaitActivate
Func _SendEx($ss, $warn = "")
    Local $iT = TimerInit()

    While _IsPressed("10") Or _IsPressed("11") Or _IsPressed("12")

        If $warn <> "" And TimerDiff($iT) > 1000 Then
            MsgBox(262144, "Warning", $warn)
        EndIf
        Sleep(50)
    WEnd
    Send($ss)
EndFunc   ;==>_SendEx
Global $TITLE = "Microsoft Excel"
Global $TEXT = "Status Bar"

Share this post


Link to post
Share on other sites
Aequitas

I cannot post a link to the website (even if i did it is an internal site). the best I can do to get a better idea on what happens is list the links on the page with url replaced as google

17 links found
 
javascript:logoutUser(1)
javascript:logoutUser(2)
javascript:FormSubmit(28379);
javascript:FormSubmit(26808);
javascript:FormSubmit(28327);
 
the while loop cycles through the 3 javascript:FormSubmit(*****); (which will not always be 3) and then opens the help.pdf. I was trying to use the Help.pdf opening to exit the While loop

Share this post


Link to post
Share on other sites
Aequitas
I believe it is. Below is the finder tool output, but like i said before i used this script (with the real url) and it returned abc
 
If WinExists("Google - Windows Internet Explorer") Then
    MsgBox(1, "abc", "abc")
Else
    MsgBox(1, "def", "def")
EndIf
 
 
>>>> Window <<<<
Title: https://google/Help.pdf - Windows Internet Explorer
Class: IEFrame
Position: 1053, 100
Size: 800, 600
Style: 0x16CF0000
ExStyle: 0x00000100
Handle: 0x00000000003604D0
 
>>>> Control <<<<
Class: Client Caption
Instance: 1
ClassnameNN: Client Caption1
Name:
Advanced (Class): [CLASS:Client Caption; INSTANCE:1]
ID:
Text:
Position: 0, 0
Size: 784, 19
ControlClick Coords: 227, 14
Style: 0x54000000
ExStyle: 0x00000000
Handle: 0x000000000029046A
 
>>>> Mouse <<<<
Position: 1288, 114
Cursor ID: 0
Color: 0xFFFFFF
 
>>>> StatusBar <<<<
 
>>>> ToolsBar <<<<
 
>>>> Visible Text <<<<
Navigation Bar
Address Combo Control
Page Control
Favorites and Tools Bar
ITBarHost
Menu Bar
https://google/Help.pdf - Windows Internet Explorer
LocalEWH-10596-0 - Adobe Reader
AVTableContainerView
AVSplitterView
AVSplitationPageView
AVSplitterView
AVScrolledPageView
AVScrollView
AVTableContainerView
8.50 x 11.00 in
AVPageView
 
 
>>>> Hidden Text <<<<
AVUICommandWidget
76.7%
1
AVTabStripView
AVDockableHostView
AVRulerView
1
AVNullDocView

Share this post


Link to post
Share on other sites
Aequitas

I tried Opt("WinTitleMatchMode", 2) and tried changing WinExists("Help.pdf") Then

still repeating the While loop

Share this post


Link to post
Share on other sites
Aequitas

any ideas on another way to end the While loop?

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
Sign in to follow this  

×