sat6804

how to close ,quit or exit autoit script .exe files

8 posts in this topic

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

Share this post


Link to post
Share on other sites



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.

Share this post


Link to post
Share on other sites

hi,

If any error occurs ,the code( .exe) file should be exit automatically.

Share this post


Link to post
Share on other sites

Is there a question in there and what kind of error are you talking about as AutoIt3 will exit always on any syntax error?

Jos

 


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

Share this post


Link to post
Share on other sites

#6 ·  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

Share this post


Link to post
Share on other sites

#7 ·  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

Share this post


Link to post
Share on other sites

#8 ·  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

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

  • Similar Content

    • nassausky
      By nassausky
      Hi all,
       
      Anyone have any idea how to close all open tabs except a specific one I manually open.  Assuming I don't know what is open in all the tabs except just the one I want to keep open.
       
      I didn't want to use sendkeys and I was trying to use the following code to list the title (or url) of the 3 open tabs and  after I got that part working I would just close the other 2. This sample only displays the title of the first open tab
      #include <IE.au3> Const $ie_new_in_tab = 0x0800 $oIE = _IECreate("https://www.autoitscript.com") __IENavigate($oIE, "https://www.autoitscript.com/forum/", 1, $ie_new_in_tab) ;(obj,url,wait,param) __IENavigate($oIE, "https://www.google.com/", 1, $ie_new_in_tab) ;(obj,url,wait,param) Local $aIE[1] $aIE[0] = 0 Local $i = 1, $oIE While 1     $oIE = _IEAttach("", "instance", $i)     If @error = $_IEStatus_NoMatch Then ExitLoop     ConsoleWrite(_IEPropertyGet($oIE, "title") & @CRLF)     ReDim $aIE[$i + 1]     $aIE[$i] = $oIE ;each item holds object     $aIE[0] = $i ;first item holds count     $i += 1 WEnd MsgBox($MB_SYSTEMMODAL, "Browsers Found", "Number of browser instances in the array: " & $aIE[0]) ; This doesn't return the list of tabs in the console just the first tab  
      Thanks for any and all help
    • FrancescoDiMuro
      By FrancescoDiMuro
      Good morning guys
      I was trying to not open another post, writing here my little issue, but seems that no one cares about, and so, I'm opening another post
      What I'm trying to do, is detect the event close sent from the virtual keyboard.
      Why?
      Because, I have an application which, when I set the focus on a textbox, if the virtual keyboard does not exist, then it is created, else, it's not created
      But, everytime I try to close the virtual keyboard, the focus remains on the textbox, and another $EN_FOCUS event it's launched and detected from my WM_COMMAND, and so, the virtual keyboard is opened again. 
      How can I solve this little "issue"? 
      I was trying to detect the event sent from the virtual keyboard, storing the handle of it in a variable, and setting:
      GUISetOnEvent($GUI_EVENT_CLOSE, "CloseVK", $hVirtualKeyboard) without any result.
      Can someone please help me?
      Thanks  
      EDIT:
      Here I'd like to see @Melba23, @water, @Danyfirex...
       
    • salah kai
      By salah kai
      Hey everyone
      i wanna close a process by  path like
      C:\Users\salah\AppData\Local\Temp\a.exe
      processclose(C:\Users\salah\AppData\Local\Temp\a.exe)
      i tried to split the path but i don't know how to know last loop
      and thanks 
       
    • InunoTaishou
      By InunoTaishou
      When creating an mdi child using _WinApi_SetParent the close event for the parent is not run until the child window is closed. Is there any way to close the child windows when the parent's close button is pressed? It seems that when you close from the task bar the parent close function is run first.
      #include <WinAPI.au3> #include <GUIConstants.au3> Opt("GUIOnEventMode", 1) Global $hParent = GUICreate("Parent", 800, 600) Global $hChild = GUICreate("Child", 300, 200, 0, 0) _WinAPI_SetParent($hChild, $hParent) GUISetState(@SW_SHOW, $hParent) GUISetState(@SW_SHOW, $hChild) GUISetOnEvent($GUI_EVENT_CLOSE, CloseWinParent, $hParent) GUISetOnEvent($GUI_EVENT_CLOSE, CloseWinChild, $hChild) While (True) Sleep(100) WEnd Func CloseWinParent() ConsoleWrite("CloseWinParent" & @LF) GUIDelete($hParent) Exit 0 EndFunc Func CloseWinChild() ConsoleWrite("CloseWinChild" & @LF) GUIDelete($hChild) EndFunc Also, looking at the help file
      This is wrong. I've used _WinApi_SetParent in the past to set autoit created programs to the child of other programs. Perhaps it was like this in the past but Windows 7 and greater different applications can be child and parent.
    • masterlink950
      By masterlink950
      Hello, First off, I want to say that I very much appreciate the hard work that people put in to replying on these forums and helping newbs. I've gotten 99% of my answers through google, forum searches, and documentation.
      Okay, so. I'm actually sure this has been asked before, but I wasn't able to find anything and I'm having some difficulty.
      I want to delete tabs in a control with a middle click (or specifically, detect when a tab has been middle-clicked).
      Initially I was going to try to use GUIGetCursorInfo along with checking for a middle-click, the problem is, when the cursor is over a tab, it simply returns the ID of the whole control (I'm using the native tab functionality).
      If I can avoid it, I REALLY don't want to manually check coordinates of tabs when the middle mouse is clicked, as tabs are going to be generated dynamically (anywhere from one to infinity tabs if the user lets things get out of hand), and the window I'm using will be resizable (thus having to run checks if a tab is out of view, etc), but I can if I have no other choice.
       
      So basically, Is there either 1: a simple native/UDF way to detect middle-click on tabs, 2: a way to get GUIGetCursorInfo give the control ID of the tab itself instead of the control, or 3: something I haven't thought of all together?
      Thanks in advance!