Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/12/2023 in all areas

  1. TreeView Extended Styles The MS docu for TreeView extended styles can be found here. Most styles revolve around visual features. This is an implementation of some of these styles: TVS_EX_AUTOHSCROLL Failed to get this style to work. May depend on the TVM_SETAUTOSCROLLINFO message. TVS_EX_DIMMEDCHECKBOXES, TVS_EX_EXCLUSIONCHECKBOXES, TVS_EX_PARTIALCHECKBOXES Depends on the TVS_CHECKBOXES style also being set. The extended CheckBoxes styles must be set before the TVS_CHECKBOXES style. Necessary for the latter to know which extended styles to set. These CheckBoxes look better on Windows 7 than on Windows 10. On Windows 10, some of the state images become very similar. Maybe it's possible to save the state images as icons on Windows 7 and load the icons as new state images on Windows 10. Not tested. TVS_EX_DOUBLEBUFFER The double buffer extended style is usually used to reduce flicker when using the vertical ScrollBar. Therefore, the style is interesting compared to virtual TreeViews. However, it's somewhat uncertain whether the style has any effect at all for these TreeViews, or whether it only works for standard TreeViews. TVS_EX_DRAWIMAGEASYNC Has not been implemented so far. TVS_EX_FADEINOUTEXPANDOS Fade in/out of collapse/expand Buttons when the TreeView control gains/loses focus. Also works better on Windows 7 than on Windows 10. TVS_EX_MULTISELECT According to MS docu this style is not supported. Not implemented. TVS_EX_NOINDENTSTATE No indentation of collapse/expand Buttons. Thus, these Buttons are aligned along the left edge of the TreeView. Failed to get this style to work. TVS_EX_NOSINGLECOLLAPSE Intended for internal use. Not implemented. TVS_EX_RICHTOOLTIP Seems to depend on custom drawn ToolTips. Not implemented. TreeViewExtendedStyles.au3 include #include-once #include <SendMessage.au3> #include <TreeViewConstants.au3> Global Const $TVS_EX_MULTISELECT = 0x0002 Global Const $TVS_EX_DOUBLEBUFFER = 0x0004 Global Const $TVS_EX_NOINDENTSTATE = 0x0008 Global Const $TVS_EX_RICHTOOLTIP = 0x0010 Global Const $TVS_EX_AUTOHSCROLL = 0x0020 Global Const $TVS_EX_FADEINOUTEXPANDOS = 0x0040 Global Const $TVS_EX_PARTIALCHECKBOXES = 0x0080 Global Const $TVS_EX_EXCLUSIONCHECKBOXES = 0x0100 Global Const $TVS_EX_DIMMEDCHECKBOXES = 0x0200 Global Const $TVS_EX_DRAWIMAGEASYNC = 0x0400 Global Const $TVM_SETEXTENDEDSTYLE = $TV_FIRST + 44 Global Const $TVM_GETEXTENDEDSTYLE = $TV_FIRST + 45 Func _GUICtrlTreeView_GetExtendedStyle( $hWnd ) Return IsHWnd( $hWnd ) ? _SendMessage( $hWnd, $TVM_GETEXTENDEDSTYLE ) _ : GUICtrlSendMsg( $hWnd, $TVM_GETEXTENDEDSTYLE, 0, 0 ) EndFunc ; $iExStyle: Extended control styles ; $iExMask: Specifies which styles in $iExStyle are to be affected Func _GUICtrlTreeView_SetExtendedStyle( $hWnd, $iExStyle, $iExMask = 0 ) Local $iRet = IsHWnd( $hWnd ) ? _SendMessage( $hWnd, $TVM_SETEXTENDEDSTYLE, $iExMask, $iExStyle ) _ : GUICtrlSendMsg( $hWnd, $TVM_SETEXTENDEDSTYLE, $iExMask, $iExStyle ) _WinAPI_InvalidateRect( $hWnd ) Return $iRet EndFunc CheckBoxes.au3 example Examples in the Examples\Styles\ folder. Run the examples in SciTE with F5. This is the extended CheckBoxes example, CheckBoxes.au3: #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_UseX64=Y ; Run script as 64 bit code Opt( "MustDeclareVars", 1 ) #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiTreeView.au3> #include "..\..\Includes\CreateTreeViewFromSource.au3" #include "..\..\Includes\TreeViewExtendedStyles.au3" CreateTreeViewGui( "TreeViewSource.txt" ) Func CreateTreeViewGui( $sTreeViewSource ) ; Create GUI Local $hGui = GUICreate( "Create TreeView From Source - CheckBoxes", 400, 300, 600, 300, $GUI_SS_DEFAULT_GUI ) ; Create TreeView Local $idTV = GUICtrlCreateTreeView( 2, 2, 396, 296, $GUI_SS_DEFAULT_TREEVIEW, $WS_EX_CLIENTEDGE ) Local $hTV = GUICtrlGetHandle( $idTV ) ; Set CheckBoxes extended styles ; Click CheckBoxes several times to see the different styles _GUICtrlTreeView_SetExtendedStyle( $idTV, $TVS_EX_PARTIALCHECKBOXES+$TVS_EX_EXCLUSIONCHECKBOXES+$TVS_EX_DIMMEDCHECKBOXES ) ; Set CheckBoxes style ; Must be set AFTER extended styles ; Extended CheckBox styles depends on the TVS_CHECKBOXES style also being set. The extended CheckBox styles ; must be set BEFORE the TVS_CHECKBOXES style. Necessary for the latter to know which extended styles to set. DllCall( "user32.dll", "long_ptr", @AutoItX64 ? "SetWindowLongPtrW" : "SetWindowLongW", "hwnd", $hTV, "int", $GWL_STYLE, "long_ptr", _ DllCall( "user32.dll", "long_ptr", @AutoItX64 ? "GetWindowLongPtrW" : "GetWindowLongW", "hwnd", $hTV, "int", $GWL_STYLE )[0] + $TVS_CHECKBOXES ) ; Create TreeView from source file CreateTreeViewFromSource( $hTV, $sTreeViewSource ) _GUICtrlTreeView_Expand( $hTV ) ; Show GUI GUISetState( @SW_SHOW, $hGui ) ; Loop While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; Cleanup GUIDelete( $hGui ) EndFunc The image shows the 5 CheckBoxes on Windows 7 with state image indices 1 - 5: TreeView Explorer Theme Example in the Examples\Theme\ folder. Run the example in SciTE with F5. ExplorerTheme.au3: #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_UseX64=Y ; Run script as 64 bit code Opt( "MustDeclareVars", 1 ) #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiTreeView.au3> #include <WinAPITheme.au3> #include "..\..\Includes\CreateTreeViewFromSource.au3" CreateTreeViewGui( "TreeViewSource.txt" ) Func CreateTreeViewGui( $sTreeViewSource ) ; Create GUI Local $hGui = GUICreate( "Create TreeView From Source - ExplorerTheme", 400, 300, 600, 300, $GUI_SS_DEFAULT_GUI ) ; Create TreeView Local $idTV = GUICtrlCreateTreeView( 2, 2, 396, 296, $GUI_SS_DEFAULT_TREEVIEW, $WS_EX_CLIENTEDGE ) Local $hTV = GUICtrlGetHandle( $idTV ) ; Set Explorer theme _WinAPI_SetWindowTheme( $hTV, "Explorer", 0 ) ; Create TreeView from source file CreateTreeViewFromSource( $hTV, $sTreeViewSource ) _GUICtrlTreeView_Expand( $hTV ) ; Show GUI GUISetState( @SW_SHOW, $hGui ) ; Loop While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; Cleanup GUIDelete( $hGui ) EndFunc The Explorer theme on Windows 7. Looks better on Windows 10. 7z-file The 7z-file contains source code for UDFs and examples. You need AutoIt 3.3.12 or later. Tested on Windows 7 and Windows 10. Comments are welcome. Let me know if there are any issues. TreeViewStyles.7z
    3 points
  2. Earthshine

    AutoIt Cheat Sheet

    There is no need for a cheat sheet. You have the help file. If only people would use it. for what it’s worth in my experience, cheat sheets don’t cut it anyway Only way to learn something is to deep dive. You can help people most by not writing their code for them, and helping them learn.
    3 points
  3. Hi everybody Here is the script I use to test RegEx patterns offline, it's handy. Credits go to Lazycat, who scripted it initially many years ago and thanked "w0uter for ideas and parts of code". I added some modifications (listed in next post) and would like to thank @mLipok @mikell @Nine @mistersquirrle and @ioa747 for their contribution. ;================================================================= ; Description: Testing Regular Expressions on the fly ; Requirement(s): Autoit 3.3.14.5 (2018) ; Author(s): YDY (Lazycat), thanks to w0uter for ideas and parts of code ; Modified: pixelsearch ; Version: 2.5p ;================================================================= #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> Global $hDll = DllOpen("user32.dll") ; for DllCall's in _TrackPopupMenu() : purpose is not open/close Dll at each call (on-line help) Global $_g_bWasAChange = True ; mLipok, cf Func WM_COMMAND() Global $nMode = 0, $APP_VER = "2.5p" Global $sIniFile = @ScriptDir & "\" & StringTrimRight(@ScriptName, 4) & ".ini" Global $sTxtFile = StringTrimRight($sIniFile, 4) & ".txt" ; read/write "match text" edit control in a separate txt file (no more size limit) Global $aInfo, $mPos, $nColor, $sOldResult, $sOldCount #Region ### START Koda GUI section ### Form=RegExpQuickTester.kxf Global $hGUI = GUICreate("RegExp Quick Tester " & $APP_VER, 460, 598, -1, -1, _ BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX), _ $WS_EX_ACCEPTFILES) ; accept to Maximize & Resize the GUI, also accept drag & drop Global $aGUIInitPos = WinGetPos($hGUI) ; see Func WM_GETMINMAXINFO ;========== $grpMatch = GUICtrlCreateGroup("Match Text", 4, 6, 449, 145) $ebTest = GUICtrlCreateEdit("", 12, 23, 434, 121, BitOR($ES_WANTRETURN, $WS_VSCROLL)) ; no horizontal scrollbar ; $ebTest = GUICtrlCreateEdit("", 12, 23, 434, 121) ; user may prefer this line, in case he needs an horizontal scrollbar GUICtrlSetFont(-1, 9, 400, 0, "Courier New") GUICtrlSetState(-1, $GUI_DROPACCEPTED) ; drag & drop accepted in "match text" edit control GUICtrlSendMsg($ebTest, $EM_LIMITTEXT, -1, 0) ; added to allow unlimited text size in edit control : ini file won't store this control anymore, a separate txt file will. GUICtrlCreateGroup("", -99, -99, 1, 1) ;========== $grpExpressions = GUICtrlCreateGroup("Expressions (right click for menu)", 4, 156, 449, 145, -1, $WS_EX_TRANSPARENT) $tabExpr = GUICtrlCreateTab(8, 174, 442, 121, BitOR($TCS_BUTTONS, $TCS_FLATBUTTONS, $TCS_FOCUSONBUTTONDOWN)) GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif") GUICtrlSetResizing(-1, $GUI_DOCKAUTO) $TabSheet0 = GUICtrlCreateTabItem("Search Pattern") $ebRegExp = GUICtrlCreateEdit("", 12, 201, 434, 90, BitOR($ES_WANTRETURN,$WS_VSCROLL)) GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console") $TabSheet1 = GUICtrlCreateTabItem("Replace Pattern") $ebRegExpReplace = GUICtrlCreateEdit("", 12, 201, 434, 90, BitOR($ES_WANTRETURN,$WS_VSCROLL)) GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console") $TabSheet2 = GUICtrlCreateTabItem("Result Prefix") $ebResultPrefix = GUICtrlCreateEdit("", 12, 201, 434, 90, BitOR($ES_WANTRETURN,$WS_VSCROLL)) GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console") $TabSheet3 = GUICtrlCreateTabItem("Result Suffix") $ebResultSuffix = GUICtrlCreateEdit("", 12, 201, 434, 90, BitOR($ES_WANTRETURN,$WS_VSCROLL)) GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console") $TabSheet4 = GUICtrlCreateTabItem("Personal") $ebPersonal = GUICtrlCreateEdit("", 12, 201, 434, 90, BitOR($ES_WANTRETURN,$WS_VSCROLL)) GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console") GUICtrlCreateTabItem("") GUICtrlCreateGroup("", -99, -99, 1, 1) ; purpose of $Tab_Highlight[3][2] is to highlight a TabItem if its Edit control contains something (or don't highlight if it's empty) Global $Tab_Highlight[3][2] = [[$ebRegExpReplace], [$ebResultPrefix], [$ebResultSuffix]] ; Col 1 = False (not highlited) ;========== $grpResults = GUICtrlCreateGroup("Result", 4, 304, 449, 208) $lblCount = GUICtrlCreateLabel("", 12, 492, 300, 17) ; width increased to 300 (in case additional infos). Possible to increase => 434 $ebResult = GUICtrlCreateEdit("", 12, 324, 434, 164, BitOR($WS_HSCROLL, $WS_VSCROLL, $ES_READONLY, $WS_TABSTOP)) GUICtrlSetFont(-1, 9, 400, 0, "Courier New") GUICtrlCreateGroup("", -99, -99, 1, 1) ;========== $grpBehaviour = GUICtrlCreateGroup("Options", 4, 514, 329, 78) GUICtrlCreateLabel("Mode:", 16, 536, 34, 17) $cbMode = GUICtrlCreateCombo("", 56, 532, 265, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL)) GUICtrlSetData(-1, "0 - Return 0/1|1 - Return array of matches|2 - Return array of matches with full match|3 - Return array of global matches|4 - Return array of arrays of global matches") GUICtrlCreateLabel("Replace count:", 16, 564, 77, 17) $ibRepCount = GUICtrlCreateInput("0", 96, 560, 72, 21, BitOr($GUI_SS_DEFAULT_INPUT, $ES_NUMBER)) $udRepCount = GUICtrlCreateUpdown($ibRepCount) GUICtrlSetLimit(-1, 16384, 0) $cbLineNum = GUICtrlCreateCheckbox("Show group numbers", 201, 562, 127, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) ;========== $btnCode = GUICtrlCreateButton("Code", 370, 514, 81, 25) $btnClear = GUICtrlCreateButton("Clear", 370, 543, 81, 25) $btnClose = GUICtrlCreateButton("Close", 370, 572, 81, 25) ;========== $lblDummy = GUICtrlCreateLabel("", 336, 552, 1, 1) ; 1 pixel size ! Good luck to click on it in the GUI :) $lblDummycontext = GUICtrlCreateContextMenu($lblDummy) $hDummycontext = GUICtrlGetHandle($lblDummyContext) ; for function _TrackPopupMenu() ; 25th march 2023 : context menu prepared in a separate function _PrepareContextMenu() Global $idMenu_Start, $idMenu_End ; +++ _PrepareContextMenu() ;========== GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ; Reload recent data $nMode = Number(IniRead($sIniFile, "Main", "Mode", 0)) GUICtrlSendMsg($cbMode, $CB_SETCURSEL, $nMode, 0) GUICtrlSetState($cbLineNum, IniRead($sIniFile, "Main", "LineNum", 1)) GUICtrlSetData($ibRepCount, IniRead($sIniFile, "Main", "ReplaceCount", 0)) GUICtrlSetData($ebRegExp, BinaryToString(IniRead($sIniFile, "Main", "Pattern", ""), 4)) ; 4 = $SB_UTF8 (binary data is UTF8) GUICtrlSetData($ebRegExpReplace, BinaryToString(IniRead($sIniFile, "Main", "Replace", ""), 4)) GUICtrlSetData($ebResultPrefix, BinaryToString(IniRead($sIniFile, "Main", "Prefix", ""), 4)) GUICtrlSetData($ebResultSuffix, BinaryToString(IniRead($sIniFile, "Main", "Suffix", ""), 4)) GUICtrlSetData($ebPersonal, BinaryToString(IniRead($sIniFile, "Main", "Personal", ""), 4)) GUICtrlSetData($ebTest, FileRead($sTxtFile)) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") ; mLipok GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO") While 1 $aInfo = GUIGetCursorInfo() If IsArray($aInfo) Then If $aInfo[3] = 1 And $aInfo[4] = $ebRegExp Then ; right click ($aInfo[3] = 1) while hovering over Edit Control in TabSheet0 $mPos = MouseGetPos() _TrackPopupMenu($hGUI, $hDummycontext, $mPos[0], $mPos[1]) EndIf EndIf $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $btnClose IniWrite($sIniFile, "Main", "Mode", $nMode) IniWrite($sIniFile, "Main", "LineNum", GUICtrlRead($cbLineNum)) IniWrite($sIniFile, "Main", "ReplaceCount", Int(GUICtrlRead($ibRepCount))) IniWrite($sIniFile, "Main", "Pattern", StringToBinary(GUICtrlRead($ebRegExp), 4)) ; 4 = $SB_UTF8 (string data is UTF8) IniWrite($sIniFile, "Main", "Replace", StringToBinary(GUICtrlRead($ebRegExpReplace), 4)) IniWrite($sIniFile, "Main", "Prefix", StringToBinary(GUICtrlRead($ebResultPrefix), 4)) IniWrite($sIniFile, "Main", "Suffix", StringToBinary(GUICtrlRead($ebResultSuffix), 4)) IniWrite($sIniFile, "Main", "Personal", StringToBinary(GUICtrlRead($ebPersonal), 4)) Local $hTxtFile = FileOpen($sTxtFile, 2) ; 2 = Write mode (erase previous contents) FileWrite($hTxtFile, GUICtrlRead($ebTest)) FileClose($hTxtFile) DllClose($hDll) ; close user32.dll (was opened so DllCall's in _TrackPopupMenu() didn't open/close it at each call) Exit Case $idMenu_Start To $idMenu_End $sMenuData = GUICtrlRead($nMsg, 1) GUICtrlSendMsg($ebRegExp, 0x00C2, 1, StringLeft($sMenuData, StringInStr($sMenuData, @TAB)-1)) ; 0x00C2 = $EM_REPLACESEL ; 1 (or True) = allow Undo ; GUICtrlSetState($ebRegExp, $GUI_FOCUS) ; better caret position when line commented out. Case $cbMode $nMode = GUICtrlSendMsg($cbMode, $CB_GETCURSEL, 0, 0) Case $btnCode GUICtrlSetState($btnCode, $GUI_DISABLE) ; prevent accidental double click on the button _GenerateCode() ; generate AutoIt code and copy it to Clipboard GUICtrlSetState($btnCode, $GUI_ENABLE) Case $btnClear If MsgBox(BitOr($MB_YESNO, $MB_TOPMOST, $MB_ICONQUESTION, $MB_DEFBUTTON2), _ "Attention", "Clear all fields ?", 0, $hGUI) = $IDYES Then GUICtrlSetData($ebTest, "") GUICtrlSetData($ebRegExp, "") GUICtrlSetData($ebRegExpReplace, "") GUICtrlSetData($ebResultPrefix, "") GUICtrlSetData($ebResultSuffix, "") ; never clear the 'Personal' Tab here EndIf Case $GUI_EVENT_DROPPED If @GUI_DragId = -1 Then ; -1 means dragged from a file (only alternative is to drag from... Listview item : help file) GUICtrlSetData(@GUI_DropId, FileRead(@GUI_DragFile)) EndIf EndSwitch Check_Highlight() ; check 3 TabItems content (empty or not), then possibly turn on / off their highlight If $_g_bWasAChange Or ($nMsg <> 0 And $nMsg <> -11) Then ; mLipok for $_g_bWasAChange . $GUI_EVENT_MOUSEMOVE = -11 (me) RegExpExecute() $_g_bWasAChange = False EndIf WEnd ;================================================================= Func RegExpExecute() Local $vResult, $vTemp, $sResult = "Failed", $sCount = "", $error, $nCurColor Local $sResultPrefix = GUICtrlRead($ebResultPrefix), $sResultSuffix = GUICtrlRead($ebResultSuffix), _ $bShowGroupsNumber = (GUICtrlRead($cbLineNum) = $GUI_CHECKED) If GUICtrlRead($ebRegExpReplace) <> "" Then ; if Edit control "Replace Pattern" isn't empty => StringRegExpReplace If Not BitAND(GUICtrlGetState($cbMode), $GUI_DISABLE) Then GUICtrlSetState($cbMode, $GUI_DISABLE) If Not BitAND(GUICtrlGetState($ibRepCount), $GUI_ENABLE) Then GUICtrlSetState($ibRepCount, $GUI_ENABLE) If Not BitAND(GUICtrlGetState($cbLineNum), $GUI_DISABLE) Then GUICtrlSetState($cbLineNum, $GUI_DISABLE) ; added that one $sResult = $sResultPrefix & _ StringRegExpReplace(GUICtrlRead($ebTest), GUICtrlRead($ebRegExp), GUICtrlRead($ebRegExpReplace), GUICtrlRead($ibRepCount)) & _ $sResultSuffix $sCount = "Groups replaced: " & @extended & " (result length: " & StringLen($sResult) & ")" Else ; Edit control "Replace Pattern" is empty, so we're dealing now with "Search Pattern" Edit control => StringRegExp If Not BitAND(GUICtrlGetState($cbMode), $GUI_ENABLE) Then GUICtrlSetState($cbMode, $GUI_ENABLE) If Int(GUICtrlRead($ibRepCount)) <> 0 Then GUICtrlSetData($ibRepCount, 0) ; added that one If Not BitAND(GUICtrlGetState($ibRepCount), $GUI_DISABLE) Then GUICtrlSetState($ibRepCount, $GUI_DISABLE) If Not BitAND(GUICtrlGetState($cbLineNum), $GUI_ENABLE) Then GUICtrlSetState($cbLineNum, $GUI_ENABLE) ; added that one $nCurColor = 0 ; black $vResult = StringRegExp(GUICtrlRead($ebTest), GUICtrlRead($ebRegExp), $nMode) $error = @error $extended = @extended ; Workaround about editbox flickering If $error = 2 Then $nCurColor = 0xFF0000 ; red . $error = 2 means bad pattern (in any mode) If $nColor <> $nCurColor Then GUICtrlSetColor($ebRegExp, $nCurColor) $nColor = $nCurColor If $nMode = 0 Then If $vResult Then $sResult = "Matched" Else ; Mode 1/2/3/4 If Not $error Then $sResult = "" $vTemp = 0 If $nMode = 4 Then $sCount = "Global matches: " & UBound($vResult) For $i = 0 to UBound($vResult) - 1 If $i > 0 Then $sResult &= @CRLF ; version 2.5e : prevent here (& below) an annoying @CRLF at the end of the Result field $vTemp = $vResult[$i] $sResult &= "--- Global match " & $i+1 & " ---" & @CRLF For $j = 0 To UBound($vTemp) - 1 If $j > 0 Then $sResult &= @CRLF If $bShowGroupsNumber Then $sResult &= StringFormat("%0" & StringLen(String(UBound($vTemp))) & "d: %s", $j, $sResultPrefix & $vTemp[$j] & $sResultSuffix) Else $sResult &= $sResultPrefix & $vTemp[$j] & $sResultSuffix EndIf Next Next If IsArray($vTemp) Then $sCount = "Groups matched: " & UBound($vTemp) & " (global matches: " & UBound($vResult) & ")" Else ; Mode 1/2/3 $sCount = "Groups matched: " & UBound($vResult) & ($nMode < 3 ? (" (next offset: " & $extended & ")") : "") For $i = 0 to UBound($vResult) - 1 If $i > 0 Then $sResult &= @CRLF If $bShowGroupsNumber Then $sResult &= StringFormat("%0" & StringLen(String(UBound($vResult))) & "d: %s", $i, $sResultPrefix & $vResult[$i] & $sResultSuffix) Else $sResult &= $sResultPrefix & $vResult[$i] & $sResultSuffix EndIf Next EndIf EndIf EndIf EndIf If $sOldResult <> $sResult Or $sOldCount <> $sCount Then GUICtrlSetData($ebResult, $sResult) GUICtrlSetData($lblCount, $sCount) EndIf $sOldResult = $sResult $sOldCount = $sCount ; Wow... w0uter's workaround is still actual... ; Don't know, not recall what the prob was... ; StringRegExp('', Random(0x80000000, 0x7FFFFFFF), 1) EndFunc ;==>RegExpExecute ;================================================================= Func _TrackPopupMenu($hWnd, $hMenu, $x, $y) DllCall($hDll, "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0, "int", $x, "int", $y, "hwnd", $hWnd, "ptr", 0) EndFunc ;==>_TrackPopupMenu ;================================================================= Func Check_Highlight() For $i = 0 To 2 ; 3 TabItems to check If GUICtrlRead($Tab_Highlight[$i][0]) = "" Then ; if Edit control is empty in this TabItem... If $Tab_Highlight[$i][1] Then ; ...and if it's highlited... GUICtrlSendMsg($tabExpr, $TCM_HIGHLIGHTITEM, $i + 1, False) ; ...then don't highlight this TabItem $Tab_Highlight[$i][1] = False EndIf Else ; Edit control not empty in this TabItem... If Not $Tab_Highlight[$i][1] Then ; ...and if it's not highlited... GUICtrlSendMsg($tabExpr, $TCM_HIGHLIGHTITEM, $i + 1, True) ; ...then highlight this TabItem $Tab_Highlight[$i][1] = True EndIf EndIf Next EndFunc ;==>Check_Highlight ;================================================================= Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) ; mLipok, reworked ; Local $hWndFrom = $lParam ; Local $iIDFrom = _WinAPI_LoWord($wParam) Local $iIDFrom = BitAND($wParam, 0xFFFF) ; same (cf WinAPIConv.au3) ; Local $iCode = _WinAPI_HiWord($wParam) Local $iCode = BitShift($wParam, 16) ; same (cf WinAPIConv.au3) Switch $iIDFrom Case $ebTest, $ebRegExp, $ebRegExpReplace, $ebResultPrefix, $ebResultSuffix, $ibRepCount Switch $iCode Case $EN_CHANGE ; Sent when the user has taken an action that may have altered text in an edit control (mLipok) $_g_bWasAChange = True If Not GUICtrlRead($ibRepCount) Then GUICtrlSetData($ibRepCount, 0) ; in case empty field => force 0 EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND ;================================================================= Func WM_GETMINMAXINFO($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam If $hWnd = $hGUI Then Local $minmaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam) DllStructSetData($minmaxinfo, 7, $aGUIInitPos[2]) ; min width DllStructSetData($minmaxinfo, 8, $aGUIInitPos[3] / 1.5) ; min height, testing / 1.5 seems ok Return 0 ; "If an application processes this message, it should return zero." (msdn) EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_GETMINMAXINFO ;================================================================= Func _GenerateCode() Local $sClipTxt, $sSubject, $sPattern $sSubject = _TextSplit(GUICtrlRead($ebTest), "$sSubject") ; 2nd param. used literally in generated code $sPattern = _TextSplit(GUICtrlRead($ebRegExp), "$sPattern") ; ditto If $sSubject = "" Or $sPattern = "" Then MsgBox(0, "Generating code", "error : Match Text OR Search Pattern are empty", 0, $hGUI) Return EndIf If Not GUICtrlRead($ebRegExpReplace) Then ; generate StringRegExp code If $nMode > 0 Then ; 1/2/3/4 $sClipTxt = "#include <Array.au3>" & @crlf & @crlf & _ "Local $sSubject, $sPattern, $aArray" & @crlf & @crlf & _ "$sSubject = " & $sSubject & @crlf & @crlf & _ "$sPattern = " & $sPattern & @crlf & @crlf & _ "$aArray = StringRegExp($sSubject, $sPattern, " & $nMode & ")" & @crlf & _ "If Not @error Then" & @crlf & _ " ; _CW($aArray)" & @crlf & _ ; interesting line used during tests (removable) " _ArrayDisplay($aArray)" & @crlf & _ "Else" & @crlf & _ " MsgBox(0, 'StringRegExp', 'error = ' & @error & (@error = 1 ? ' (no matches)' : ' (bad pattern)'))" & @crlf & _ "EndIf" & @crlf Else ; mode 0 doesn't generate an Array but an Int32 $sClipTxt = "Local $sSubject, $sPattern, $iMatch" & @crlf & @crlf & _ "$sSubject = " & $sSubject & @crlf & @crlf & _ "$sPattern = " & $sPattern & @crlf & @crlf & _ "$iMatch = StringRegExp($sSubject, $sPattern, " & $nMode & ")" & @crlf & _ "MsgBox(0, 'Matched ?', ($iMatch ? 'yes' : 'no'))" & @crlf EndIf Else ; generate StringRegExpReplace code Local $sReplace, $iCount $sReplace = _TextSplit(GUICtrlRead($ebRegExpReplace), "$sReplace") ; 2nd param. used literally in generated code $iCount = Int(GUICtrlRead($ibRepCount)) $sClipTxt = "Local $sSubject, $sPattern, $sReplace, $iCount, $sOutput" & @crlf & @crlf & _ "$sSubject = " & $sSubject & @crlf & @crlf & _ "$sPattern = " & $sPattern & @crlf & _ "$sReplace = " & $sReplace & @crlf & _ "$iCount = " & $iCount & (($iCount = 0) ? " ; 0 means global replacement" : "") & @crlf & @crlf & _ "$sOutput = StringRegExpReplace($sSubject, $sPattern, $sReplace, $iCount)" & @crlf & _ "MsgBox(0, 'StringRegExpReplace', $sOutput)" & @crlf EndIf ClipPut($sClipTxt) MsgBox(0, "Code (copied to Clipboard)", ClipGet(), 0, $hGUI) EndFunc ;==>_GenerateCode ;================================================================= Func _TextSplit($sString, $sCaller) Local $iMaxLineSize = 2000 ; changeable but tested ok . Though Scite MaxLine length = 4095, just think of ... ; ...possible plenty newline chars or ' expanded below, not forgetting possible @Tab characters expanded in Scite Local $iStringSize = StringLen($sString) ; ConsoleWrite("[" & $sCaller & "] " & "Initial $iStringSize = " & $iStringSize & @crlf & @crlf) Local $sLi = "", $iLiSize = 0, $b5CharsFound = False, $sRet = "" While $iStringSize > 0 $sLi = StringLeft($sString, $iMaxLineSize) $iLiSize = StringLen($sLi) ; important variable declared here, as $sLi is gonna be altered below. ; ConsoleWrite("[" & $sCaller & "] " & "$iLiSize = " & $iLiSize & @crlf) $sLi = "'" & StringReplace($sLi, "'", "''") & "'" ; surround with ' (by design) and double all eventual ' inside StringRegExp($sLi, '\R', 1) ; check 1st EOL match (if any) . EOL can be @crlf or @lf or @cr If Not @error Then ; EOL found in $sLi StringRegExp($sLi, "& '' ", 1) ; as there is (at least) 1 EOL in $sLi, check if these 5 problematic chars are found in $sLi $b5CharsFound = Not @error ? True : False ; if they're found => we'll keep them in $sLi after the 3 StringReplace() below $sLi = StringReplace($sLi, @crlf, "' & @crlf & '") ; @crlf first $sLi = StringReplace($sLi, @lf, "' & @lf & '") $sLi = StringReplace($sLi, @cr, "' & @cr & '") ; 3 following If's are useful, as they generate a simplified code If StringLeft($sLi, 5) = "'' & " Then $sLi = StringTrimLeft($sLi, 5) ; safe to execute this line (impossible '' in original) If StringRight($sLi, 5) = " & ''" Then $sLi = StringTrimRight($sLi, 5) ; ditto If Not $b5CharsFound Then ; If 5 original chars were not part of $sLi before the 3 StringReplace() above, then... $sLi = StringReplace($sLi, "& '' ", "") ; ...they may be part of $sLi now, in case several followed newlines at middle of $sLi were treated EndIf EndIf ; ConsoleWrite("[" & $sCaller & "] " & "Len $sLi altered = " & StringLen($sLi) & @crlf) ; ConsoleWrite("[" & $sCaller & "] " & "$sLi altered = " & $sLi & @crlf) If $sRet = "" Then ; 1st passage $sRet = $sLi Else $sRet &= @crlf & " " & $sCaller & " &= " & $sLi EndIf $sString = StringMid($sString, $iLiSize + 1) $iStringSize = StringLen($sString) ; ConsoleWrite("[" & $sCaller & "] " & "Remaining $iStringSize = " & $iStringSize & @crlf & @crlf) WEnd Return $sRet EndFunc ;==>_TextSplit ;================================================================= Func _PrepareContextMenu() ; Group here all GUICtrlCreateMenu() so their id's will precede all the Context menus lines id's defined by GUICtrlCreateMenuItem(...) below Local $mnu100 = GUICtrlCreateMenu("Options", $lblDummycontext) Local $mnu200 = GUICtrlCreateMenu("Anchors && Assertions", $lblDummycontext) Local $mnu300 = GUICtrlCreateMenu("Matching Characters", $lblDummycontext) Local $mnu400 = GUICtrlCreateMenu("Character Classes && Posix", $lblDummycontext) Local $mnu500 = GUICtrlCreateMenu("Groups && Backreferences", $lblDummycontext) Local $mnu600 = GUICtrlCreateMenu("Repeating Characters", $lblDummycontext) ; All Context menus items id's are defined in a single interval : from $idMenu_Start to $idMenu_End ; It will allow a simple test later, during the GUI loop : Case $idMenu_Start To $idMenu_End $idMenu_Start = GUICtrlCreateMenuItem("(?i)"&@TAB&"case-insensitive", $mnu100) GUICtrlCreateMenuItem("(?m)"&@TAB&"^ and $ match at newlines chars within data", $mnu100) GUICtrlCreateMenuItem("(?s)"&@TAB&". matches anything, including newline chars", $mnu100) GUICtrlCreateMenuItem("(?U)"&@TAB&"Ungreedy (quantifiers become lazy)", $mnu100) GUICtrlCreateMenuItem("(?x)"&@TAB&"ignore whitespace chars and # comments", $mnu100) GUICtrlCreateMenuItem("", $mnu100) GUICtrlCreateMenuItem("(?- )"&@TAB&"unset option(s) ex. (?-im) etc...", $mnu100) GUICtrlCreateMenuItem("^"&@TAB&"beginning of string, or after a newline if (?m)", $mnu200) GUICtrlCreateMenuItem("\A"&@TAB&"beginning of string, no matter (?m)", $mnu200) GUICtrlCreateMenuItem("\G"&@TAB&"beginning of string, then where previous match ended", $mnu200) GUICtrlCreateMenuItem("$"&@TAB&"end of string, or before a newline if (?m)", $mnu200) GUICtrlCreateMenuItem("\z"&@TAB&"end of string, no matter (?m)", $mnu200) GUICtrlCreateMenuItem("\Z"&@TAB&"end of string, or b4 newline at the end, no matter (?m)", $mnu200) GUICtrlCreateMenuItem("", $mnu200) GUICtrlCreateMenuItem("\b"&@TAB&"match at a word boundary", $mnu200) GUICtrlCreateMenuItem("\B"&@TAB&"match when not at a word boundary", $mnu200) GUICtrlCreateMenuItem("\K"&@TAB&"reset start of match at the current position", $mnu200) GUICtrlCreateMenuItem("(?= )"&@TAB&"positive lookahead q(?=u) q followed by u", $mnu200) GUICtrlCreateMenuItem("(?! )"&@TAB&"negative lookahead q(?!u) q not followed by u", $mnu200) GUICtrlCreateMenuItem("(?<= )"&@TAB&"positive lookbehind (?<=u)q q preceded by u", $mnu200) GUICtrlCreateMenuItem("(?<! )"&@TAB&"negative lookbehind (?<!u)q q not preceded by u", $mnu200) GUICtrlCreateMenuItem("."&@TAB&"any single character, except newline chars [^\r\n]", $mnu300) GUICtrlCreateMenuItem("|"&@TAB&"OR operator", $mnu300) GUICtrlCreateMenuItem("\"&@TAB&"escape a metacharacter \ ^ $ . [ | ( ) ? * + {", $mnu300) GUICtrlCreateMenuItem("\\"&@TAB&"match an actual backslash ", $mnu300) GUICtrlCreateMenuItem("\a"&@TAB&"alarm character (BEL, (chr(7))", $mnu300) GUICtrlCreateMenuItem("\d"&@TAB&"any digit (0-9)", $mnu300) GUICtrlCreateMenuItem("\D"&@TAB&"any non-digit", $mnu300) GUICtrlCreateMenuItem("\e"&@TAB&"escape character (chr(27))", $mnu300) GUICtrlCreateMenuItem("\f"&@TAB&"formfeed character (chr(12))", $mnu300) GUICtrlCreateMenuItem("\h"&@TAB&"any hor. whitespace (@TAB, space, non-break space)", $mnu300) GUICtrlCreateMenuItem("\H"&@TAB&"any non-horizontal whitespace", $mnu300) GUICtrlCreateMenuItem("\n"&@TAB&"newline character (@LF, chr(10))", $mnu300) GUICtrlCreateMenuItem("\N"&@TAB&"any character except newline chars, no matter (?s)", $mnu300) GUICtrlCreateMenuItem("\Q \E"&@TAB&"treat all enclosed characters as literals", $mnu300) GUICtrlCreateMenuItem("\r"&@TAB&"carriage return (@CR, chr(13))", $mnu300) GUICtrlCreateMenuItem("\R"&@TAB&"any newline sequence (@CRLF, @CR, @LF)", $mnu300) GUICtrlCreateMenuItem("\s"&@TAB&"any whitespace char : chr(9) to chr(13) and chr(32)", $mnu300) GUICtrlCreateMenuItem("\S"&@TAB&"any non-whitespace character", $mnu300) GUICtrlCreateMenuItem("\t"&@TAB&"tab character (@TAB, chr(9))", $mnu300) GUICtrlCreateMenuItem("\v"&@TAB&"any vertical whitespace : chr(10) to chr(13)", $mnu300) GUICtrlCreateMenuItem("\V"&@TAB&"any non-vertical whitespace", $mnu300) GUICtrlCreateMenuItem("\w"&@TAB&"any 'word' character: A-Z, a-z, 0-9 or underscore _", $mnu300) GUICtrlCreateMenuItem("\W"&@TAB&"any non-word character", $mnu300) GUICtrlCreateMenuItem("\xhh"&@TAB&"character with hexa code hh \x7E match a tilde ~", $mnu300) GUICtrlCreateMenuItem("\x{hhhh}"&@TAB&"character with hexa code hhhh \x{20AC} matches €", $mnu300) GUICtrlCreateMenuItem("[ ]"&@TAB&"match any character in the class", $mnu400) GUICtrlCreateMenuItem("[^ ]"&@TAB&"match any character not in the class", $mnu400) GUICtrlCreateMenuItem("[\\x0-9]"&@TAB&"match a backslash OR an x OR any digit", $mnu400) GUICtrlCreateMenuItem("[^0-9]"&@TAB&"match any non-digit character", $mnu400) GUICtrlCreateMenuItem("[\b]"&@TAB&"watch out: match a backspace (BS, (chr(8))", $mnu400) GUICtrlCreateMenuItem(""&@TAB&"5 metacharacters in a class are ^ \ - ] [ if posix", $mnu400) GUICtrlCreateMenuItem("", $mnu400) GUICtrlCreateMenuItem("[:alnum:]"&@TAB&"letters and digits, [A-Za-z0-9]", $mnu400) GUICtrlCreateMenuItem("[:alpha:]"&@TAB&"letters, [A-Za-z]", $mnu400) GUICtrlCreateMenuItem("[:ascii:]"&@TAB&"character codes, 0-127", $mnu400) GUICtrlCreateMenuItem("[:blank:]"&@TAB&"space or Tab only, [\x09\x20]", $mnu400) GUICtrlCreateMenuItem("[:cntrl:]"&@TAB&"control characters, 0-31 and 127", $mnu400) GUICtrlCreateMenuItem("[:digit:]"&@TAB&"decimal digits, \d or [0-9]", $mnu400) GUICtrlCreateMenuItem("[:graph:]"&@TAB&"printing characters, excluding space 33-126", $mnu400) GUICtrlCreateMenuItem("[:lower:]"&@TAB&"lower case characters, [a-z]", $mnu400) GUICtrlCreateMenuItem("[:print:]"&@TAB&"printing characters, including space 32-126", $mnu400) GUICtrlCreateMenuItem("[:punct:]"&@TAB&"punctuation !""#$%&&'()*+,-./:;<=>?@[\]^_`{|}~", $mnu400) GUICtrlCreateMenuItem("[:space:]"&@TAB&"whitespace, chr(9) to chr(13) and chr(32)", $mnu400) GUICtrlCreateMenuItem("[:upper:]"&@TAB&"uppercase letters, [A-Z]", $mnu400) GUICtrlCreateMenuItem("[:word:]"&@TAB&"word characters, \w or [[:alnum:]_]", $mnu400) GUICtrlCreateMenuItem("[:xdigit:]"&@TAB&"hexadecimal digits, [0-9A-Fa-f]", $mnu400) GUICtrlCreateMenuItem("", $mnu400) GUICtrlCreateMenuItem("[:^xdigit:]"&@TAB&"non-hexadecimal digits, [^0-9A-Fa-f] etc...", $mnu400) GUICtrlCreateMenuItem("( )"&@TAB&"capturing group", $mnu500) GUICtrlCreateMenuItem("(?: )"&@TAB&"non-capturing group", $mnu500) GUICtrlCreateMenuItem("(?| )"&@TAB&"non-capturing group with reset", $mnu500) GUICtrlCreateMenuItem("(?> )"&@TAB&"atomic non-capturing group (no backtrack)", $mnu500) GUICtrlCreateMenuItem("(?# )"&@TAB&"comment group (not nestable)", $mnu500) GUICtrlCreateMenuItem("(?<name> )"&@TAB&"named capturing group ex. (?<caps>[A-Z]+)", $mnu500) GUICtrlCreateMenuItem("", $mnu500) GUICtrlCreateMenuItem(""&@TAB&"Backreferences of previously captured groups", $mnu500) GUICtrlCreateMenuItem("\n"&@TAB&"absolute group number ex: \1 to \9", $mnu500) GUICtrlCreateMenuItem("\gn"&@TAB&"absolute group number (safer) ex: \g1", $mnu500) GUICtrlCreateMenuItem("\g{n}"&@TAB&"absolute group number (safest) ex: \g{1}", $mnu500) GUICtrlCreateMenuItem("\g{-n}"&@TAB&"relative group number ex: \g{-1}", $mnu500) GUICtrlCreateMenuItem("\k<name>"&@TAB&"named group ex: \k<caps>", $mnu500) GUICtrlCreateMenuItem(""&@TAB&"Repeat the previous character, class, group or backreference", $mnu600) GUICtrlCreateMenuItem("*"&@TAB&"0 or more times", $mnu600) GUICtrlCreateMenuItem("+"&@TAB&"1 or more times", $mnu600) GUICtrlCreateMenuItem("?"&@TAB&"0 or 1 time", $mnu600) GUICtrlCreateMenuItem("{x}"&@TAB&"exactly x times", $mnu600) GUICtrlCreateMenuItem("{x,}"&@TAB&"at least x times", $mnu600) GUICtrlCreateMenuItem("{,x}"&@TAB&"at most x times", $mnu600) GUICtrlCreateMenuItem("{x,y}"&@TAB&"between x and y times", $mnu600) GUICtrlCreateMenuItem("", $mnu600) GUICtrlCreateMenuItem("?"&@TAB&"(after any of the above) find the smallest match (ungreedy)", $mnu600) $idMenu_End = GUICtrlCreateMenuItem("+"&@TAB&"(after any of the above) possessive (e.g. atomic and greedy)", $mnu600) EndFunc ;==>_PrepareContextMenu Below are the match text & patterns corresponding to the pic above. For a start, you can copy and paste them in their respective edit control. After you choose the corresponding RegExp mode from the ComboBox at the bottom of the screen (mode 3 = return array of global matches) then you'll have the same results as displayed in the pic above. Match Text : blabla...blabla... blabla..."https://media.pic1.jpg"blabla..."https://media.pic2.png"... blabla..."https://media.pic3.jpg"blabla..."https://media.pic4.png"... blabla...blabla... Pattern : (?i)"([^"]+?\.(?:jpg|png))" When you end the script, 2 files will be created in the same directory of the script. Assuming your script is named "RegExpQuickTester 2.5p.au3", the 2 files created will be : * "RegExpQuickTester 2.5p.txt" which contains the saved Match Text that will be reused when you run the script. * "RegExpQuickTester 2.5p.ini" which contains the saved options that will be reused when you run the script. A right click while hovering over the Edit control of the Search Pattern will display a helpful context menu, with possibility to paste something from the menu inside the Search Pattern. Personally I nearly don't paste anything from the context menu but as this feature was created by the original scripter... Instead I like to consult this context menu as a RegExp syntax reminder ! Anyway, just experiment it and choose what's best for you. 99% of the time, the Search Pattern Tab will be on top. If you notice another colored Tab (except the Personal Tab which will never be highlited), then it means that there is something written in this other tab : the color is here only to remind you that there IS something in this other tab, in case you had forgotten. Even a space or a blank line would color the Tab. YJ This particular design (due to original scripter) won't allow you to type "" in the Replace Pattern Tab (mikell frowned, concerning this missing feature). Gladly I found that typing a non existing group, for example $99 will have the same effect as "" so it's a workaround that seems to do the job. The "Code" button allows you to generate the corresponding AutoIt code, which will be copied to the Clipboard Don't hesitate to ask if you have questions. Our RegExp gurus (that's not me) just love RegExp questions Edit: I forgot. You can drag a text file (or htm etc...) inside the Match Text edit control (it's a droppable zone) . There shouldn't be a 32Kb file size limit anymore as I added code to override this limit. There are probably a couple of other functionalities I'm not thinking of now, you'll easily find what you need if you look at the code. And if you want to modify something in the code, don't hesitate. Just share here your modifications in case other users find them useful too, thanks. Updates are detailed in next post
    2 points
  4. water

    AutoIt Cheat Sheet

    Users are not writing that we shouldn't have a cheat sheet, they are writing that they don't see the benefit of a cheat sheet. So if someone wants to write a CS, feel free!
    2 points
  5. Lepes

    AutoIt Cheat Sheet

    I'm a coder, I have already downloaded LUA and Python Cheat sheets and I agree with all of you: - Cheat Sheet purpose is to have a look on the language: loop syntax (helps me a lot), datatypes, read a text/ini file and so on... very frequently asks on the forum. I appreciate that! - I always start with Cheat sheets and then switch to the help file, once I know how to search some topic on the help file, I won't use anymore Cheat sheets... but remember: I downloaded Cheat Sheets!! I really don't understand why we shouldn't have a wiki page with Cheat Sheet, downloadable as PDF with topics links to the main help file. Just an example: I remember I opened cheat sheets to just click a link to the help file to find exactly what I was searching for, because I didn't find on the help file itself. It sound embarrasing but it is real life, you are stressed, in a hurry, both...whatever!! I agree the best way to learn is to open help file and read from start to the end, bottom line. The problem is that whenever someone install AutoIt (or whatever new language) is because he found a snipped code that solve his problem, so he is on a hurry and he wants something that works. That's the glue that makes this new user sticks to AutoIt or just leave it. Once this person solved his problem and he had more time, he will read help file from the beginning.
    2 points
  6. If you're looking to get the volume as set in the player/program itself, that's likely more complicated. If you just want to get and set the Windows volume mixer levels, check out this post: I tried it out and it worked for me with vlc.exe
    1 point
  7. No problem at all @argumentum 🤝 . I hoped it was a misunderstanding 😅 . Thanks anyways for your suggestion now. Best regards Sven
    1 point
  8. Well I did. And for that, please do pardon my grave misunderstanding. I edited just minutes ago but not in time for you to see it, as for what is obvious now, you were writing the above. By now you've been scripting in AutoIt long enough to just do it. Have a go at it. Ask for corrections and/or addendums, to make available a most awesome cheatsheet for AutoIt, as cheatsheets are valued by cheatsheet connoisseurs
    1 point
  9. AutoBert

    AutoIt Cheat Sheet

    but don't forget the '#' : #cs #ce to begin a comment - block
    1 point
  10. TIP: Change any new line to \n
    1 point
  11. @SOLVE-SMART I think it's a great idea! Especially for complete beginners, I used cheatsheets myself when first playing around with HTTP requests, Python etc. IMO having a lot of actionable one-line commands on one page makes it really accessible for people who aren't coders, trying out AutoIt for the first time.
    1 point
  12. water

    AutoIt Cheat Sheet

    I don't remember anyone on the forum asking for an AutoIt cheat sheet. Seems users are happy with the information they get from the various sources provided here. The forum lists 30 threads related to cheat sheets - regarding JS, RegExp ... I think that the benefit of a cheat sheet is small compared to the effort. Just my 0,02 €
    1 point
  13. JLogan3o13

    AutoIt Cheat Sheet

    There is already an official Wiki, why would you not just direct new people here rather than adding confusion by having to maintain two sources?
    1 point
  14. @Danp2 Hello Dan, thanks for the working example. I was able to run it and extract all 33 pages of this website which gave me an array of 1600 rows. Also the UDF from @Gianni ( _HtmlTable2Array.au3 ) made the whole process way faster. Thanks for that! I also made a second version of the _HtmlTable2Array.au3 with the recommended changes from @barbossa . Works also but i could not feel a speed up. Although i did not measure the time. Maybe it only benefits from larger tables. I dont know. Cool! Now i can start to disect and learn about the navigation Thank you guys!
    1 point
  15. It's not quite clear to me what you're asking to do. Do you have some code as an example that shows what you're trying to do, and where the error is? You probably want to look into this function: https://www.autoitscript.com/autoit3/docs/libfunctions/_Date_Time_SystemTimeToTzSpecificLocalTime.htm You can convert the GMT times to your local time, or a local time to GMT: https://www.autoitscript.com/autoit3/docs/libfunctions/_Date_Time_TzSpecificLocalTimeToSystemTime.htm
    1 point
  16. funkey

    HookDlgBox UDF

    Hello, it's quite often, that someone asks how to change the texts of the MsgBox buttons or the InputBox buttons or how to change the position of ta MsgBox. Since years I use CBT hooks for that, but now I made a small UDF out of it for the ease of use. Of course you can build your own GUI or use already existing UDFs to do the same, but I like this way and you can hack (hook) the inbuild InputBox. HookDlgBox.au3 #include-once #include <WinAPI.au3> Global Const $tagCBT_CREATEWND = "ptr lpcs;HWND tagCBT_CREATEWND" Global Const $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 $g__hProcDlgBox = DllCallbackRegister("__DlgBox_CbtHookProc", "LRESULT", "int;WPARAM;LPARAM") Global $g__TIdDlgBox = _WinAPI_GetCurrentThreadId() Global $g__hHookDlgBox = _WinAPI_SetWindowsHookEx($WH_CBT, DllCallbackGetPtr($g__hProcDlgBox), 0, $g__TIdDlgBox) Global Const $g__MaxDlgBtns = 5 ; maximum of 5 buttons to rename text Global Const $g__MaxDlgItemId = 11 ; maximun ID of buttons to search is 11 as this is the maximun used in Messagebox Global $g__DlgBoxPosX, $g__DlgBoxPosY, $g__DlgBoxWidth, $g__DlgBoxHeight Global $g__aDlgBoxBtnText[$g__MaxDlgBtns] Global $g__DlgBtnCount = 0 _DlgBox_SetDefaults() OnAutoItExitRegister("__DlgBox_UnregisterHook") Func _DlgBox_SetButtonNames($TxtBtn1 = Default, $TxtBtn2 = Default, $TxtBtn3 = Default, $TxtBtn4 = Default, $TxtBtn5 = Default) $g__aDlgBoxBtnText[0] = $TxtBtn1 $g__aDlgBoxBtnText[1] = $TxtBtn2 $g__aDlgBoxBtnText[2] = $TxtBtn3 $g__aDlgBoxBtnText[3] = $TxtBtn4 $g__aDlgBoxBtnText[4] = $TxtBtn5 $g__DlgBtnCount = @NumParams EndFunc ;==>_DlgBox_SetButtonNames Func _DlgBox_SetPosition($x = Default, $y = Default) ;only for MsgBox, not working and not needed for InputBox $g__DlgBoxPosX = $x $g__DlgBoxPosY = $y EndFunc ;==>_DlgBox_SetPosition Func _DlgBox_SetSize($w = Default, $h = Default) $g__DlgBoxWidth = $w $g__DlgBoxHeight = $h EndFunc ;==>_DlgBox_SetSize Func _DlgBox_SetDefaults() $g__DlgBoxPosX = Default $g__DlgBoxPosY = Default $g__DlgBoxWidth = Default $g__DlgBoxHeight = Default For $i = 0 To UBound($g__aDlgBoxBtnText) - 1 $g__aDlgBoxBtnText[$i] = Default Next EndFunc ;==>_DlgBox_SetDefaults Func __DlgBox_CbtHookProc($nCode, $wParam, $lParam) Local $tcw, $tcs Local $iSearch = 0 Local $ahBtn[$g__DlgBtnCount] If $nCode < 0 Then Return _WinAPI_CallNextHookEx($g__hHookDlgBox, $nCode, $wParam, $lParam) EndIf Switch $nCode Case 3 ;5=HCBT_CREATEWND If _WinAPI_GetClassName(HWnd($wParam)) = "#32770" Then ;Dialog window class $tcw = DllStructCreate($tagCBT_CREATEWND, $lParam) $tcs = DllStructCreate($tagCREATESTRUCT, DllStructGetData($tcw, "lpcs")) If $g__DlgBoxPosX <> Default Then DllStructSetData($tcs, "x", $g__DlgBoxPosX) If $g__DlgBoxPosY <> Default Then DllStructSetData($tcs, "y", $g__DlgBoxPosY) If $g__DlgBoxWidth <> Default Then DllStructSetData($tcs, "cx", $g__DlgBoxWidth) If $g__DlgBoxHeight <> Default Then DllStructSetData($tcs, "cy", $g__DlgBoxHeight) EndIf Case 5 ;5=HCBT_ACTIVATE If _WinAPI_GetClassName(HWnd($wParam)) = "#32770" Then ;Dialog window class For $i = 1 To $g__MaxDlgItemId If IsHWnd(_WinAPI_GetDlgItem($wParam, $i)) Then If $g__aDlgBoxBtnText[$iSearch] <> Default Then _WinAPI_SetDlgItemText($wParam, $i, $g__aDlgBoxBtnText[$iSearch]) $iSearch += 1 If $iSearch >= UBound($ahBtn) Then ExitLoop EndIf Next EndIf EndSwitch Return _WinAPI_CallNextHookEx($g__hHookDlgBox, $nCode, $wParam, $lParam) EndFunc ;==>__DlgBox_CbtHookProc Func __DlgBox_UnregisterHook() _WinAPI_UnhookWindowsHookEx($g__hHookDlgBox) DllCallbackFree($g__hProcDlgBox) EndFunc ;==>__DlgBox_UnregisterHook Func _WinAPI_SetDlgItemText($hDlg, $nIDDlgItem, $lpString) Local $aRet = DllCall('user32.dll', "int", "SetDlgItemText", _ "hwnd", $hDlg, _ "int", $nIDDlgItem, _ "str", $lpString) Return $aRet[0] EndFunc ;==>_WinAPI_SetDlgItemText Simple example to see how to use it #include "HookDlgBox.au3" _DlgBox_SetButtonNames("1", "two", "3") MsgBox(4, "Test 1", "Custom button texts") _DlgBox_SetPosition(20, 20) MsgBox(66, "Test 2", "Custom position and button texts") _DlgBox_SetButtonNames("Submit", "Don't submit", "Don't know") InputBox("Test 3", "Where were you born?", "Planet Earth") _DlgBox_SetSize(800, 800) InputBox("Test 4", "Where were you born?", "Planet Earth") _DlgBox_SetSize(Default, 800) MsgBox(66, "Test 5", "Strange but working") _DlgBox_SetButtonNames(Default, "Wait", "What?") _DlgBox_SetSize(Default, Default) _DlgBox_SetPosition(500, 500) MsgBox(66, "Test 6", "So far so good!") _DlgBox_SetDefaults() MsgBox(6, "Test 7", "Default position and button texts") Hope you like it. Best regards funkey HookDlgBox Example.au3 HookDlgBox.au3
    1 point
×
×
  • Create New...