Jump to content

All Activity

This stream auto-updates     

  1. Today
  2. Yesterday
  3. Update. After more troubleshooting i found a combo-box items only generate it's list after it has been opened. A workaround for this is the code below which opens / closes the combo but doesn't take focus. ; --- Find window/control --- ConsoleWrite( "--- Find window/control ---" & @CRLF ) Local $pCondition0 $oUIAutomation.CreatePropertyCondition( $UIA_AutomationIdPropertyId, "cmbAddressType", $pCondition0 ) If Not $pCondition0 Then Return ConsoleWrite( "$pCondition0 ERR" & @CRLF ) ConsoleWrite( "$pCondition0 OK" & @CRLF ) Local $pComboBox1, $oComboBox1 $oWindow1.FindFirst( $TreeScope_Descendants, $pCondition0, $pComboBox1 ) $oComboBox1 = ObjCreateInterface( $pComboBox1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oComboBox1 ) Then Return ConsoleWrite( "$oComboBox1 ERR" & @CRLF ) ConsoleWrite( "$oComboBox1 OK" & @CRLF ) Local $pInvoke, $oInvoke $oComboBox1.GetCurrentPattern( $UIA_LegacyIAccessiblePatternId, $pInvoke) $oInvoke = ObjCreateInterface( $pInvoke, $sIID_IUIAutomationLegacyIAccessiblePattern, $dtagIUIAutomationLegacyIAccessiblePattern ) If Not IsObj( $oInvoke ) Then Return ConsoleWrite( "$oInvoke ERR" & @CRLF ) ConsoleWrite( "$oInvoke OK" & @CRLF ) $oInvoke.DoDefaultAction() $oInvoke.DoDefaultAction() I also found using the Legacy Select lets me select my item without taking focus. I don't know why it needed the number 3 but without it didn't work ^^. ;Find List Item Local $pCondition4 $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "Do it later", $pCondition4 ) If Not $pCondition4 Then Return ConsoleWrite( "$pCondition4 ERR" & @CRLF ) ConsoleWrite( "$pCondition4 OK" & @CRLF ) Local $pListItem1, $oListItem1 $oComboBox1.FindFirst( $TreeScope_Children, $pCondition4, $pListItem1 ) $oListItem1 = ObjCreateInterface( $pListItem1, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oListItem1 ) Then Return ConsoleWrite( "$oListItem1 ERR" & @CRLF ) ConsoleWrite( "$oListItem1 OK" & @CRLF ) Local $pInvoke, $oInvoke $oListItem1.GetCurrentPattern( $UIA_LegacyIAccessiblePatternId, $pInvoke) $oInvoke = ObjCreateInterface( $pInvoke, $sIID_IUIAutomationLegacyIAccessiblePattern, $dtagIUIAutomationLegacyIAccessiblePattern ) If Not IsObj( $oInvoke ) Then Return ConsoleWrite( "$oInvoke ERR" & @CRLF ) ConsoleWrite( "$oInvoke OK" & @CRLF ) $oInvoke.Select(3) One random question! Can IUI enable/disable controls similar to ControlEnable/ControlDisable?
  4. Another possible solution. #AutoIt3Wrapper_Change2CUI=y ShellExecute("notepad.exe") Global $g_cbHandler = DllCallbackRegister(_HandlerRoutine, "BOOL", "DWORD") ;~ https://docs.microsoft.com/en-us/windows/console/setconsolectrlhandler DllCall("kernel32", "BOOL", "SetConsoleCtrlHandler", "PTR", DllCallbackGetPtr($g_cbHandler), "BOOL", True) ProcessWaitClose(@AutoItPID) Func _HandlerRoutine($dwCtrlType) ProcessClose("notepad.exe") EndFunc
  5. What I've done to run scripts on executable programs and click-click the windows, is to have a console user auto-login and run my scripts from there. When I need to interact with the session, I shadow it. All this is done in a vm where no one can plug a monitor or keyboard to it, as is a vm. Maybe you can do this setup, and not even worry that the untended PC rebooted or what not, since the session will always run if the vm is turned on. My 2 cents PS: I even wrote me a script to make it simpler ( https://www.autoitscript.com/forum/files/file/477-rdpshadow-utility/ )
  6. No the less, this last post is pretty spot on. Jos
  7. ..I don't mean to be .. that you're thinking. In my view, regarding online stuff, I don't trust blindly any of it. I can not know when a heartbeat bug or a breach will occur. And I can not give more examples, as I could get in trouble by just hinting. I rather have RDP access in house, and as unusual as possible.
  8. I don't try, I say. As far as understanding, I can not make you understand ...and the OP question is answered, so no more chatting on this thread from me.
  9. Don't forget, you can do all of this in Python if you needed to, you only need to import PyAutoGUI to do a lot of the automation you can do in AutoIt. You could make a wrapper for it that mimics AutoIt's functions if you REALLY wanted to.
  10. What CUI are you talking about? The AutoIt hidden window? That's not a "CUI" that's there on every script that gets run, whether or not you use CUI mode or not. The 2 things aren't the same.
  11. ..visually, a CUI, it looks like a window. So the inexperienced may see a window, not knowing that is a different animal altogether.
  12. They are compatible with each other, I've used AdLib function in an OnEvent style script many times.
  13. I don't understand at all what you're trying to say here, or in the comments in your script. BTW, script writers are programmers, don't sell yourself short.
  14. ; *** Start added by AutoIt3Wrapper *** #include <AutoItConstants.au3> ; *** End added by AutoIt3Wrapper *** #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Change2CUI=n #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 ;~ ReRun() ; ugly fix ;~ Func ReRun() ;~ If Not @Compiled Then ;~ ConsoleWrite(@CRLF & @CRLF & @CRLF & "!!! compile to run the example !!!" & @CRLF & @CRLF & @CRLF & @CRLF) ;~ Exit 0 ;~ EndIf ;~ If Not StringInStr($CmdLineRaw, "/ErrorStdOut") Then ;~ WinSetState(@ScriptFullPath, "", @SW_HIDE) ;~ Local $errorlevel = ShellExecuteWait(@ScriptFullPath, "/ErrorStdOut " & $CmdLineRaw) ;~ Do ;~ ProcessClose ( "notepad.exe" ) ;~ Until Not ProcessExists ( "notepad.exe" ) ;~ Exit $errorlevel ;~ EndIf ;~ EndFunc ;;; GUI vs. CUI AutoItWinSetTitle(@ScriptFullPath) WinSetState(@ScriptFullPath, "", @SW_SHOW) ;;; if I close the "main" window ;;; OnAutoItExitRegister() behaves as expected ;;; but is not expected that a CUI's frame is ;;; not the "window" of the script. ;;; Then again, we are not programmers =) OnAutoItExitRegister ( "endproc" ) ; replaced by ugly fix ShellExecute ( "notepad.exe" ) Global $text = 0, $sTemp = "" WinActivate(@ScriptFullPath) Do $text = $text + 1 ConsoleWrite('loop # ' & $text & ' of 10'& @CRLF) $sTemp &= 'loop # ' & $text & ' of 10'& @CRLF ControlSetText(@ScriptFullPath, "", "Edit1", $sTemp) ; Do stuff Sleep(2000) Until $text = 10 ; Do more stuff here Func endproc () Do ProcessClose ( "notepad.exe" ) Until Not ProcessExists ( "notepad.exe" ) EndFunc We are scriptwriters, not programmers. Hence, we believe, that the frame we see, is a window 😕 Understood
  15. I've got app that runs predominantly in OnEvent mode (the exceptions are during pop-up style mini-GUIs, when I don't want the normal event handlers to operate). I've registered an Adlib function to periodically run the "main" functionality. I did this to avoid spending too long in any event handler: the event handler sets variables that are tested in the "main" adlib func and processed there. My problem is that the adlib function is never invoked. But before embarking on a debugging project to fix this I though I would simply ask if adlib funcs are compatible with OnEvent mode. If there are not, I've got to find some other method to trigger the main func. Gracias
  16. I feel you should use 127.0.0.1, it works for you.
  17. tatane, Sorry for the delay in replying - busy week in the real world! No idea about the second GUI - nothing in the script should produce that. But here is a better developed script for you to play with - see what you can break this time: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <GUIScrollbars_Size_Test.au3> Global $iMag = 1 Global $iMax_HScroll = 600, $iMax_VScroll = 600 Global $iVSize = _WinAPI_GetSystemMetrics(2) ; Width of VScrollbar: SM_CXVSCROLL Global $iHSize = _WinAPI_GetSystemMetrics(3) ; Height of HScrollbar: SM_CYHSCROLL Global $iH_Pos, $iV_Pos, $bH_Vis = False, $bV_Vis = False ; Set max/min sizes Global $iGUI_MinX = 200, $iGUI_MinY = 200 Global $iGUI_MaxX = $iMax_HScroll + $iVSize, $iGUI_MaxY = $iMax_VScroll + $iHSize + 21 ; Why 21? No idea Global $aLabels[5] $hGUI = GUICreate("Resizeable Test - Mag: 1", 400, 400, Default, Default, $WS_SIZEBOX) GUISetBkColor(0xCCFFCC) Local $cStart = GUICtrlCreateDummy() _DrawLimits($iMax_HScroll, $iMax_HScroll) Local $cEnd = GUICtrlCreateDummy() For $i = $cStart To $cEnd GUICtrlSetResizing($i, $GUI_DOCKALL) Next $cZoom_Minus = GUICtrlCreateButton("Zoom -", 10, 10, 80, 30) $cZoom_Plus = GUICtrlCreateButton("Zoom +", 110, 10, 80, 30) GUISetState(@SW_SHOW) _GUIScrollBars_Init($hGUI) _Set_Scroll_Params($hGUI) GUIRegisterMsg($WM_HSCROLL, "_WM_HSCROLL") GUIRegisterMsg($WM_VSCROLL, "_WM_VSCROLL") GUIRegisterMsg($WM_MOUSEWHEEL, "_WM_MOUSEWHEEL") GUIRegisterMsg($WM_MOUSEHWHEEL, "_WM_MOUSEHWHEEL") GUIRegisterMsg($WM_ENTERSIZEMOVE, "_WM_ENTERSIZEMOVE") GUIRegisterMsg($WM_EXITSIZEMOVE, "_WM_EXITSIZEMOVE") GUIRegisterMsg($WM_GETMINMAXINFO, "_WM_GETMINMAXINFO") While 1 Switch GUIGetMsg() Case $cZoom_Plus $iMag *= 2 $iMax_HScroll *= 2 $iMax_VScroll *= 2 _DrawLimits($iMax_HScroll, $iMax_HScroll) _Set_Scroll_Params($hGUI) WinSetTitle($hGUI, "", "Resizeable Test - Mag: " & $iMag) Case $cZoom_Minus If $iMag > 1 Then $iMag /= 2 $iMax_HScroll /= 2 $iMax_VScroll /= 2 _DrawLimits($iMax_HScroll, $iMax_HScroll) _Set_Scroll_Params($hGUI) WinSetTitle($hGUI, "", "Resizeable Test - Mag: " & $iMag) EndIf Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _Set_Scroll_Params($hWnd) Local $aClientSize = WinGetClientSize($hWnd) ; Check if scrollbars needed Local $iH_Aperture = 0, $iV_Aperture = 0, $iH_Reduction = 0, $iV_Reduction = 0 ; Loop to check if client area reduced by scrollbars For $i = 1 To 2 If $aClientSize[0] < $iMax_HScroll + $iH_Reduction Then $iH_Aperture = $iMax_HScroll + $iH_Reduction $iV_Reduction = $iHSize ; Height of HScrollbar EndIf If $aClientSize[1] < $iMax_VScroll + $iV_Reduction Then $iV_Aperture = $iMax_VScroll + $iV_Reduction $iH_Reduction = $iVSize ; Width of VScrollbar EndIf Next $aRet = _GUIScrollbars_Size($iMax_HScroll, $iMax_VScroll, $aClientSize[0], $aClientSize[1]) If Not @error Then If $iMax_HScroll >= $aClientSize[0] Then ; Show scrollbar _GUIScrollBars_ShowScrollBar($hGUI, $SB_HORZ, True) $bH_Vis = True ; Set new parameters _GUIScrollBars_SetScrollInfoPage($hGUI, $SB_HORZ, $aRet[0]) _GUIScrollBars_SetScrollInfoMax($hGUI, $SB_HORZ, $aRet[1]) ; Reset scrollbar positions If $iH_Aperture Then _GUIScrollBars_SetScrollInfoPos($hWnd, $SB_HORZ, $iH_Pos) EndIf If $iMax_VScroll >= $aClientSize[1] Then _GUIScrollBars_ShowScrollBar($hGUI, $SB_VERT, True) $bV_Vis = True _GUIScrollBars_SetScrollInfoPage($hGUI, $SB_VERT, $aRet[2]) _GUIScrollBars_SetScrollInfoMax($hGUI, $SB_VERT, $aRet[3]) If $iV_Aperture Then _GUIScrollBars_SetScrollInfoPos($hWnd, $SB_VERT, $iV_Pos) EndIf EndIf EndFunc ;==>_Set_Scroll_Params Func _DrawLimits($iMaxH, $iMaxV) For $i = 0 To 4 GUICtrlDelete($aLabels[$i]) Next $aLabels[0] = GUICtrlCreateLabel("", 0, 0, $iMaxH, $iMaxV) GUICtrlSetBkColor(-1, 0xFFCCCC) GUICtrlSetState(-1, $GUI_DISABLE) $aLabels[1] = GUICtrlCreateLabel("", 0, 0, 10, 10) GUICtrlSetBkColor(-1, 0xFF0000) $aLabels[2] = GUICtrlCreateLabel("", 0, $iMaxV - 10, 10, 10) GUICtrlSetBkColor(-1, 0xFF0000) $aLabels[3] = GUICtrlCreateLabel("", $iMaxH - 10, 0, 10, 10) GUICtrlSetBkColor(-1, 0xFF0000) $aLabels[4] = GUICtrlCreateLabel("", $iMaxH - 10, $iMaxV - 10, 10, 10) GUICtrlSetBkColor(-1, 0xFF0000) EndFunc ;==>_DrawLimits Func _WM_HSCROLL($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $lParam Local $iScrollCode = BitAND($wParam, 0x0000FFFF) Local $iIndex = -1, $iCharX, $iPosX Local $iMin, $iMax, $iPage, $iPos, $iTrackPos For $x = 0 To UBound($__g_aSB_WindowInfo) - 1 If $__g_aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $iCharX = $__g_aSB_WindowInfo[$iIndex][2] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 ; ; Get all the horizontal scroll bar information Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_HORZ) $iMin = DllStructGetData($tSCROLLINFO, "nMin") $iMax = DllStructGetData($tSCROLLINFO, "nMax") $iPage = DllStructGetData($tSCROLLINFO, "nPage") ; Save the position for comparison later on $iPosX = DllStructGetData($tSCROLLINFO, "nPos") $iPos = $iPosX $iTrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") #forceref $iMin, $iMax Switch $iScrollCode Case $SB_LINELEFT ; user clicked left arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos - 1) Case $SB_LINERIGHT ; user clicked right arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos + 1) Case $SB_PAGELEFT ; user clicked the scroll bar shaft left of the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos - $iPage) Case $SB_PAGERIGHT ; user clicked the scroll bar shaft right of the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos + $iPage) Case $SB_THUMBTRACK ; user dragged the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iTrackPos) EndSwitch ; // Set the position and then retrieve it. Due to adjustments ; // by Windows it may not be the same as the value set. DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) ;// If the position has changed, scroll the window and update it $iPos = DllStructGetData($tSCROLLINFO, "nPos") If ($iPos <> $iPosX) Then _GUIScrollBars_ScrollWindow($hWnd, $iCharX * ($iPosX - $iPos), 0) Return $GUI_RUNDEFMSG EndFunc ;==>_WM_HSCROLL Func _WM_VSCROLL($hWnd, $Msg, $wParam, $lParam) #forceref $Msg, $wParam, $lParam Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Local $iIndex = -1, $yChar, $yPos Local $Min, $Max, $Page, $Pos, $TrackPos For $x = 0 To UBound($__g_aSB_WindowInfo) - 1 If $__g_aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $yChar = $__g_aSB_WindowInfo[$iIndex][3] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT) $Min = DllStructGetData($tSCROLLINFO, "nMin") $Max = DllStructGetData($tSCROLLINFO, "nMax") $Page = DllStructGetData($tSCROLLINFO, "nPage") $yPos = DllStructGetData($tSCROLLINFO, "nPos") $Pos = $yPos $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") Switch $nScrollCode Case $SB_TOP DllStructSetData($tSCROLLINFO, "nPos", $Min) Case $SB_BOTTOM DllStructSetData($tSCROLLINFO, "nPos", $Max) Case $SB_LINEUP DllStructSetData($tSCROLLINFO, "nPos", $Pos - 1) Case $SB_LINEDOWN DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1) Case $SB_PAGEUP DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page) Case $SB_PAGEDOWN DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page) Case $SB_THUMBTRACK DllStructSetData($tSCROLLINFO, "nPos", $TrackPos) EndSwitch DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) $Pos = DllStructGetData($tSCROLLINFO, "nPos") If ($Pos <> $yPos) Then _GUIScrollBars_ScrollWindow($hWnd, 0, $yChar * ($yPos - $Pos)) $yPos = $Pos EndIf Return $GUI_RUNDEFMSG EndFunc ;==>_WM_VSCROLL Func _WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $lParam Local $iDirn, $iDelta = BitShift($wParam, 16) ; Mouse wheel movement If $hWnd = $hGUI Then If BitAND($wParam, 0x0000FFFF) Then ; If Ctrl or Shft pressed move Horz scrollbar ; Check if max size If $bH_Vis Then $iDirn = $SB_LINERIGHT If $iDelta > 0 Then $iDirn = $SB_LINELEFT For $i = 1 To 7 _SendMessage($hWnd, $WM_HSCROLL, $iDirn) Next EndIf Else ; Move Vert scrollbar If $bV_Vis Then $iDirn = $SB_LINEDOWN If $iDelta > 0 Then $iDirn = $SB_LINEUP For $i = 1 To 7 _SendMessage($hWnd, $WM_VSCROLL, $iDirn) Next EndIf EndIf EndIf Return $GUI_RUNDEFMSG EndFunc ;==>_WM_MOUSEWHEEL Func _WM_MOUSEHWHEEL($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $lParam Local $iDirn = $SB_LINERIGHT If BitShift($wParam, 16) > 0 Then $iDirn = $SB_LINELEFT ; Mouse wheel movement If $hWnd = $hGUI Then ; Check if max size If $bH_Vis Then For $i = 1 To 7 _SendMessage($hWnd, $WM_HSCROLL, $iDirn) Next EndIf EndIf Return $GUI_RUNDEFMSG EndFunc ;==>_WM_MOUSEHWHEEL Func _WM_ENTERSIZEMOVE($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam If $hWnd = $hGUI Then ; Store current scrollbar positions $iH_Pos = _GUIScrollBars_GetScrollInfoPos($hWnd, $SB_HORZ) $iV_Pos = _GUIScrollBars_GetScrollInfoPos($hWnd, $SB_VERT) ; Reset scrollbar positions to 0 _GUIScrollBars_SetScrollInfoPos($hWnd, $SB_HORZ, 0) _GUIScrollBars_SetScrollInfoPos($hWnd, $SB_VERT, 0) ; Hide scrollbars _GUIScrollBars_ShowScrollBar($hWnd, $SB_BOTH, False) $bV_Vis = False $bH_Vis = False EndIf EndFunc ;==>_WM_ENTERSIZEMOVE Func _WM_EXITSIZEMOVE($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam ; Check if handle matches If $hWnd = $hGUI Then _Set_Scroll_Params($hWnd) EndIf EndFunc ;==>_WM_EXITSIZEMOVE Func _WM_GETMINMAXINFO($hWnd, $iMsg, $wParam, $lParam) Local $tagMaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam) DllStructSetData($tagMaxinfo, 7, $iGUI_MinX) ; min X DllStructSetData($tagMaxinfo, 8, $iGUI_MinY) ; min Y DllStructSetData($tagMaxinfo, 9, $iGUI_MaxX) ; max X DllStructSetData($tagMaxinfo, 10, $iGUI_MaxY) ; max Y Return 0 EndFunc ;==>_WM_GETMINMAXINFO M23
  18. @kosamja, Windows has several protection mechanisms against users making changes to system files. and there is a good reason for that. how certain are you that your reason for making changes to system files is better than their reason to prevent that? bare in mind that even if you succeed on your test target, when going to deploy on a larger scale, high percentage of failures is inevitable. i advise you either describe or rethink your purpose in all this, so we may help you find a better - perhaps officially supported - method to achieve your goal.
  19. I read through the entire thread and was looking forward to helping out if possible. But you are right I will just ignore in the future
  20. therefore, the use of Run(@AutoItExe & ' /AutoIt3ExecuteLine ' & ... does not generate a detached process, but in this case, it generates a process that is "child" and still connected to the main script (I thought it was not so). it seems however that using ShellExecute () instead of run (), generates a detached and independent process from the main script. Good to know... here a working version of the WatchDog that works as expected (at least as expected by me) so that if you force the close of the main scipt, the WatchDog still runs and acts as it was programmed to do #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) ShellExecute(@AutoItExe, ' /AutoIt3ExecuteLine ' & $sCommand & ' ' & @AutoItPID & ' ' & $hPid, '', '', @SW_HIDE) EndFunc ;==>_WatchDog_OnAutoItExitRegister
  21. Awesome thank you all I will start working on this and post back.
  22. Hi all, Just to point out that this is a good example of what we mean when we talk about a "check for a few keys being pressed" in this announcement - and so the thread is perfectly legal. M23
  23. Nope, When a computer shuts down, a close messages is send to all "program windows" which will then include the hidden Autoit3 window and a normal close will be performed by AutoIt3 which includes performing the registered functions for Exit. Jos
  24. Ok. While I understand what you are saying, autoit is able to determine if a script exited due to the user logging out or shutting down the machine, right? As far as the executing script is concerned, wouldn't the act of shutting down or logging off the machine be interpreted as "killing the script" as well, @BrewManNH?
  25. So make one exe with all functionality and based on parameter it can start itself and call the function you indicate by parameter. You are having focus to much on your solution instead of detailing requirements. This way its hard to give you a good direction on a solution. Same exe starting many times from itself calling another function shouldnt be that difficult.
  26. That's by design, you aren't exiting the process, you are killing it. There's no way for any program to know you're doing that. OnAutoItExit only works when the program closes normally, you're not closing it normally. There's no bug.
  1. Load more activity
×
×
  • Create New...