Sign in to follow this  
Followers 0
Spirotot

Restarting a Script

3 posts in this topic

#1 ·  Posted (edited)

I'm writing a script that automatically logs me in to Cisco's Clean Access Agent here at my college campus via CCA Bypass.

The script works well enough, BUT, CCA Bypass (the program my script interacts with) will sometimes hang. And, it never hangs at the same spot.

So, rather than writing individual If statements and timers and stuff in the script for each individual spot that the CCA Bypass program can hang, I'd like to write just one timer that completely re-starts the script if CCA Bypass hangs for more than a certain amount of time.

I'm new with AutoIt, and I'm a a relative n00b when it comes to programming in general.

So how would I go about writing this timer?

If you need the actual code from the script or whatever, just let me know.

Thanks!

Edited by Spirotot

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Check out timerinit in the help file. And then to restart the script do something like:

ShellExecute(@ScriptFullPath)
Exit
Edited by P5ych0Gigabyte

HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Ok, since I'm still learning how this works, I've got my timer set up (incorrectly, unfortunately), I just want the script to end after 15 seconds (it will definitely fail to complete within 15 seconds... So I'm just doing this for testing).

However, the program doesn't quite after 15 seconds. I know it's probably got something to do with the loop (because it only checks the _Timer_Diff once per loop, and since it can't complete the loop [i set up CCA Bypass to stall at a certain point], it never checks the time, and never ends the loop).

What am I doing wrong?

Here is my code:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=CCA Bypass Auto-Login_x32.exe
#AutoIt3Wrapper_Compression=4
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <timers.au3>




Do
    While 1
        $starttime = _Timer_Init()
        $timerdiff = _Timer_Diff($starttime)

        Ping ("www.google.com")
        If (@error == 1 OR @error == 2 OR @error == 3 OR @error = 4) Then
            Sleep (500)
            Send ("#1")

            Sleep(2000)
            ControlFocus("CCA_Bypass.exe", "", "Button1")
            ControlClick ("CCA_Bypass.exe", "", "Button1", "left", 1, 21, 11)

            $A = 0
            Do
                If (WinExists ("Security Alert")) Then
                    $A = 1
                EndIf
            Until $A == 1


            $security = 1


            While $security = 1
                PixelSearch (323, 139, 323, 139, 0XD56765)
                If WinExists("Security Alert") Then
                    $security = 0
                    Sleep(100)
                    ControlFocus ("Security Alert", "", "Button1")
                    ControlClick("Security Alert", "", "Button1", "left", 1, 42, 9)
                ElseIf Not @error Then
                    $security = 0
                    MouseClick ("left", 408, 341, 1, 10)
                Else
                    $security = 1
                    Sleep(2000)
                EndIf
            WEnd

            Sleep(2000)

            $B = 0
            Do
                PixelSearch (428, 196, 428, 196, 0x111076)
                If Not @error Then
                    Send("adfields12585")
                    Send("{TAB}")
                    Send("adf0209")

                    Sleep(3500)

                    Send("{TAB}")
                    sleep(500)
                    Send("{SPACE}")
                    $B = 1
                Else
                    Sleep (1000)
                EndIf
            Until $B == 1

            $count = 0

            Do
                If WinExists ("Google - Windows Internet Explorer") Then
                    ProcessClose ("iexplore.exe")
                    ProcessClose("CCA_Bypass.exe")
                    $count = 1
                Else
                    Sleep(2000)
                EndIf
            Until $count == 1
        Else
            Sleep(1800000)
        EndIf
    WEnd
Until ($timerdiff == 15000)

ProcessClose("CCA_Bypass.exe")
Edited by Spirotot

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  
Followers 0