Jump to content

Recommended Posts

Posted

Hi All,

How to quit or exit autoit script .exe file. I have created one script using autoit script finally we converted .exe file. but while executing script , how to close or eixt or quit entire .exe file , if havning any function , please inform me.

 

Thanks,

Sat6804

Posted

Think your question belongs in a different section of the Forum.

One answer to your question is maybe.....look at the function EXIT() 

Really need some sample (or the whole) of the code you have for the correct answer.

Posted (edited)

If your editing F5 = GO and CTRL+BREAK stops executing.

You can also create a hotkeyset as noted above. Basically, you put it in your script, identify the key and point it to a simple function. I'll give you an example...

HotKeySet("{ESC}", "Terminate")

Func Terminate()
    Exit
EndFunc   ;==>Terminate

 

Edited by fixitrod
Adding more information. Didn't want to make excessive posts
Posted (edited)

hi ,

I used the below code, for comparing pdf file and created same code with 50 .exe file , If any error occurs in this below code . how to quit or close or exit  particular auto it .exe file. If any one know answer please share it..

#include <File.au3>
#include <Excel.au3>
#include <MsgBoxConstants.au3>

Func _FindStrInFile($File, $String)
    If Not FileExists($File) Then Return -1
    Local $fOpen = FileOpen($File, 0), $LineCount = 0
    Dim $ret[2]
    While 1
        $LineCount += 1
        $CurrentLine = FileReadLine($fOpen)
        If @error = -1 Then ExitLoop
        If StringInStr($CurrentLine, $String) Then
            $ret[0] = $CurrentLine
            $ret[1] = $LineCount
        EndIf
    WEnd
    Return $ret
EndFunc    ;==>_FindStrInFile

$file1 = "E:\Automation\testing\AutoIT\Report.xls"
Local $oExcel1 = _ExcelBookOpen($file1)
For $j = 16 To 16 ;Loop
    $sCellValue8 = _ExcelReadCell($oExcel1, $j, 8)
Next
_ExcelBookClose($oExcel1)

$file2 = "E:\Automation\testing\Validation.xls"
Local $oExcel2 = _ExcelBookOpen($file2)
_ExcelSheetActivate($oExcel2, "process")

For $j = 2 To 2 ;Loop
    $sCellValue2 = _ExcelReadCell($oExcel2, $j, 3)
Next

For $k = 3 To 3 ;Loop
    $sCellValue3 = _ExcelReadCell($oExcel2, $k, 3)
Next

For $l = 4 To 4 ;Loop
    $sCellValue4 = _ExcelReadCell($oExcel2, $l, 3)
Next

For $m = 5 To 5 ;Loop
    $sCellValue5 = _ExcelReadCell($oExcel2, $m, 3)
Next

For $n = 6 To 6 ;Loop
    $sCellValue6 = _ExcelReadCell($oExcel2, $n, 3)
Next

For $o = 7 To 7 ;Loop
    $sCellValue7 = _ExcelReadCell($oExcel2, $o, 3)
Next
_ExcelBookClose($oExcel2)

If ($sCellValue8 == "completed") Then
    Run("C:\Program Files\Adobe\Acrobat 10.0\Acrobat\Acrobat.exe")
    WinWaitActive("Adobe Acrobat Pro", "")
    Send("!V")
    Send("{Down 11}")
    Send("{enter}")
    WinWaitActive("Compare Documents", "")
    Send("!s", "{enter}")
    WinWaitActive("Open", "")
    Sleep(1000)
    Send($sCellValue2)
    Send("!O", "{ENTER}")
    WinWaitActive("Compare Documents", "")
    Send("!e", "{enter}")
    WinWaitActive("Open", "")
    Sleep(1000)
    Send($sCellValue3)
    Send("!O", "{ENTER}")
    WinWaitActive("Compare Documents", "")
    Send("!R", "Check")
    Send("!O", "{enter}")
    Sleep(10000)
    WinWaitActive("[CLASS:AcrobatSDIWindow]", "")
    Send("!F")
    Send("{Down 3}")
    Send("{Right}", "!P")
    Send("{Down 8}")
    Send("{Right}", "!A")
    Send("{Down 8}")
    Send("{enter}")
    Sleep(1000)
    Send($sCellValue4)
    Send("!O")
    Send("{enter}")
    Send("{TAB 2}")
    Send("!S", "{enter}")
    If Send("!Y", "{enter}") Then
    EndIf
    WinWaitActive("[CLASS:AcrobatSDIWindow]", "")
    WinClose("[CLASS:AcrobatSDIWindow]")
    Send("!Y")
    Sleep(1000)
    Send($sCellValue5)
    Send("!O")
    Send("{enter}")
    Send("{TAB 2}")
    Send("!S", "{enter}")
    If Send("!Y", "{enter}") Then
    EndIf


    $String = "Differences exist between documents"
    $File = $sCellValue6
    $read = FileRead($File)

    $FindArr = _FindStrInFile($File, $String)
    If IsArray($FindArr) And $FindArr[0] <> "" Then
        $sFilePath1 = @ScriptDir & $sCellValue7
        If FileExists($sFilePath1) Then ;This file should already exist
            Local $oExcel = _ExcelBookOpen($sFilePath1)
        Else
            Local $oExcel = _ExcelBookNew()
        EndIf


        _ExcelWriteCell($oExcel, "PASS", 16, 11)
        _ExcelWriteCell($oExcel, $read, 16, 10)


        _ExcelBookSaveAs($oExcel, @ScriptDir & $sCellValue7, "xls", 0, 1)

          ; close excel book
        _ExcelBookClose($oExcel)

    ElseIf $FindArr <> -1 Then
        $sFilePath1 = @ScriptDir & $sCellValue7
        If FileExists($sFilePath1) Then ;This file should already exist
            Local $oExcel = _ExcelBookOpen($sFilePath1)
        Else
            Local $oExcel = _ExcelBookNew()
        EndIf

        _ExcelWriteCell($oExcel, "FAIL", 16, 11)
        _ExcelWriteCell($oExcel, $read, 16, 10)

          ; Save file into Script directory; overwrite existing file if necessary
        _ExcelBookSaveAs($oExcel, @ScriptDir & $sCellValue7, "xls", 0, 1)

        _ExcelBookClose($oExcel)
    ElseIf $FindArr = -1 Then
        MsgBox(48, "Results", "The file <" & $File & "> was not found")
    EndIf

Else
    $sFilePath8 = @ScriptDir & $sCellValue7
    If FileExists($sFilePath8) Then ;This file should already exist
        Local $oExcel4 = _ExcelBookOpen($sFilePath8)
    Else
        Local $oExcel4 = _ExcelBookNew()
    EndIf
    _ExcelWriteCell($oExcel4, "FAIL", 16, 11)
    _ExcelWriteCell($oExcel4, "PDFFileNotExist", 16, 10)
    _ExcelBookSaveAs($oExcel4, @ScriptDir & $sCellValue7, "xls", 0, 1)
    _ExcelBookClose($oExcel4)
EndIf

 

Edited by Jos
added codebox
Posted (edited)
  1. please be so kind and use the code Tag.
  2. Use the actual Excel.udf
  3. why send to automate acrobat (i'll never test a programm which tries to automate acrobat in this way)
Edited by AutoBert

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
×
×
  • Create New...