Jump to content
Sign in to follow this  

Redirect exit code of the AutoIt window

Recommended Posts


Here is a script which destroys the AutoIt Window, there is many issues that can understand and fix except that the application won't exit with the Exit code.

Is there any way to "redirect" the exit code to terminate the application?

There should be a main function in the internal autoit code, no way to make it exit?

Here is the script :

;you will need to kill the autoit3 process.

#include <WinAPI.au3>
#include <Constants.au3>
#include <WindowsConstants.au3>

Global $_hWndProc = DllCallbackRegister("WM_HANDLER", "int", "hwnd;int;wparam;lparam")

$hWnd = WinGetHandle("Wndtmp_")

_WinAPI_SetWindowLong($hWnd, $GWL_WNDPROC, DllCallbackGetPtr($_hWndProc))
;also destroys:
;tray icon, hotkeys, wm messages (in particular Exit), more things?

Exit ;does not work

Func WM_HANDLER($hWnd, $iMsg, $wParam, $lParam)
    Switch $iMsg
        Case $WM_CLOSE
            Return False

    Return _WinAPI_DefWindowProc($hWnd, $iMsg, $wParam, $lParam)
EndFunc   ;==>WM_HANDLER

My purpose for this is insignificant, but I would be interested to know if it's possible.

Br, FireFox.

Edited by FireFox


OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control


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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Jahar
      I have an AutoIT script It monitors 2 websites for content that applys to me and the services that I provide. One site is : www.Freelancer.com The other: www.PeoplePerHour.com Both sites publish new jobs on their site hourly or so. My AutoIT app, will view those sites and present new jobs to me in a grid that pops up on my screen. Lately, the app has stopped showing me any jobs from PeoplePerHour.
      For freelancer.com,  Inetget is giving full html but for peopleperhour, now its not coming.
      Func _CheckPPH()
          Local Static $hTimer = 0
          Local Static $hDownload = 0
          Local $aTitlesandUrls = 0
          Local Static $sTempFile = ""
          If $hTimer = 0 Then $hTimer = TimerInit()
          If $hDownload = 0 Then
              $sTempFile = _WinAPI_GetTempFileName(@TempDir)
              ConsoleWrite("Checking PPH..." & @CRLF)
              ConsoleWrite(">Downloading..." & @CRLF)
      ;~         $hDownload = InetGet("http://www.peopleperhour.com/freelance-jobs", $sTempFile, $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)
              $hDownload = InetGet("http://www.peopleperhour.com/freelance-jobs", $sTempFile, $INET_FORCERELOAD)
      ;~         Return 0
      ;~     Sleep(30)
      ;~     Local $isCompleted = InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)
      ;~     Local $isError = InetGetInfo($hDownload, $INET_DOWNLOADERROR)
      ;~     Sleep(30)
      ;~     If TimerDiff($hTimer) > 3000 And $isError Then
      ;~         ConsoleWrite("!PPH Fail" & @CRLF)
      ;~         InetClose($hDownload)
      ;~         $hDownload = 0
      ;~         Return 0
      ;~     EndIf
      ;~     Sleep(30)
          Local $Show = 0
      ;~     If TimerDiff($hTimer) > 3000 And $isCompleted Then
          If $hDownload > 0 Then
              ConsoleWrite("+Downloaded..." & @CRLF)
              Local $sPPHHtml = FileRead($sTempFile)
              $aTitlesandUrls = _StringBetween($sPPHHtml, '"title">' & @LF, 'time>')
      ;~         _ArrayDisplay($aTitlesandUrls)
              Local $aPPH[0][4]
              Local $sTitle = ""
              Local $sUrl = ""
              Local $sID = ""
              Local $sDate = ""
              Local $iRet=0
              For $i = 0 To UBound($aTitlesandUrls) - 1
                  $sTitle = _StringBetween($aTitlesandUrls[$i], '<a title="', '" class')
                  $sUrl = _StringBetween($aTitlesandUrls[$i], 'href="', '">')
                  $sDate = _GetDate($aTitlesandUrls[$i])
                  If IsArray($sTitle) And IsArray($sUrl) Then
                      $sID = _GetID($sUrl[0])
      ;~                 _ArrayAdd($aPPH, $sDate & "|" & $sTitle[0] & "|" & $sUrl[0] & "|" & $sID)
                      $iRet = _BuildPopupsPPH($sID, $sDate, "PPH: " & $sTitle[0], $sUrl[0])
                      If $iRet Then $Show+=1
      ;~         If $Show > 0 Then ShowLatestJobs()
      ;~         _ArrayDisplay($aPPH)
              $hDownload = 0
              $hTimer = 0
              Return $Show
      EndFunc   ;==>_CheckPPH
    • By malicioussoap
      back when I was still doing autohotkey you could write (in code) spanisha::á
      and whenever you were in google docs or notepad you could type (in the document) spanisha  and it instantly turns it into á 
      I tried doing this in autoit, here's what I have so far (my entire code so if this language requires a main function or a return/exit to function properly please let me know):
      ;is this a proper comment? HotKeySet ( "spanisha" , "SendAltered" ) Func SendAltered() Send("á", flag = 0); EndFunc I assume that autoit follows a sort of contemporary hotkey pressing model where you have to hold all keys at the same time? which makes this impossible. So
      I'm wondering if anyone has a workaround for this? or maybe an alternative to HotKeySet()
      I have a vague memory of someone saying that doing something like spanisha:á would work. I don't know if I'm slightly off syntax but this doesn't work.
      Also I tried doing 
      ;is this a proper comment? ;HotKeySet ( "a" , "SendAltered" ) ;spanisha::á Func SendAltered() Send("á"); EndFunc just to try and debug,
      I'm also wondering if my approach is fundamentally wrong since HotKeySet() was made for something like !^A. Or if Send() is syntactically wrong.
      I'm also noticing on these forums that specifying installation is important so to whom it may concern I downloaded both installers, editor and main files. Although I'm about to be real mad if the editor installation makes a difference.
    • By shelly
      I have to press tab to reach a selected button then double click on that
      Here's my script but its not working:
      WinActivate("Policy Decisions -- Webpage Dialog","")
      Send("{TAB}")                    // at this point its working according to my need  but double click is not working
      Mouseclick("Left",510, 320, 2, 0)

    • By TheDcoder
      See this thread for info:
    • By Dan_555
      i'v just uploaded my latest project: Simple Snippet Manager to the Downloads. area :


       The intended usage is to select a Snippet, and to copy it's contents into your favorite Editor.
          The Copy/Paste process happens over the (windows)Clipboard. 
          The previous clipboard content is not restored.
          There is a time limit of 60 seconds, in which the pasting of the text is allowed (starting when the App window gets inactive).  
          The Hotkey is reenabled, when the main Window is activated.
          This is a File/Folder based manager. 
          The App is configured to hold 4000 files and 400 folders with searching depth of 5 sub-folders.
          The root folder is freely selectable, but it  should be a Folder with writing permission.
          Please install the App in a folder with Writing permission, too. 
          This App only uses an .ini file to save it's configuration, which has to be in the same folder as the App.
      First configuration:
      1. Open the config Window.
      2. Enter the Language name, create or seek a root folder, enter an extension.
      3. Click on Set button.
      4. Click on the Exit button.
      The Language configuration is done, adding files or folders are needed:
       1. Select the language from the dropbox list, and click on Get Lang button.
      2a. Right Click on the root folder, chose New folder to add categories.
      2b. or chose New/Edit file to open the builtin text editor
       3. Paste or Write a snippet-code, enter a filename and save it.
       (Repeat the 3. as needed)
      Select a language, then click on Get Lang button.
      Choose a file with the left mouse button.
      Check if the code was loaded in the Textarea at the bottom.
      Switch to your Sourcecode editor, and press the Hotkey (default= Ctrl/Strg b) to copy and paste the text.
      There is a time limit of 60 seconds, after the main window gets inactive, in which the copy&pasting is allowed.
      V1.02        (24.06.2020)
                  Addition: Undocumented ini setting: StartLoadLastUsedLanguage
                            Setting this to 1 (default value) will now reload the Last used language at start.
                            Last used language counts for the Language, selected with [Get Lang] button. The [Config] button will delete the last used language.
                            LastUsedLanguageNr, LastUsedLanguageName ini settings are used internaly for the above function.
                   Added version string to the main Window title.
      V1.01        (23.06.2020)
                  Bugfix    : Starting the App without the ini file now sets the correct starting Hotkey (Ctrl b)
                  Addition: Clipboard is saved, before pasting, and restored after pasting. (May work with text data only. p.s. untested!)
  • Create New...