Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/21/2024 in all areas

  1. I started to work on this UDF and I'd like to discuss, test and improve it with other interested users. The idea is to create a UDF similar to FTPEx, but to support SFTP protocol. Given that this protocol is not natively supported by Windows, I found some candidates to manage it: cURL: http://curl.haxx.se/ PSFTP: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html FZSFTP: http://filezilla-project.org/ I'm trying to use the second one (realied by PuTTY team) and the result is the following code. It is not complete and needs to be widely tested, but main functions work and could be considered as a draft to start the discussion. A possible alternative could be to use FZSFTP (a modified version of PSFTP realized for FileZilla), that includes some interesting improvements to be used by external programs, but does not offer a related documentation. Code version: 1.0 beta 9 (not complete) Previous downloads: 132 SFTPEx.au3
    1 point
  2. argumentum

    MsgBox_Extn() UDF

    It started in the help area, to delay the OK button for X seconds but is a good example for a mix of _WinAPI_SetTimer(), _WinAPI_SetWindowsHookEx(), IsFunc(), FuncName() and a callback. ; same as MsgBox() + button to delay[ /options ] [+ X,Y,W,H ] _MsgBox_Extn(5, BitOR($MB_TOPMOST, $MB_ICONINFORMATION, $MB_OK), "My title", "My Message", 20) ;~ _MsgBox_Extn("0, 20, 100", BitOR($MB_TOPMOST, $MB_ICONINFORMATION, $MB_OKCANCEL), "My title", "My Message", 20) ;~ _MsgBox_Extn("5/1, 20, 100", BitOR($MB_TOPMOST, $MB_ICONINFORMATION, $MB_YESNO), "My title", "My Message", 20) ;~ _MsgBox_Extn("5 sec. / -4th button, 20, 100, 600, 300", BitOR($MB_TOPMOST, $MB_ICONINFORMATION, $MB_CANCELTRYCONTINUE, $MB_HELP), "My title", "My Message", 20) The use is simple ( to me that I wrote it ). Try the examples above and it'll be self evident. Is a MsgBox with an extra ( 1st ) parameter. All expected returns are the same. But in @error there is also the return value and in @extended the line number were something is wrong. I may start coding this way for myself too. Is like a UDF with training wheels. A fun example of the callback is: #include <MsgBox_Extn.au3> ; https://www.autoitscript.com/forum/index.php?showtopic=211523 ConsoleWrite(@CRLF & "+++ _MsgBox_Extn() returned: $" & _MsgBox_Extn_ReturnMeaning(Example_CallBack(4)) & ' (' & @extended & ')' & @CRLF & @CRLF) ConsoleWrite('==========------------==========------------==========------------==========------------==========------------==========') ConsoleWrite(@CRLF & "+++ _MsgBox_Extn() returned: $" & _MsgBox_Extn_ReturnMeaning(Example_CallBack(1)) & ' (' & @extended & ')' & @CRLF & @CRLF) Func Example_CallBack($iTryButton) If _MsgBox_Extn_Version() < 5 Then Return SetError(1, 0, -2) Local $MsgText = 'Now this example will punish you' & @CR & 'by wasting 60 seconds of your life.' _MsgBox_Extn_SetCallBackFunc(_MyCallBack_TimerProc) If @error Then Return SetError(2, 0, -2) ConsoleWrite('+++ Using "' & FuncName(_MsgBox_Extn_SetCallBackFunc()) & '" as callback function.' & @CRLF) Local $iMisuseAtLineNumber, $iRet = _MsgBox_Extn("60/-" & $iTryButton, BitOR($MB_OKCANCEL, $MB_HELP), 'Example', $MsgText, 15) ; "-4" is wrong. Part of the demo. $iReturn = @error $iMisuseAtLineNumber = @extended ; so misuse/error, can be gathered for debug. If $iMisuseAtLineNumber Then ConsoleWrite('! At line ' & $iMisuseAtLineNumber & ' in the UDF, there was a complain. ( Naggy UDF ! )' & @CRLF) ConsoleWrite('@error (' & $iReturn & ') holds the same value as Return (' & $iRet & '). Why ?, meh, it may come in handy.' & _ ' There is no error return in MsgBox. Let''s give it some use.' & @CRLF) _MsgBox_Extn_SetCallBackFunc(Default) ; if you're not gonna use it anymore. Return $iRet EndFunc ;==>Example_CallBack Func _MyCallBack_TimerProc() Switch _MsgBox_Extn_SecCount() Case 60 ConsoleWrite('UDF version: ' & _MsgBox_Extn_Version() & @CRLF) Case 58 ; With the MsgBox HWnd, you can have your fun. ControlEnable(_MsgBox_Extn_GetHWnd(), "", "Button2") Case 57 _MsgBox_Extn_SetMessageText('Nah, just kidding =)') _MsgBox_Extn_SecCount(3) _MsgBox_Extn_SetCounterButtonText(_MsgBox_Extn_SetCounterButtonText() & " ?") Case 1 ; Setting "SetCounterButtonText" is used on a next loop. In 1 second. _MsgBox_Extn_SetCounterButtonText(_MsgBox_Extn_GetOrigBttnText()) Case 0 _MsgBox_Extn_SetButtonText(Default, Default, _MsgBox_Extn_GetOrigBttnText( _MsgBox_Extn_TotalCount()) & " ???") _MsgBox_Extn_ApplyButtonText() EndSwitch EndFunc ;==>_MyCallBack_TimerProc and the UDF code: #include-once ; #include <MsgBox_Extn.au3> ; https://www.autoitscript.com/forum/index.php?showtopic=211523 #include <WinAPISys.au3> #include <WinAPISysWin.au3> ; do check these include with your current version of AutoIt, it func() not found ( note for the future ) #include <WinAPI.au3> #include <MsgBoxConstants.au3> ; for the demo Global Const $g__MsgBox_Extn_tagCBT_CREATEWND = "ptr lpcs;HWND tagCBT_CREATEWND" ; https://www.autoitscript.com/forum/topic/191204-hookdlgbox-udf/ Global Const $g__MsgBox_Extn_tagCREATESTRUCT = "ptr lpCreateParams;handle hInstance;HWND hMenu;HWND hwndParent;int cy;int cx;int y;int x;LONG style;ptr lpszName;ptr lpszClass;DWORD dwExStyle" Global Const $g__MsgBox_Extn_aReturnMeaning[13] = [11, "IDOK", "IDCANCEL", "IDABORT", "IDRETRY", "IDIGNORE", "IDYES", "IDNO", "ID#8", "ID#9", "IDTRYAGAIN", "IDCONTINUE", "IDTIMEOUT"] Global $g__MsgBox_Extn_Globals_UDFversion = 5, _ $g__MsgBox_Extn_Globals_hHook = 0, _ $g__MsgBox_Extn_Globals_DisableAll = 0, _ $g__MsgBox_Extn_Globals_BttnAtlText[5] = [4, Default, Default, Default, Default], _ $g__MsgBox_Extn_Globals_BttnOriText[5] = [4, Default, Default, Default, Default], _ $g__MsgBox_Extn_Globals_DelayOnBttnNo = 1, _ $g__MsgBox_Extn_Globals_aWinPos = 0, _ $g__MsgBox_Extn_Globals_iSecCount = 0, _ $g__MsgBox_Extn_Globals_hWnd = 0, _ $g__MsgBox_Extn_Globals_hCallBackFunc = Default, _ $g__MsgBox_Extn_Globals_iDoitOnlyOnce = 1, _ $g__MsgBox_Extn_Globals_BttnOriCount = 0, _ $g__MsgBox_Extn_Globals_iWarning = 0, _ $g__MsgBox_Extn_Globals_sOriginalText ; same as MsgBox() + button to delay[ /options ] [+ X,Y,W,H ] ;~ _MsgBox_Extn(5, BitOR($MB_TOPMOST, $MB_ICONINFORMATION, $MB_OK), "My title", "My Message", 20) ;~ _MsgBox_Extn("0, 20, 100", BitOR($MB_TOPMOST, $MB_ICONINFORMATION, $MB_OKCANCEL), "My title", "My Message", 20) ;~ _MsgBox_Extn("5/1, 20, 100", BitOR($MB_TOPMOST, $MB_ICONINFORMATION, $MB_YESNO), "My title", "My Message", 20) ;~ _MsgBox_Extn("5 sec. / -4th button, 20, 100, 600, 300", BitOR($MB_TOPMOST, $MB_ICONINFORMATION, $MB_CANCELTRYCONTINUE, $MB_HELP), "My title", "My Message", 20) ; SecDelay The time delay until the control is re-enabled ; or a comma delimited string up to "delay [, X pos [, Y pos [, Width [, Height]]]]" ; "delay" can be formated as "delay [ /ButtonNumber]". Default is Button1. ; if ButtonNumber is a negative number, it'll disable all the buttons. ; flag The flag indicates the type of message box and the possible button combinations. See remarks in MsgBox(). ; title The title of the message box. ; text The text of the message box. ; timeout [optional] Timeout in seconds. After the timeout has elapsed the message box will close automatically. The default is 0, which is no timeout. ; hwnd [optional] The window handle to use as the parent for this dialog. ; Return Value ; Success: the ID of the button pressed. ; Failure: $IDTIMEOUT (-1) if the message box timed out. ; ; @extended = function misuse Func _MsgBox_Extn($iSecDelay, $iFlag, $sTitle, $sText, $iSecTimeout = 0, $hParent_hwnd = 0) ; https://www.autoitscript.com/forum/index.php?showtopic=211499&view=findpost&p=1530323 $g__MsgBox_Extn_Globals_aWinPos = StringSplit($iSecDelay, ",") ReDim $g__MsgBox_Extn_Globals_aWinPos[6] Local $aBttnNoDelay = StringSplit(StringReplace($g__MsgBox_Extn_Globals_aWinPos[1], "\", "/"), "/") ReDim $aBttnNoDelay[3] $g__MsgBox_Extn_Globals_DelayOnBttnNo = Int($aBttnNoDelay[2]) If Not $g__MsgBox_Extn_Globals_DelayOnBttnNo Then $g__MsgBox_Extn_Globals_DelayOnBttnNo = 1 If $g__MsgBox_Extn_Globals_DelayOnBttnNo < 0 Then $g__MsgBox_Extn_Globals_DisableAll = 1 $g__MsgBox_Extn_Globals_DelayOnBttnNo = Abs($g__MsgBox_Extn_Globals_DelayOnBttnNo) EndIf If $g__MsgBox_Extn_Globals_DelayOnBttnNo > 4 Then _MsgBox_Extn_ConsoleWrite('Note: Button' & $g__MsgBox_Extn_Globals_DelayOnBttnNo & ' will not exist. Setting to Button1 to, be nice ?. Check the code.' & @CRLF) $g__MsgBox_Extn_Globals_DelayOnBttnNo = 1 ; function misuse ; no more than a 4th button. EndIf If $g__MsgBox_Extn_Globals_aWinPos[0] > 5 Then _MsgBox_Extn_ConsoleWrite('Note: ' & $g__MsgBox_Extn_Globals_aWinPos[0] & ' parameters are too many. Check the code.' & @CRLF) $g__MsgBox_Extn_Globals_aWinPos[0] = 5 ; better safe than sorry. ; function misuse ; $iSecDelay = "delay [, X pos [, Y pos [, Width [, Height]]]]" only. EndIf For $n = 1 To $g__MsgBox_Extn_Globals_aWinPos[0] $g__MsgBox_Extn_Globals_aWinPos[1] = Int($g__MsgBox_Extn_Globals_aWinPos[1]) Next For $n = $g__MsgBox_Extn_Globals_aWinPos[0] + 1 To 5 $g__MsgBox_Extn_Globals_aWinPos[$n] = Null ; these are unused place holders. Next Local $hTimerProc = DllCallbackRegister(__MsgBox_Extn_TimerProc, 'none', 'hwnd;uint;uint_ptr;dword') Local $iTimerID = _WinAPI_SetTimer(0, 0, 1000, DllCallbackGetPtr($hTimerProc)) ; $iTimerID should be 0 if the $hWnd is 0. Local $hProc = DllCallbackRegister(__MsgBox_Extn_CbtHookProc, "int", "int;int;int") $g__MsgBox_Extn_Globals_hHook = _WinAPI_SetWindowsHookEx($WH_CBT, DllCallbackGetPtr($hProc), 0, _WinAPI_GetCurrentThreadId()) Local $iRet = MsgBox($iFlag, $sTitle, $sText, $iSecTimeout, $hParent_hwnd) _WinAPI_KillTimer(0, $iTimerID) DllCallbackFree($hTimerProc) _WinAPI_UnhookWindowsHookEx($g__MsgBox_Extn_Globals_hHook) DllCallbackFree($hProc) Local $iExt = $g__MsgBox_Extn_Globals_iWarning $g__MsgBox_Extn_Globals_iWarning = 0 $g__MsgBox_Extn_Globals_hHook = 0 $g__MsgBox_Extn_Globals_iSecCount = 0 $g__MsgBox_Extn_Globals_aWinPos = 0 $g__MsgBox_Extn_Globals_hWnd = 0 $g__MsgBox_Extn_Globals_iDoitOnlyOnce = 1 $g__MsgBox_Extn_Globals_DelayOnBttnNo = 1 $g__MsgBox_Extn_Globals_DisableAll = 0 Dim $g__MsgBox_Extn_Globals_BttnOriText[5] = [4, Default, Default, Default, Default] _MsgBox_Extn_SetButtonText() ; re-init all prior alternate button text to defaults. $g__MsgBox_Extn_Globals_BttnOriCount = 0 Return SetError($iRet, $iExt, $iRet) EndFunc ;==>_MsgBox_Extn ; Return the meaning/name of the enumerator/constant Func _MsgBox_Extn_ReturnMeaning($iIndex) $iIndex = Int($iIndex) If $iIndex = -1 Then Return SetExtended($iIndex, $g__MsgBox_Extn_aReturnMeaning[12]) Switch $iIndex Case 8, 9 Return SetError(1, $iIndex, "unkown index " & $iIndex) Case 1 To 12 Return SetExtended($iIndex, $g__MsgBox_Extn_aReturnMeaning[$iIndex]) EndSwitch Return SetError(2, $iIndex, "unkown index " & $iIndex) EndFunc ;==>_MsgBox_Extn_ReturnMeaning ; Returns the UDF version. Just in case more stuff is added. Func _MsgBox_Extn_Version() Return $g__MsgBox_Extn_Globals_UDFversion EndFunc ;==>_MsgBox_Extn_Version ; Get the original text of any of the 4 possible buttons. ; For if _MsgBox_Extn_SetCallBackFunc() is used. Func _MsgBox_Extn_GetOrigBttnText($iIndex = $g__MsgBox_Extn_Globals_DelayOnBttnNo) If $iIndex > 4 Or $iIndex < 1 Then $g__MsgBox_Extn_Globals_iWarning = @ScriptLineNumber _MsgBox_Extn_ConsoleWrite('Note: an $iIndex of ' & $iIndex & ' should have been between 1 and 4. Therefore is an error.' & @CRLF) $iIndex = $g__MsgBox_Extn_Globals_DelayOnBttnNo EndIf Return SetExtended(IsKeyword($g__MsgBox_Extn_Globals_BttnOriText[$iIndex]), $g__MsgBox_Extn_Globals_BttnOriText[$iIndex]) EndFunc ;==>_MsgBox_Extn_GetOrigBttnText ; Reset the original text of the 4 possible buttons. Or just the one you pass along as Index. ; For if _MsgBox_Extn_SetCallBackFunc() is used. Func _MsgBox_Extn_ResetButtonText($iIndex = Default) If IsKeyword($iIndex) = 1 Then For $n = 1 To $g__MsgBox_Extn_Globals_BttnOriText[0] $g__MsgBox_Extn_Globals_BttnAtlText[$n] = $g__MsgBox_Extn_Globals_BttnOriText[$n] Next Else If $iIndex > 4 Or $iIndex < 1 Then $g__MsgBox_Extn_Globals_iWarning = @ScriptLineNumber _MsgBox_Extn_ConsoleWrite('Note: an $iIndex of ' & $iIndex & ' should have been between 1 and 4. Therefore is an error.' & @CRLF) $iIndex = $g__MsgBox_Extn_Globals_DelayOnBttnNo EndIf $g__MsgBox_Extn_Globals_BttnAtlText[$n] = $g__MsgBox_Extn_Globals_BttnOriText[$n] EndIf EndFunc ;==>_MsgBox_Extn_ResetButtonText ; Set any of the 4 possible buttons, from left to right, with an alternate text. Func _MsgBox_Extn_SetButtonText($iButton1 = Default, $iButton2 = Default, $iButton3 = Default, $iButton4 = Default) $g__MsgBox_Extn_Globals_BttnAtlText[1] = $iButton1 $g__MsgBox_Extn_Globals_BttnAtlText[2] = $iButton2 $g__MsgBox_Extn_Globals_BttnAtlText[3] = $iButton3 $g__MsgBox_Extn_Globals_BttnAtlText[4] = $iButton4 EndFunc ;==>_MsgBox_Extn_SetButtonText ; After _MsgBox_Extn_SetButtonText(), you'll need to _MsgBox_Extn_ApplyButtonText() ; For use in _MsgBox_Extn_SetCallBackFunc() Func _MsgBox_Extn_ApplyButtonText() For $n = 1 To $g__MsgBox_Extn_Globals_BttnAtlText[0] If Not IsKeyword($g__MsgBox_Extn_Globals_BttnAtlText[$n]) Then ControlSetText($g__MsgBox_Extn_Globals_hWnd, "", "Button" & $n, String($g__MsgBox_Extn_Globals_BttnAtlText[$n]), 1) EndIf Next EndFunc ;==>_MsgBox_Extn_ApplyButtonText ; Set a new message text on the fly ; For use in _MsgBox_Extn_SetCallBackFunc() Func _MsgBox_Extn_SetMessageText($sStr) Local $iRet, $iStatic = 2 If ControlGetText($g__MsgBox_Extn_Globals_hWnd, "", "Static2") = "" Or @error Then $iStatic = 1 $iRet = ControlSetText($g__MsgBox_Extn_Globals_hWnd, "", "Static" & $iStatic, String($sStr)) Return SetError(Int(Not $iRet), $iStatic, $iRet) EndFunc ;==>_MsgBox_Extn_SetMessageText ; Set a new default text on the fly ; For use in _MsgBox_Extn_SetCallBackFunc() Func _MsgBox_Extn_SetCounterButtonText($sNewText = Default) If Not IsKeyword($sNewText) Then $g__MsgBox_Extn_Globals_sOriginalText = String($sNewText) Return $g__MsgBox_Extn_Globals_sOriginalText EndFunc ;==>_MsgBox_Extn_SetCounterButtonText ; Set a new count down on the fly via _MsgBox_Extn_SetCallBackFunc() Func _MsgBox_Extn_SecCount($iNewValue = Default) If Not IsKeyword($iNewValue) Then $g__MsgBox_Extn_Globals_aWinPos[1] = Int($iNewValue) $g__MsgBox_Extn_Globals_iSecCount = -1 EndIf Return $g__MsgBox_Extn_Globals_aWinPos[1] - $g__MsgBox_Extn_Globals_iSecCount EndFunc ;==>_MsgBox_Extn_SecCount Func _MsgBox_Extn_TotalCount() Return $g__MsgBox_Extn_Globals_BttnOriCount EndFunc ;==>_MsgBox_Extn_TotalCount ; The handle of the MsgBox(), to use in _MsgBox_Extn_SetCallBackFunc() Func _MsgBox_Extn_GetHWnd() Return $g__MsgBox_Extn_Globals_hWnd EndFunc ;==>_MsgBox_Extn_GetHWnd Func _MsgBox_Extn_ConsoleWrite($sStr, $iLineNumber = @ScriptLineNumber) Local Static $iReturn = Not (StringRight(@ScriptName, 4) = '.au3') $g__MsgBox_Extn_Globals_iWarning = $iLineNumber If $iReturn Then Return "" ConsoleWrite('"MsgBox_Extn.au3" (' & $iLineNumber & ',0) : ' & $sStr) EndFunc ;==>_MsgBox_Extn_ConsoleWrite ; To do stuff within the time the delay is active. ; example at https://www.autoitscript.com/forum/index.php?showtopic=211499&view=findpost&p=1530455 Func _MsgBox_Extn_SetCallBackFunc($hCallBackFunc = Null) ; a no parameter func(). Use helper func ( _MsgBox_Extn_* ) Local $iErr = 0 If IsKeyword($hCallBackFunc) = 1 Then ; $KEYWORD_DEFAULT (1) the Default keyword. ; $KEYWORD_NULL (2) the Null keyword. $g__MsgBox_Extn_Globals_hCallBackFunc = "" ; ..to remove the value ElseIf IsFunc($hCallBackFunc) Then $g__MsgBox_Extn_Globals_hCallBackFunc = $hCallBackFunc ElseIf IsKeyword($hCallBackFunc) = 2 Then ; This is to return the $hCallBackFunc in use. Else ; if we get to this point, is not a keyword nor a function. Therefore is an error. _MsgBox_Extn_ConsoleWrite('Note: If we get to this point, is not a keyword nor a function. Therefore is an error.' & @CRLF) $g__MsgBox_Extn_Globals_hCallBackFunc = "" ; since is an error, let's remove whatever was there. $iErr = 1 EndIf Return SetError($iErr, 0, $g__MsgBox_Extn_Globals_hCallBackFunc) EndFunc ;==>_MsgBox_Extn_SetCallBackFunc #Region INTERNAL Func __MsgBox_Extn_TimerProc($hWnd, $iMsg, $iTimerID, $iTime) ;~ ConsoleWrite('+ Func __MsgBox_Extn_TimerProc(' & $hWnd & ', ' & $iMsg & ', ' & $iTimerID & ', ' & $iTime & ')' & @CRLF) #forceref $hWnd, $iMsg, $iTimerID, $iTime $g__MsgBox_Extn_Globals_iSecCount += 1 If $g__MsgBox_Extn_Globals_iSecCount < $g__MsgBox_Extn_Globals_aWinPos[1] Then ControlSetText($g__MsgBox_Extn_Globals_hWnd, "", "Button" & $g__MsgBox_Extn_Globals_DelayOnBttnNo, _MsgBox_Extn_SetCounterButtonText() & ' (' & $g__MsgBox_Extn_Globals_aWinPos[1] - $g__MsgBox_Extn_Globals_iSecCount & ')') ElseIf $g__MsgBox_Extn_Globals_iSecCount = $g__MsgBox_Extn_Globals_aWinPos[1] Then ControlSetText($g__MsgBox_Extn_Globals_hWnd, "", "Button" & $g__MsgBox_Extn_Globals_DelayOnBttnNo, _MsgBox_Extn_SetCounterButtonText()) If $g__MsgBox_Extn_Globals_DisableAll Then For $n = 1 To 4 ControlEnable($g__MsgBox_Extn_Globals_hWnd, "", "Button" & $n) Next Else ControlEnable($g__MsgBox_Extn_Globals_hWnd, "", "Button" & $g__MsgBox_Extn_Globals_DelayOnBttnNo) EndIf EndIf If IsFunc($g__MsgBox_Extn_Globals_hCallBackFunc) Then $g__MsgBox_Extn_Globals_hCallBackFunc() ; $hWnd, $iMsg, $iTimerID, $iTime) ; there's no use for these. EndFunc ;==>__MsgBox_Extn_TimerProc Func __MsgBox_Extn_CbtHookProc($nCode, $wParam, $lParam) ;~ ConsoleWrite('+ Func __MsgBox_Extn_CbtHookProc(' & $nCode & ', ' & $wParam & ', ' & $lParam & ')' & @CRLF) If $nCode = 3 And $g__MsgBox_Extn_Globals_iDoitOnlyOnce = 1 And _WinAPI_GetClassName(HWnd($wParam)) = "#32770" Then $g__MsgBox_Extn_Globals_iDoitOnlyOnce = 2 $g__MsgBox_Extn_Globals_hWnd = HWnd($wParam) If $g__MsgBox_Extn_Globals_aWinPos[2] <> Null Then Local $tcs = DllStructCreate($g__MsgBox_Extn_tagCREATESTRUCT, DllStructGetData(DllStructCreate($g__MsgBox_Extn_tagCBT_CREATEWND, $lParam), "lpcs")) If $g__MsgBox_Extn_Globals_aWinPos[2] <> Null Then DllStructSetData($tcs, "x", $g__MsgBox_Extn_Globals_aWinPos[2]) If $g__MsgBox_Extn_Globals_aWinPos[3] <> Null Then DllStructSetData($tcs, "y", $g__MsgBox_Extn_Globals_aWinPos[3]) If $g__MsgBox_Extn_Globals_aWinPos[4] <> Null Then DllStructSetData($tcs, "cx", $g__MsgBox_Extn_Globals_aWinPos[4]) ; these Cx,Cy don't do anything functional If $g__MsgBox_Extn_Globals_aWinPos[5] <> Null Then DllStructSetData($tcs, "cy", $g__MsgBox_Extn_Globals_aWinPos[5]) ; but, you can use them if you wish. EndIf EndIf If $nCode = 5 And $g__MsgBox_Extn_Globals_iDoitOnlyOnce = 2 And $g__MsgBox_Extn_Globals_aWinPos[1] > 0 And HWnd($wParam) = $g__MsgBox_Extn_Globals_hWnd Then ; 5=HCBT_ACTIVATE $g__MsgBox_Extn_Globals_iDoitOnlyOnce = 0 _MsgBox_Extn_ApplyButtonText() If $g__MsgBox_Extn_Globals_DisableAll Then For $n = 1 To 4 ControlDisable($g__MsgBox_Extn_Globals_hWnd, "", "Button" & $n) Next Else ControlDisable($g__MsgBox_Extn_Globals_hWnd, "", "Button" & $g__MsgBox_Extn_Globals_DelayOnBttnNo) EndIf For $n = 1 To 4 $g__MsgBox_Extn_Globals_BttnOriText[$n] = ControlGetText($g__MsgBox_Extn_Globals_hWnd, "", "Button" & $n) If $g__MsgBox_Extn_Globals_BttnOriText[$n] = "" And @error Then If Not $g__MsgBox_Extn_Globals_BttnOriCount Then $g__MsgBox_Extn_Globals_BttnOriCount = $n - 1 $g__MsgBox_Extn_Globals_BttnOriText[$n] = Default EndIf Next If $g__MsgBox_Extn_Globals_DelayOnBttnNo > $g__MsgBox_Extn_Globals_BttnOriCount Then _MsgBox_Extn_ConsoleWrite('Note: Button' & $g__MsgBox_Extn_Globals_DelayOnBttnNo & ' does not exist on this ' & $g__MsgBox_Extn_Globals_BttnOriCount & ' button MsgBox. Setting to Button1. Check the code.' & @CRLF) $g__MsgBox_Extn_Globals_DelayOnBttnNo = 1 EndIf _MsgBox_Extn_SetCounterButtonText(_MsgBox_Extn_GetOrigBttnText($g__MsgBox_Extn_Globals_DelayOnBttnNo)) ControlSetText($g__MsgBox_Extn_Globals_hWnd, "", "Button" & $g__MsgBox_Extn_Globals_DelayOnBttnNo, _MsgBox_Extn_SetCounterButtonText() & ' (' & $g__MsgBox_Extn_Globals_aWinPos[1] & ')') If IsFunc($g__MsgBox_Extn_Globals_hCallBackFunc) Then $g__MsgBox_Extn_Globals_hCallBackFunc() ElseIf $nCode = 5 And $g__MsgBox_Extn_Globals_iDoitOnlyOnce = 2 And HWnd($wParam) = $g__MsgBox_Extn_Globals_hWnd Then _MsgBox_Extn_ApplyButtonText() EndIf Return _WinAPI_CallNextHookEx($g__MsgBox_Extn_Globals_hHook, $nCode, $wParam, $lParam) EndFunc ;==>__MsgBox_Extn_CbtHookProc #EndRegion INTERNAL And a $MB_HELP usage example ( somewhere down there ). If you don't feel like copy and paste all this then here: MsgBox_Extn[v5].zip In version 5 there more stuff. Lost count, but it has nagging code to let the user know, if the code has a complain about the parameters. So, this is a good example as far as examples but M23's Extended Message Box is a better option if you need a flexible MsgBox UDF.
    1 point
  3. This is what the options are: (from SciTEConfig/Other Tools/Run AutoIt3/SciTE check) ****************************************************************************************************************************************** * HKCR\.au3 Default : AutoIt3Script * HKLM\SOFTWARE\Classes\.au3\ShellNew: C:\WINDOWS\SHELLNEW\Template.au3 (File Exists) * HKCR\.au3 ShellNew : C:\WINDOWS\SHELLNEW\Template.au3 (File Exists) ****************************************************************************************************************************************** * Explorer shell options: * HKCR\AutoIt3Script\shell: * => Default Action:Open * Compile => Command:"C:\Program Files (x86)\AutoIt3\Aut2Exe\Aut2Exe.exe" /in "%l" * Compile with Options => Command:"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /ShowGui /in "%l" * CompileX64 => Command:"C:\Program Files (x86)\AutoIt3\Aut2Exe\Aut2Exe_x64.exe" /in "%l" * CompileX86 => Command:"C:\Program Files (x86)\AutoIt3\Aut2Exe\Aut2Exe.exe" /in "%l" * Edit => Command:"C:\Program Files (x86)\AutoIt3\SciTE\SciTE.exe" "%1" * Open => Command:"C:\Program Files (x86)\AutoIt3\SciTE\SciTE.exe" "%1" * Run => Command:"C:\Program Files (x86)\AutoIt3\AutoIt3.exe" "%1" %* * RunX64 => Command:"C:\Program Files (x86)\AutoIt3\AutoIt3_x64.exe" "%1" %* * RunX86 => Command:"C:\Program Files (x86)\AutoIt3\AutoIt3.exe" "%1" %* ****************************************************************************************************************************************** So only "Compile with Options" is using Autoit3Wrapper.
    1 point
  4. ioa747

    Class wildcarding?

    you can use REGEXPCLASS look in help file for Window Titles and Text (Advanced) 210720-how-can-i-future-proof-my-code-so-changes-to-windows-handlesids-dont-require-new-edits Edit: $winpos = WinGetPos("[REGEXPCLASS:(?i)(.*ZebraDesigner.exe.*)")
    1 point
  5. I had a quick look at the code and noticed that the wrapper functions need a brush up in this area. I will post updated code as soon as possible. Unfortunately I no longer have access to Outlook and jhence can't test my code. Would you mind to do the testing for me when the new code is ready?
    1 point
  6. Introduction: To parse XML data, a so-called DOM parser is usually used - e.g. the Microsoft.XMLDOM object. This parser goes through the entire structure and rebuilds it hierarchically in its own data structure. Afterwards you can continue working on this basis. In other programming languages, however, one occasionally encounters a different approach: the SAX parser. Here the idea is as follows: The parser traverses the XML string and calls user-defined functions at certain breakpoints. Usually this would be at the beginning of an element, for example. The parser then passes the element type, the position in the string and the attributes of the element to the user-defined function. The parser doesn't care what the user does with it - it just calls functions at the breakpoints. Further breakpoints would be when closing an element or as soon as the content of an element has been reached. This approach has advantages as well as disadvantages. The advantage is that the user can decide what is really needed and what is not. This can result in faster parsing. Also it is possible to process the data before it is completely loaded or processed. The disadvantage however is that the work with this can not only take some getting used to but also quickly become very complex. In particular, since it is important for a reasonable processing to exchange information between the individual user functions one will have to use global variables. Example of use: The following example reads the Autoitscript.com forum page and extracts a list of recent topics using the SAX parser: To use or not? So what's the point of all this? For most use cases I think it is better to use the known DOM-based approaches, because working with a SAX parser can quickly degenerate into enormous complexity. However, a certain acceleration can(!) be achieved with this approach. I have tested this in the example above: If I process the page with the HTMLFile object, it needs ~150ms for parsing alone. The topics were already processed with the SAX parser after 60ms (the parsing continues - but can be stopped). The question is whether the higher complexity for the user is worth it for these cases. The Sax parser also reacts more kindly to errors in the XML file in many cases and could be used as a more robust alternative. With the SAX parser as a fundament, it should also be fairly easy to write your own purely AutoIt-based DOM parser. And last but not least, we can now say for AutoIt: Now we have our own Sax parser too! >>sourcecode and download on github<<
    1 point
  7. Hi all, I've made a program to block certain programs and a remote management console It all works, I can send commands to the main program, but one function to unblock, won't work. When the command is executed to the remote machine it should unblock it, by just sleeping. Normally this works fine, but it doesnt work when remotely called. Why? Because When I change de sleep() function to a messagebox it works, it does display the msgbox, so the connction is there. Any Ideas? Thanks!
    1 point
×
×
  • Create New...