Sign in to follow this  
Followers 0
iverson_est

Run Prog And Exit Prog

11 posts in this topic

#include <IE.au3>  
$Account = IniRead("Settings.ini", "Settings", "Kasutaja", "NotFound")  
$Password = IniRead("Settings.ini", "Settings", "Parool", "NotFound") 
HotKeySet("{ESC}", "Terminate") 
$o_IE = _IECreate ()
_IENavigate($o_IE, "http://www.rate.ee/show.php") 
Sleep(2000) 
Run("Errorcheck.exe")
Sleep(3000)  
Send($Account)
Send("{TAB}")
Send($Password)  
Send("{TAB}") 
Send("{Enter}")  
Sleep(4000) 
While 1
$oForm = _IEFormGetObjByIndex($o_IE, 0)
$oViis = _IEFormElementGetObjByName($oForm, "rating", 5) 
$oViis.click  
Sleep(1000)
$oForm1 = _IEFormGetObjByIndex($o_IE, 0)
$oNeli = _IEFormElementGetObjByName($oForm1, "rating", 4)  
$oNeli.click 
Sleep(1000)  
$oForm2 = _IEFormGetObjByIndex($o_IE, 0)
$oKolm = _IEFormElementGetObjByName($oForm2, "rating", 3)  
$oKolm.click  
Sleep(1000) 
WEnd 
Func Terminate () 
    Exit 0 
EndFunc

and the errorcheck

$file_loc = @ScriptDir & "\rate login 1.au3"
HotKeySet("{F1}", "Terminate")
Func Terminate()
    Exit 0
EndFunc
While 1
    Sleep(5000) 
    If WinExists("AutoIt Error") Then
        Send("{Enter}")
        ProcessClose("iexplore.exe")  
        Sleep(2000)
        Run(@AutoItExe & ' "' & $file_loc & '"', "",@SW_MAXIMIZE) 
        Sleep(3000)
        Exit
    ;ProcessClose("errorcheck.exe")
    EndIf
WEnd

and it just wont close the errorcheck. It just won't. If i take this Run part away it closes nicely. How could i make it run one prog and then close the errorcheck? :think:

Share this post


Link to post
Share on other sites



#include <IE.au3>  
$Account = IniRead("Settings.ini", "Settings", "Kasutaja", "NotFound")  
$Password = IniRead("Settings.ini", "Settings", "Parool", "NotFound") 
HotKeySet("{ESC}", "Terminate") 
$o_IE = _IECreate ()
_IENavigate($o_IE, "http://www.rate.ee/show.php") 
Sleep(2000) 
Run("Errorcheck.exe")
Sleep(3000)  
Send($Account)
Send("{TAB}")
Send($Password)  
Send("{TAB}") 
Send("{Enter}")  
Sleep(4000) 
While 1
$oForm = _IEFormGetObjByIndex($o_IE, 0)
$oViis = _IEFormElementGetObjByName($oForm, "rating", 5) 
$oViis.click  
Sleep(1000)
$oForm1 = _IEFormGetObjByIndex($o_IE, 0)
$oNeli = _IEFormElementGetObjByName($oForm1, "rating", 4)  
$oNeli.click 
Sleep(1000)  
$oForm2 = _IEFormGetObjByIndex($o_IE, 0)
$oKolm = _IEFormElementGetObjByName($oForm2, "rating", 3)  
$oKolm.click  
Sleep(1000) 
WEnd 
Func Terminate () 
    Exit 0 
EndFunc

and the errorcheck

$file_loc = @ScriptDir & "\rate login 1.au3"
HotKeySet("{F1}", "Terminate")
Func Terminate()
    Exit 0
EndFunc
While 1
    Sleep(5000) 
    If WinExists("AutoIt Error") Then
        Send("{Enter}")
        ProcessClose("iexplore.exe")  
        Sleep(2000)
        Run(@AutoItExe & ' "' & $file_loc & '"', "",@SW_MAXIMIZE) 
        Sleep(3000)
        Exit
;ProcessClose("errorcheck.exe")
    EndIf
WEnd

and it just wont close the errorcheck. It just won't. If i take this Run part away it closes nicely. How could i make it run one prog and then close the errorcheck? :think:

