Jump to content
sat6804

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

Recommended Posts

sat6804

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
Jos

Under which condition would you want to stop the script?

e.g. Pressing a specific key? ==> HotKeySet()

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
lewisg

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
sat6804

hi,

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

Share this post


Link to post
Share on other sites
Jos

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
fixitrod

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
sat6804

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
AutoBert
  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

    • Miliardsto
      By Miliardsto
      Hello I got problem with final program .exe closing on windows 7 ultimate 64bit. It starts , icon shows on toolbar and program exit.
      I have seen things like that before but it was caused by AV. There is no AV and UAC and firewall off.
      Maybe is there needed any microsoft library or etc or whatever?
       
    • XinYoung
      By XinYoung
      For fun, I'm building an app that opens a webpage and refreshes it every 30 seconds.
      But once the script performs _IEAction($oIE, "refresh"), the GUI closes.
      Any help is appreciated.
       

      #include <ButtonConstants.au3>
      #include <EditConstants.au3>
      #include <GUIConstantsEx.au3>
      #include <StaticConstants.au3>
      #include <WindowsConstants.au3>
      #include <WinAPIFiles.au3>
      #include <Array.au3>
      #include <File.au3>
      #include <Excel.au3>
      #include <DateTimeConstants.au3>
      #include <MsgBoxConstants.au3>
      #include <WinAPIShellEx.au3>
      #include <MsgBoxConstants.au3>
      #include <Date.au3>
      #include <ComboConstants.au3>
      #include <guimenu.au3>
      #include <IE.au3>
      HotKeySet("{F4}", "_Exit")
      ;Open the file(s) in the selected folder
      $extension = ".txt"
      $app2openWith = @SystemDir & "\notepad.exe"
      Func Begin()
          Global $loopTrick = 0
          #Region ### START Koda GUI section ### Form=c:\users\mchu\downloads\autoit\my code\form1.kxf
          Global $UI = GUICreate("Hit Em Up!", 256, 113, -1, -1)
          GUISetBkColor(0x000000)
          $menu = _GUICtrlMenu_GetSystemMenu($UI)
          _GUICtrlMenu_EnableMenuItem($menu, $SC_CLOSE, 1, False)
          Global $url = GUICtrlCreateInput("https://www.youtube.com/watch?v=dQw4w9WgXcQ", 81, 8, 160, 21)
          $Label1 = GUICtrlCreateLabel("Target:", 16, 8, 55, 17)
          GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
          GUICtrlSetColor(-1, 0x00FF00)
          Global $StartBut = GUICtrlCreateButton("Start", 16, 40, 67, 25)
          GUICtrlSetFont(-1, 13, 800, 0, "MS Sans Serif")
          GUICtrlSetBkColor(-1, 0x008000)
          $Label2 = GUICtrlCreateLabel("(Press F4 to Exit)", 96, 40, 8000, 17)
          GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
          GUICtrlSetColor(-1, 0x00FF00)
          GUISetState(@SW_SHOW)
          #EndRegion ### END Koda GUI section ###
          While 1
              $UIfunc = GUIGetMsg()
              Select
                  Case $UIfunc = $GUI_EVENT_CLOSE
                      _Exit()
                  Case $UIfunc = $StartBut
                      If GUICtrlRead($url) = "" Then
                          MsgBox(48, "Um...", "Give me a target you idiot.")
                      Else
                          GUICtrlSetState($url, $GUI_DISABLE)
                          GUICtrlSetState($StartBut, $GUI_DISABLE)
                          Start()
                      EndIf
              EndSelect
          WEnd
      EndFunc   ;==>Begin
      Func Start()
          If $loopTrick = 0 Then
              Global $oIE = _IECreate(GUICtrlRead($url))
              _IELoadWait($oIE)
              Again()
          ElseIf $loopTrick = 1 Then
              Sleep(3000)
              _IEAction($oIE, "refresh")
              Sleep(3000)
              Start()
          EndIf
      EndFunc   ;==>Start
      Func Again()
          $loopTrick = 1
          Start()
      EndFunc   ;==>Again
      Func _Exit()
          Exit
      EndFunc   ;==>_Exit
    • 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 
       
×