All Activity

even more strange... as @argumentum suggested, tryed a WatchDog way by spawn a process detached from the main script. (I can see that there are 2 processes with 2 different Pid in task manager) the whole works OK even if compiled, but if I force the close of the command prompt window of the main exe, then also the detached exe is closed as well (shouldn't the detached exe continue to run??)
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseX64=y
#AutoIt3Wrapper_Change2CUI=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#pragma compile(AutoItExecuteAllowed, true)
Local $hPid = ShellExecute('notepad.exe')
_WatchDog_OnAutoItExitRegister()
MsgBox(0, "Demo", "press ok to exit (and let notepd be closed by the watchdog)")
Func _WatchDog_OnAutoItExitRegister()
; prepare the "On exit" script (it must stay all in one line)
Local $sCommand = "Local $WatchDog = ProcessWaitClose($CmdLine[1]), $Dummy = ProcessClose($CmdLine[2]) + MsgBox(0,'WatchDog','All done! ... woof woof!' )"
; adjust quotes if needed
;https://www.autoitscript.com/forum/topic/181491-question-about-autoit3executeline/?do=findComment&comment=1303199
$sCommand = '"' & StringReplace($sCommand, '"', '""') & '"'
; unleash the "WatchDog"
; the @AutoItPID passed here is the Pid of the "main" script (not the pid of the detached script)
Run(@AutoItExe & ' /AutoIt3ExecuteLine ' & $sCommand & ' ' & @AutoItPID & ' ' & $hPid)
EndFunc ;==>_WatchDog_OnAutoItExitRegister

here the problem described by op also arises. (Win7 x64),
as suggested by @argumentum better to insert a delay of few seconds within the do ... Until $text = 5 loop so to give time to notepad to start, and also allow users to force the close of the command prompt window.
When I force the close of the command prompt window, (before the script ends by himself) the notepad is not killed by the OnAutoItExitRegister function.

@TheSaint. Cool UDF. I figured I would offer a suggestion if you have not already found out how to get the other browsers to work. If I were in your shoes, I would use a tool like Nirsoft's reg from app tool or registry changes view tool to determine which registry keys are responsible for setting each browser as the "default browser" by actually recording the change that is made. Just a thought

Hello all. So I have some questions concerning the OnAutoItExitRegister function. I see the help file takes the time to explain how the exit code and exit method can be retrieved from macro values and even defines some of the methods, but my question is are the methods that the help file defines the only methods that autoit can detect? Allow me to elaborate: consider the below script, which was compiled as a CUI script rather than a GUI script:
; *** Start added by AutoIt3Wrapper ***
#include <AutoItConstants.au3>
; *** End added by AutoIt3Wrapper ***
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseX64=y
#AutoIt3Wrapper_Change2CUI=y
#AutoIt3Wrapper_Res_SaveSource=y
#AutoIt3Wrapper_Res_Language=1033
#AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator
#AutoIt3Wrapper_Add_Constants=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.15.0 (Beta)
Author: myName
Script Function:
Template AutoIt script.
#ce ----------------------------------------------------------------------------
; Script Start - Add your code below here
OnAutoItExitRegister ( "endproc" )
ShellExecute ( "notepad.exe" )
$text = 0
Do
$text = $text + 1
; Do stuff
Until $text = 5
; Do more stuff here
Func endproc ()
Do
ProcessClose ( "notepad.exe" )
Until Not ProcessExists ( "notepad.exe" )
EndFunc
This script is not the exact same as the one I am working with, but it will still help me illustrate the nature of my question/problem. The main difference between this script and the one I am working with is that the contents inside the "Do...Until" loop are very unlikely to satisfy the condition that would allow the loop to exit (its monitoring if a web site is online and will only exit the loop if the code in the loop indicate the site has gone down). That being the case, the scenario which is much more likely is that the script will be closed by me when I close the command prompt (either by clicking the "x" or using the keyboard "ctrl + c"). However, when I exit the application in this way, the contents of the function that I defined in the "OnAutoitExitRegister" function do not appear to be executing, as notepad remains open after the script has stopped running. Why is this? I am guessing compiling the script as a cui rather than a gui might have something to do with it, but is there a way for autoit to register a function when a cui script is closed in either of the ways I described above. I look forward to your feed back.

Well, I have a location on one of our servers in the LAN and on every start the local version is compared to the version on the server.
General way of updating the compiled exe is:
rename current exe to _old.exe (yes, the exe file is able to rename itself)
copy the new exe to the local computer
run the new exe
Func Updateholen()
Local $updatepfad = "\\server\myprogram\" ; Folder to get the Updates
Local $updatequelle = $updatepfad & "myfile.exe" ; FileName to check for
Local $tmp1 = ""
Local $tmp2 = ""
If FileExists(@ScriptDir & "\myfile_old.exe") Then FileDelete(@ScriptDir & "\myfile_old.exe") ; delete possibly existing old version
If Not @Compiled Then Return ; only try to update if started as a compiled exe
If @AutoItX64 = 1 Then $updatequelle = $updatepfad & "myfile_x64.exe"
If Not Ping("server", 50) Then Return ; if server is not online, update can not be retrieved
If FileExists($updatequelle) Then
$tmp1 = FileGetTime($updatequelle, 0, 1)
$tmp2 = FileGetTime(@AutoItExe, 0, 1)
If $tmp1 > $tmp2 Then
; rename the currently running exe file
$tmp1 = FileMove(@AutoItExe, @ScriptDir & "\userinfo_alt.exe")
If $tmp1 <> 1 Then
MsgBox(16, "Problem", "Could not rename the running exe")
Exit
EndIf
; copy the new exe file to our PC
$tmp1 = FileCopy($updatequelle, @AutoItExe)
If $tmp1 <> 1 Then
MsgBox(16, "Problem", "Could not copy the update")
Exit
EndIf
; notify user about the update and display version history
If FileExists($updatepfad & "history.htm") Then ShellExecute($updatepfad & "history.htm")
Run(@AutoItExe)
Exit
EndIf
EndIf
EndFunc ;==>Updateholen

Hello every one,
I have a small question is: With a large amount of data, if I use StringSplit to convert it to Array then use ArrayFindAll to find or just leave it as a string and use StringInStr to find which is effective than? And the fastest?
Thanks.

Hi and thanks for this excellent UDF! Gonna extensively use it in a BIG project I'm working on...
Juste one "cosmetics" little comment: I'm I the only one that don't like the Icon placement in the window?
I think it should be:
If Icon height > textHeight: vertically centered on the text's center
If Icon height <= textHeight: Icon.X = text.X

Why would you want to? If you're writing Python, write Python. If you're writing AutoIt, write AutoIt. If you have a situation where you simply cannot get away from mixing and matching languages (doubtful) a little more explanation would be wonderful.

I should have shown the previous line. There is a local variable $guitmsg =GuiGetMsg() that is being called. Your example lets me reduce an extra line that is not needed. Thanks.
I added that so the application and GUI could be exited when I was testing with a mouse.