Why are you trying to do this with a separate program ?

It looks to me you are trying to avoid Com errors so why not implement a Com Error handler in your original script to process errors?

:(


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

How can i put the errorcheck into the 1st script? When i get an error, the script will stop and it won't do the if...endif. Hope you get what i mean :think:

Share this post


Link to post
Share on other sites

How can i put the errorcheck into the 1st script? When i get an error, the script will stop and it won't do the if...endif. Hope you get what i mean :think:

Here's an example com error handler ... see helpfile for details.

Global $oMyError = ObjEvent("AutoIt.Error","MyErrFunc"); Install a custom error handler 
; This is my custom error handler 
Func MyErrFunc() 
   $HexNumber=hex($oMyError.number,8) 
   ConsoleWrite("COM Error !  LineNumber " & $oMyError.scriptline &  "  errNumber: " & $HexNumber &  "Desc: " & $oMyError.description  & "Windesc: " & $oMyError.windescription ) 
   SetError(1)  ; something to check for when this function returns 
Endfunc

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

The helpfile had this example:

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc"); Install a custom error handler 

; Performing a deliberate failure here (object does not exist)
$oIE = ObjCreate("InternetExplorer.Application")
$oIE.visible = 1
$oIE.bogus 
if @error then Msgbox(0,"","the previous line got an error.")

Exit 


; This is my custom error handler 
Func MyErrFunc() 
   $HexNumber=hex($oMyError.number,8) 
   Msgbox(0,"","We intercepted a COM Error !" & @CRLF & _
                "Number is: " & $HexNumber & @CRLF & _
                "Windescription is: " & $oMyError.windescription ) 

   SetError(1); something to check for when this function returns 
Endfunc

well, if i understand right then i must write $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") to my script and the Func MyErrFunc() and the fix under it?

Like

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")

Func MyErrFunc()

Send("{Enter}")

ProcessClose("iexplore.exe")

Sleep(2000)

Run(@AutoItExe & ' "' & $file_loc & '"', "",@SW_MAXIMIZE)

Sleep(3000)

Tho i don't understand why is it $oMyError, i dont need it as a varable anywhere...

Did i get the basic point or i didn't :think:

Share this post


Link to post
Share on other sites

what is a com statement, didn't read it out from the helpfile.

My error is a simple autoit error. My script clicks radio buttons in a webpage, so when a new page loads a little longer or gets a timeout, i get an autoit error.

Share this post


Link to post
Share on other sites

Ok, i think i know what statement i am missing. My question:

Can i use if...endif statement in com or only for...in and with...endwith statements :think:

Share this post


Link to post
Share on other sites

bump :think:

Share this post


Link to post
Share on other sites

bump :think:

one thing you can do is make sure you have the latest functions in your IE.au3 include file

Func _IELoadWait($o_object, $i_delay = 0)
    If IsObj($o_object) Then
        Sleep($i_delay)
        If ObjName($o_object) = "IWebBrowser2" Then
            While _IEGetProperty($o_object, "busy") or _
                ((_IEGetProperty($o_object, "readyState") <> "complete") and _
                 (_IEGetProperty($o_object, "readyState") <> 4))
                Sleep(100)
            WEnd
        EndIf
        While ($o_object.document.readyState <> "complete") and _
            ($o_object.document.readyState <> 4)
            Sleep(100)
        WEnd
        SetError(0)
        Return 1
    Else
        SetError(1)
        Return 0
    EndIf
EndFunc;==>_IELoadWait

and

Func _IECreate($f_visible = 1)
    $o_object = ObjCreate("InternetExplorer.Application")
    If IsObj($o_object) Then
        $o_object.visible = $f_visible
        _IENavigate ($o_object, "about:blank")
        SetError(0)
        Return $o_object
    Else
        SetError(1)
        Return 0
    EndIf
EndFunc;==>_IECreate

the loadwait is the most importatnt

hope that helps too

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

i have the newest ie.au3, but imo the error i get is unavoidable, i will get it sooner or later... i get one in every 30mins or so, but i want it to run longer, so i can see that the COM error handler would be the best solution here. Tho i have very little clue how to install one.

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