Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/23/2021 in all areas

  1. Source: https://forum.dtw.tools/d/26-easycodeit-update-our-hand-written-parser-is-going-away Also don't forget to make an account at the forum if you want to catch all of my updates on the latest... you can also do other stuff, but that is up to you.
    2 points
  2. Column alignment #AutoIt3Wrapper_Au3Check_Parameters=-d -w- 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_UseX64=Y Opt( "MustDeclareVars", 1 ) #include <ComboConstants.au3> #include <EditConstants.au3> #include <GuiListView.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include "RandomArray.au3" Global $g_iRows = 1000, $g_iCols = 6, $g_aArray, $g_aSubArray, $g_tIndex = DllStructCreate( "uint arr[" & $g_iRows & "]" ), $g_tDefaultIndex, $g_aIndex[$g_iCols], $g_aIndexTemp[$g_iCols], $g_iSortDir Global $g_aColNames[$g_iCols] = [ "Strings", "Integers", "Floats", "Dates", "Times", "R/C" ], $g_aColWidths[$g_iCols] = [ 230, 61, 124, 70, 60, 60 ], $g_aColAligns[$g_iCols] = [ $HDF_CENTER, $HDF_RIGHT, $HDF_RIGHT, $HDF_RIGHT, $HDF_RIGHT, $HDF_RIGHT ] ; $HDF_LEFT, $HDF_RIGHT, $HDF_CENTER Global $g_hGui, $g_idListView, $g_hListView, $g_hHeader, $g_idMarker, $g_hEdit, $g_idEditDummy, $g_idComboCol, $g_idComboColDummy Global $g_sSearch, $g_iSearchCol, $g_iSearch = $g_iRows Example() Func Example() ; Generate array & one index Generate_All( $g_aArray ) $g_aSubArray = $g_aArray $g_tDefaultIndex = $g_tIndex ; Create GUI $g_hGui = GUICreate( "Virtual and Custom Drawn List View With Sorting and Incremental Search", 630 + 20, 788 + 30 + 20 ) ; Create Edit control ( search ) + dummy control Local $idEdit = GUICtrlCreateEdit( "", 120, 10, 305, 20, BitXOR( $GUI_SS_DEFAULT_EDIT, $WS_HSCROLL, $WS_VSCROLL ) ) $g_hEdit = GUICtrlGetHandle( $idEdit ) $g_idEditDummy = GUICtrlCreateDummy() ; Create ComboBox control ( how to search : RegEx or Normal ? ) Local $idSearchHow = GUICtrlCreateCombo( "RegEx search", 11, 9, 100, 20, BitOR( $GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST ) ) Local $sSearchHow = "RegEx search", $sSearchHowPrev = $sSearchHow ; Default way of searching ( changeable ) GUICtrlSetData( $idSearchHow, "Normal search", $sSearchHow ) ; Create ComboBox control ( column where to search ) + dummy control GUICtrlCreateLabel( "Col", 429, 10, 20, 20, BitOR( $SS_CENTERIMAGE, $SS_CENTER ) ) $g_idComboCol = GUICtrlCreateCombo( "0", 452, 9, 41, 20, BitOR( $GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST ) ) $g_iSearchCol = 0 ; Default column where to search ( changeable ) Local $iSearchColPrev = $g_iSearchCol For $i = 1 To $g_iCols - 1 GUICtrlSetData( $g_idComboCol, $i & "|", $g_iSearchCol ) Next $g_idComboColDummy = GUICtrlCreateDummy() ; Create Label control ( number of matching results ) Local $idResult = GUICtrlCreateLabel( " " & $g_iRows & " rows ( no pattern )", 501, 10, 135, 20, BitOR( $SS_CENTERIMAGE, $SS_SUNKEN ) ) ; Create ListView $g_idListView = GUICtrlCreateListView( "", 10, 40, 630, 788, BitOr( $GUI_SS_DEFAULT_LISTVIEW, $LVS_OWNERDATA ), $WS_EX_CLIENTEDGE ) _GUICtrlListView_SetExtendedListViewStyle( $g_idListView, BitOr( $LVS_EX_DOUBLEBUFFER, $LVS_EX_FULLROWSELECT ) ) $g_hListView = GUICtrlGetHandle( $g_idListView ) $g_hHeader = _GUICtrlListView_GetHeader( $g_idListView ) For $i = 0 To $g_iCols - 1 _GUICtrlListView_AddColumn( $g_idListView, $g_aColNames[$i], $g_aColWidths[$i] ) _GUICtrlHeader_SetItemFormat( $g_hHeader, $i, $HDF_STRING + $g_aColAligns[$i] ) Next ; No ListView column resizing by dragging header dividers ;_WinAPI_SetWindowLong( $hHeader, $GWL_STYLE, _WinAPI_GetWindowLong( $hHeader, $GWL_STYLE ) + $HDS_NOSIZING ) ; AutoIt 3.3.14.5 issue DllCall( "user32.dll", "long_ptr", @AutoItX64 ? "SetWindowLongPtrW" : "SetWindowLongW", "hwnd", $g_hHeader, "int", $GWL_STYLE, "long_ptr", _ DllCall( "user32.dll", "long_ptr", @AutoItX64 ? "GetWindowLongPtrW" : "GetWindowLongW", "hwnd", $g_hHeader, "int", $GWL_STYLE )[0] + $HDS_NOSIZING ) ; Create Marker ( an orange line placed above the header of the column being searched ) $g_idMarker = GUICtrlCreateLabel( "", 0, 0 ) GUICtrlSetBkColor( -1, 0xFFA060 ) ; Orange MoveMarker( $g_iSearchCol ) GUICtrlSendMsg( $g_idListView, $LVM_SETSELECTEDCOLUMN, $g_iSearchCol, 0 ) ; Sorting information $g_iSortDir = $HDF_SORTUP Local $iSortCol = 0, $iSortColPrev = 0 ; Register message handlers GUIRegisterMsg( $WM_NOTIFY, "WM_NOTIFY" ) GUIRegisterMsg( $WM_COMMAND, "WM_COMMAND" ) ; Allocate memory for ListView rows GUICtrlSendMsg( $g_idListView, $LVM_SETITEMCOUNT, $g_iRows, 0 ) ; Show GUI GUISetState( @SW_SHOW ) ; Main loop While 1 Switch GUIGetMsg() Case $g_idComboCol, $g_idComboColDummy, $idSearchHow $g_iSearchCol = GUICtrlRead( $g_idComboCol ) + 0 ; Return int $sSearchHow = GUICtrlRead( $idSearchHow ) Select Case $g_iSearchCol <> $iSearchColPrev MoveMarker( $g_iSearchCol ) ; Search column will be selected below, after ContinueCase $iSearchColPrev = $g_iSearchCol Case $sSearchHow <> $sSearchHowPrev $sSearchHowPrev = $sSearchHow Case Else ; No change in both Combo controls ( same search column, same search way ) ContinueLoop EndSelect ContinueCase Case $g_idEditDummy _GUICtrlHeader_SetItemFormat( $g_hHeader, $iSortCol, $HDF_STRING + $g_aColAligns[$iSortCol] ) $g_sSearch = GUICtrlRead( $idEdit ) $g_tIndex = $g_tDefaultIndex If $g_sSearch = "" Then ; Empty search string, display all rows $g_aSubArray = $g_aArray $g_iSearch = $g_iRows Else ; Find rows matching the search string $g_iSearch = 0 If $sSearchHow = "RegEx search" Then For $i = 0 To $g_iRows - 1 ; Duplicated For... Next for speed If StringRegExp( $g_aArray[$i][$g_iSearchCol], "(?i)" & $g_sSearch ) Then For $j = 0 To $g_iCols - 1 $g_aSubArray[$g_iSearch][$j] = $g_aArray[$i][$j] Next $g_iSearch += 1 EndIf Next Else ; "Normal search" For $i = 0 To $g_iRows - 1 ; Duplicated For... Next for speed If StringInStr( $g_aArray[$i][$g_iSearchCol], $g_sSearch ) Then For $j = 0 To $g_iCols - 1 $g_aSubArray[$g_iSearch][$j] = $g_aArray[$i][$j] Next $g_iSearch += 1 EndIf Next EndIf ; Delete eventual temporary subindexes For $i = 0 To $g_iCols - 1 If VarGetType( $g_aIndexTemp[$i] ) = "DLLStruct" Then $g_aIndexTemp[$i] = "" Next EndIf GUICtrlSendMsg( $g_idListView, $LVM_SETITEMCOUNT, $g_iSearch, 0 ) GUICtrlSendMsg( $g_idListView, $LVM_SETSELECTEDCOLUMN, $g_iSearchCol, 0 ) GUICtrlSetData( $idResult, " " & $g_iSearch & ( $g_sSearch = "" ? " rows ( no pattern )" : " matching rows" ) ) Case $g_idListView ; Sort $iSortCol = GUICtrlGetState( $g_idListView ) + 0 If $iSortCol <> $iSortColPrev Then _GUICtrlHeader_SetItemFormat( $g_hHeader, $iSortColPrev, $HDF_STRING + $g_aColAligns[$iSortColPrev] ) ; Set $g_tIndex + eventual update of $g_aIndexTemp[$iSortCol] OR $g_aIndex[$iSortCol] $i = GUICtrlRead( $idEdit ) ? UpdateIndex( $g_aIndexTemp, $iSortCol ) : UpdateIndex( $g_aIndex, $iSortCol ) $g_iSortDir = ( ( $iSortCol = $iSortColPrev ) ? ( $g_iSortDir = $HDF_SORTUP ? $HDF_SORTDOWN : $HDF_SORTUP ) : ( $HDF_SORTUP ) ) _GUICtrlHeader_SetItemFormat( $g_hHeader, $iSortCol, $HDF_STRING + $g_aColAligns[$iSortCol] + $g_iSortDir ) GUICtrlSendMsg( $g_idListView, $LVM_SETSELECTEDCOLUMN, $iSortCol, 0 ) GUICtrlSendMsg( $g_idListView, $LVM_SETITEMCOUNT, $g_iSearch, 0 ) $iSortColPrev = $iSortCol Case $GUI_EVENT_RESTORE ; Needed, or Marker goes back in 0, 0 after Restore ( why ? ) MoveMarker( $g_iSearchCol ) Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; Cleanup GUIDelete( $g_hGui ) EndFunc ;======================================================================== Func WM_NOTIFY( $hWnd, $iMsg, $wParam, $lParam ) Local $tNMHDR = DllStructCreate( $tagNMHDR, $lParam ) Switch HWnd( DllStructGetData( $tNMHDR, "hWndFrom" ) ) Case $g_hListView Switch DllStructGetData( $tNMHDR, "Code" ) Case $NM_CUSTOMDRAW Local $tCustDraw = DllStructCreate( $tagNMLVCUSTOMDRAW, $lParam ) Switch DllStructGetData( $tCustDraw, "dwDrawStage" ) ; Holds a value that specifies the drawing stage Case $CDDS_PREPAINT ; Before the paint cycle begins Return $CDRF_NOTIFYITEMDRAW ; Notify the parent window of any item-related drawing operations Case $CDDS_ITEMPREPAINT ; Before painting an item Return $CDRF_NOTIFYSUBITEMDRAW ; Notify the parent window of any subitem-related drawing operations Case $CDDS_ITEMPREPAINT + $CDDS_SUBITEM ; Before painting a subitem If ( DllStructGetData( $tCustDraw, "iSubItem" ) = $g_iSearchCol ) And $g_sSearch Then Return $CDRF_NOTIFYPOSTPAINT ; If $g_sSearch then paint $g_iSearchCol in postpaint stage Return $CDRF_NEWFONT ; $CDRF_NEWFONT must be returned after changing font or colors ; Paint all other columns in prepaint stage with default code Case $CDDS_ITEMPOSTPAINT + $CDDS_SUBITEM ; After painting a subitem ; Paints $g_iSearchCol ( $g_iSearchCol only ) if $g_sSearch Local Static $tRect = DllStructCreate( $tagRECT ), $pRect = DllStructGetPtr( $tRect ), $tSize = DllStructCreate( $tagSIZE ) Local Static $hBrushYellow = _WinAPI_CreateSolidBrush( 0x00FFFF ), $hBrushCyan = _WinAPI_CreateSolidBrush( 0xFFFF00 ) ; Yellow and cyan, BGR Local $iItem = DllStructGetData( $tCustDraw, "dwItemSpec" ), $hDC = DllStructGetData( $tCustDraw, "hDC" ) ; Subitem text and matching text Local $sSubItemText = $g_iSortDir = $HDF_SORTUP ? $g_aSubArray[$g_tIndex.arr($iItem+1)][$g_iSearchCol] _ : $g_aSubArray[$g_tIndex.arr($g_iSearch-$iItem)][$g_iSearchCol] Local $sMatch = StringRegExp( $sSubItemText, "(?i)" & $g_sSearch, 1 ), $extended = @extended, $iLen = StringLen( $sMatch[0] ) ; Entire subitem rectangle DllStructSetData( $tRect, 2, $g_iSearchCol ) ; Top DllStructSetData( $tRect, 1, $LVIR_BOUNDS ) ; Left GUICtrlSendMsg( $g_idListView, $LVM_GETSUBITEMRECT, $iItem, $pRect ) DllStructSetData( $tRect, 1, DllStructGetData( $tRect, 1 ) + 6 ) ; Left margin If Not $g_iSearchCol Then DllStructSetData( $tRect, 3, DllStructGetData( $tRect, 1 ) + GUICtrlSendMsg( $g_idListView, $LVM_GETCOLUMNWIDTH, 0, 0 ) ) ; If $g_iSearchCol = 0 (first column), the rectangle is calculated for the entire listview item. ; Compensate for this by setting the width of the rectangle to the width of the first column. ; Subitem rectangle for right and center aligned columns If $g_aColAligns[$g_iSearchCol] = $HDF_RIGHT Or $g_aColAligns[$g_iSearchCol] = $HDF_CENTER Then DllCall( "gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sSubItemText, "int", StringLen( $sSubItemText ), "struct*", $tSize ) ; _WinAPI_GetTextExtentPoint32 Switch $g_aColAligns[$g_iSearchCol] Case $HDF_RIGHT DllStructSetData( $tRect, "Left", DllStructGetData( $tRect, "Right" ) - DllStructGetData( $tSize, "X" ) - 6 ) Case $HDF_CENTER DllStructSetData( $tRect, "Left", DllStructGetData( $tRect, "Left" ) + ( DllStructGetData( $tRect, "Right" ) - DllStructGetData( $tRect, "Left" ) - DllStructGetData( $tSize, "X" ) ) / 2 - 3 ) EndSwitch EndIf ; Set transparent background for the subitem DllCall( "gdi32.dll", "int", "SetBkMode", "handle", $hDC, "int", $TRANSPARENT ) ; _WinAPI_SetBkMode ; Draw entire subitem text DllStructSetData( $tRect, 2, DllStructGetData( $tRect, 2 ) + 2 ) ; Top margin DllCall( "user32.dll", "int", "DrawTextW", "handle", $hDC, "wstr", $sSubItemText, "int", StringLen( $sSubItemText ), "struct*", $tRect, "uint", 0 ) ; _WinAPI_DrawText DllStructSetData( $tRect, 2, DllStructGetData( $tRect, 2 ) - 2 ) ; Top margin ; Rectangle for matching substring DllCall( "gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sSubItemText, "int", $extended - $iLen - 1, "struct*", $tSize ) ; _WinAPI_GetTextExtentPoint32 DllStructSetData( $tRect, "Left", DllStructGetData( $tRect, "Left" ) + DllStructGetData( $tSize, "X" ) ) DllCall( "gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sMatch[0], "int", $iLen, "struct*", $tSize ) ; _WinAPI_GetTextExtentPoint32 DllStructSetData( $tRect, "Right", DllStructGetData( $tRect, "Left" ) + DllStructGetData( $tSize, "X" ) ) ; Fill matching rectangle with yellow or cyan background color DllCall( "user32.dll", "int", "FillRect", "handle", $hDC, "struct*", $tRect, "handle", GUICtrlSendMsg( $g_idListView, $LVM_GETITEMSTATE, $iItem, $LVIS_SELECTED ) ? $hBrushYellow : $hBrushCyan ) ; _WinAPI_FillRect ; Redraw matching text on the yellow or cyan background DllStructSetData( $tRect, 2, DllStructGetData( $tRect, 2 ) + 2 ) ; Top margin DllCall( "gdi32.dll", "int", "SetTextColor", "handle", $hDC, "int", 0x000000 ) ; _WinAPI_SetTextColor DllCall( "user32.dll", "int", "DrawTextW", "handle", $hDC, "wstr", $sMatch[0], "int", $iLen, "struct*", $tRect, "uint", 0 ) ; _WinAPI_DrawText Return $CDRF_NEWFONT ; $CDRF_NEWFONT must be returned after changing font or colors EndSwitch Case $LVN_GETDISPINFOW Local $tNMLVDISPINFO = DllStructCreate( $tagNMLVDISPINFO, $lParam ) If ( $tNMLVDISPINFO.SubItem = $g_iSearchCol ) And $g_sSearch Then Return ; Don't paint $g_iSearchCol if $g_sSearch Local Static $tText = DllStructCreate( "wchar[50]" ), $pText = DllStructGetPtr( $tText ) Local $s = $g_iSortDir = 0x0400 ? DllStructSetData( $tText, 1, $g_aSubArray[$g_tIndex.arr($tNMLVDISPINFO.Item+1)][$tNMLVDISPINFO.SubItem] ) _ ; 0x0400 = $HDF_SORTUP : DllStructSetData( $tText, 1, $g_aSubArray[$g_tIndex.arr($g_iSearch-$tNMLVDISPINFO.Item)][$tNMLVDISPINFO.SubItem] ) DllStructSetData( $tNMLVDISPINFO, "Text", $pText ) EndSwitch Case $g_hHeader Switch DllStructGetData( $tNMHDR, "Code" ) Case $NM_RCLICK Local $aHit = _GUICtrlListView_SubItemHitTest( $g_hListView ) If $aHit[1] > - 1 Then ; Valid column GUICtrlSetData( $g_idComboCol, $aHit[1] ) GUICtrlSendToDummy( $g_idComboColDummy ) EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG #forceref $hWnd, $iMsg, $wParam, $s EndFunc Func WM_COMMAND( $hWnd, $iMsg, $wParam, $lParam ) Switch $lParam ; $hWndFrom Case $g_hEdit Switch BitShift( $wParam, 16 ) ; $iCode = High word Case $EN_CHANGE GUICtrlSendToDummy( $g_idEditDummy ) EndSwitch EndSwitch Return $GUI_RUNDEFMSG #forceref $hWnd, $iMsg EndFunc Func Generate_All( ByRef $g_aArray ) $g_aArray = FAS_Random2DArrayAu3( $g_iRows, "sifdtr", "abcdefghijklmnopqrstuvwxyz" ) For $i = 0 To $g_iRows - 1 $g_tIndex.arr( $i + 1 ) = $i Next EndFunc Func SortArrayStruct( $aArray, $iCol, $iRows ) Local Static $hDll = DllOpen( "kernel32.dll" ), $hDllComp = DllOpen( "shlwapi.dll" ) Local $tIndex = DllStructCreate( "uint arr[" & $iRows & "]" ), $pIndex = DllStructGetPtr( $tIndex ) ; Sorting by one column Local $lo, $hi, $mi For $i = 1 To $iRows - 1 $lo = 0 $hi = $i - 1 Do $mi = Int( ( $lo + $hi ) / 2 ) Switch DllCall( $hDllComp, 'int', 'StrCmpLogicalW', 'wstr', $aArray[$i][$iCol], 'wstr', $aArray[DllStructGetData($tIndex,1,$mi+1)][$iCol] )[0] Case -1 $hi = $mi - 1 Case 1 $lo = $mi + 1 Case 0 ExitLoop EndSwitch Until $lo > $hi DllCall( $hDll, "none", "RtlMoveMemory", "struct*", $pIndex + ( $mi + 1 ) * 4, "struct*", $pIndex + $mi * 4, "ulong_ptr", ( $i - $mi ) * 4 ) DllStructSetData( $tIndex, 1, $i, $mi + 1 + ( $lo = $mi + 1 ) ) Next Return $tIndex EndFunc Func UpdateIndex( ByRef $aIndex, $iCol ) If VarGetType( $aIndex[$iCol] ) = "DLLStruct" Then $g_tIndex = $aIndex[$iCol] Else $g_tIndex = SortArrayStruct( $g_aSubArray, $iCol, $g_iSearch ) $aIndex[$iCol] = $g_tIndex EndIf EndFunc Func MoveMarker( $iCol ) Local $aRect = _GUICtrlHeader_GetItemRect( $g_hHeader, $iCol ) ControlMove( $g_hGui, "", $g_idMarker, 10 + $aRect[0], 40 - 3, $aRect[2] - $aRect[0] + 1, 3 ) EndFunc The first column is centered. Other columns are right aligned. Note that alignment is set with the function _GUICtrlHeader_SetItemFormat(). ColAlign.7z Virtual listview
    2 points
  3. Jon

    Using AutoItX from C# / .Net

    The following files are provided to allow .NET use: AutoItX3.Assembly.dll - The .NET Assembly for using AutoItX.AutoItX3.Assembly.xml - The Visual Studio Intellisense help file for the .NET Assembly.AutoItX3.dll - The main AutoItX DLL (x86)AutoItX3_x64.dll - The main AutoItX DLL (x64)Using the Assembly from VB/C# within in Visual Studio is very easy: Add a reference to AutoItX3.Assembly.dll to your projectAdd a using AutoIt; statement in the files you want to use AutoIt functionsWrite code like this C# example:using AutoIt; ... // Wow, this is C#! AutoItX.Run("notepad.exe"); AutoItX.WinWaitActive("Untitled"); AutoItX.Send("I'm in notepad"); IntPtr winHandle = AutoItX.WinGetHandle("Untitled"); AutoItX.WinKill(winHandle);Distribute your final executable with the files AutoItX3.Assembly.dll, AutoItX3.dll, AutoItX3_x64.dll.
    1 point
  4. For an example on how to send and receive data between different instances of the same script and which passes commandline parameters to the first instance via WM_COPYDATA take a look at post 2. Just a short snippet which came to my mind as the _Singleton() standard UDF failed on my work-notebook for me (CreateMutexW returns winapi-error 126 - "The specified module could not be found" , I just assume it interferes with one of the 72 processes running). #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.0.0 Author: KaFu Script Function: _EnforceSingleInstance() function, Standard _Singleton() UDF failed on some machines for me #ce ---------------------------------------------------------------------------- _EnforceSingleInstance('e15ff08b-84ac-472a-89bf-5f92db683165') ; any 'unique' string; created with http://www.guidgen.com/Index.aspx MsgBox(0, "", "Test") Func _EnforceSingleInstance($GUID_Program) If $GUID_Program = "" Then Return SetError(1,'',1) if IsHWnd(WinGetHandle($GUID_Program)) then MsgBox(0,"Test","Second instance, will exit now...") Exit EndIf AutoItWinSetTitle($GUID_Program) Return WinGetHandle($GUID_Program) EndFunc ;==>_EnforceSingleInstance Should work as long as the key is really 'unique' (as unique as it gets ), and script is not complied as CUI (I'm not sure but I assume then there is no default AutoItWin).
    1 point
  5. No actual contradiction, as eloquently pointed out by @TheDcoder. Only an apparent contradiction, as interpreted by yours truly, in misreading @jpm’s response partially due to my conflation of Au3Check with AutoIt proper, and partially being blinded by an all-consuming giddiness over the prospect of all out lexical conflict. tl dr; Apologies, @Jos *And let this be a lesson to those who wish to wield weasel words wisely. Note the seemingly casual use of “apparent” in my OP, but now coming in quite handy by giving me the crux of my implied defense.
    1 point
  6. I recall you mentioned that a while ago when I was still looking for information to get started on writing the parser. Not really a surprise that the tools are common, because they are the best and somewhat de facto for writing parsers according to my research, still cool though @JockoDundee Thanks for your words... even though I didn't understand half of them Unfortunately I don't think it is the case here... you might have misunderstood what jpm said in the mentioned post. He said that Jon could give them "a copy of what is used in Au3Check" as AutoIt is not based on Lex and Yacc... which means while AutoIt itself doesn't use it, Au3Check (a separate program) does! Which is the same thing as what Jos said P.S Quite the coincidence that Jon decided to update the forum on the same day that I decided to post an update on the project
    1 point
  7. What again is the contradiction?
    1 point
  8. This is the following of a discussion we're having with Lion66 in LarsJ's thread. As the "light" script below isn't related to Virtual Listview any more, then it's better to create a new thread for this example. 2 basic functionalities : * Right-click on LV rows to display a context menu * Right-click on LV headers to switch from 1 column to the other (the "searched" column and its orange marker in other scripts) @Lion66 you can pick some parts of the code below (the ones related to the LV context menu) and adapt them to : * the incremental search scripts in Virtual listviews, with colored matches, found in LarsJ's thread. * or simply adapt them to your own scripts #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <GuiMenu.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Opt("MustDeclareVars", 1) Opt("GuiCloseOnESC", 0) Global $g_iRows = 1000, $g_iCols = 6, $g_iLeftLV = 10, $g_iTopLV = 40, $g_hGui, $g_hListView, $g_hHeader Global $g_aCols = ["Col 0", "Col 1", "Col 2", "Col 3", "Col 4", "Col 5"], $g_aWidths = [230, 61, 124, 70, 60, 60] Global $g_idListView, $g_idMarker, $g_idComboCol, $g_idComboColDummy, $g_iSearchCol Global $g_idContextDummy, $g_hContextmenu, $g_iItem = -1, $g_iSubItem = -1 Example() Func Example() ; Create GUI $g_hGui = GUICreate("Context menu in LV (not in headers)", 630+20, 582+30+20) ; Create Edit control (search) + dummy control Local $idEdit = GUICtrlCreateEdit("", 120, 10, 305, 20, BitXOR($GUI_SS_DEFAULT_EDIT, $WS_HSCROLL, $WS_VSCROLL)) ; Create ComboBox control (how to search : RegEx or Normal ?) Local $idSearchHow = GUICtrlCreateCombo("RegEx search", 11, 9, 100, 20, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST)) Local $sSearchHow = "RegEx search" GUICtrlSetData($idSearchHow, "Normal search", $sSearchHow) ; Create ComboBox control (column where to search) + dummy control GUICtrlCreateLabel("Col", 429, 10, 20, 20, BitOR($SS_CENTERIMAGE, $SS_CENTER)) $g_idComboCol = GUICtrlCreateCombo("0", 452, 9, 41, 20, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST)) $g_iSearchCol = 0 ; default column where to search (changeable) For $i = 1 To $g_iCols - 1 GUICtrlSetData($g_idComboCol, $i & "|", $g_iSearchCol) Next $g_idComboColDummy = GUICtrlCreateDummy() ; Create Label control (number of matching results) Local $idResult = GUICtrlCreateLabel(" " & $g_iRows & " rows (no pattern)", 501, 10, 135, 20, BitOR($SS_CENTERIMAGE, $SS_SUNKEN)) ; Create ListView $g_idListView = GUICtrlCreateListView( "", $g_iLeftLV, $g_iTopLV, 630, 582) $g_hListView = GUICtrlGetHandle($g_idListView) $g_hHeader = _GUICtrlListView_GetHeader($g_idListView) For $i = 0 To $g_iCols - 1 _GUICtrlListView_AddColumn($g_idListView, $g_aCols[$i], $g_aWidths[$i]) Next Local $sPrepareTxt For $i = 0 To $g_iRows - 1 $sPrepareTxt = "" For $j = 0 To $g_iCols - 1 $sPrepareTxt &= "R" & $i & "/C" & $j & "|" Next GUICtrlCreateListViewItem($sPrepareTxt, $g_idListview) Next ; Create Marker (an orange line placed above the header of the column being searched) $g_idMarker = GUICtrlCreateLabel("", 0, 0) GUICtrlSetBkColor(-1, 0xFFA060) ; orange _MoveMarker($g_iSearchCol) _GUICtrlListView_SetSelectedColumn($g_idListView, $g_iSearchCol) ; Create Context menu $g_idContextDummy = GUICtrlCreateDummy() Local $idContextMenu = GUICtrlCreateContextMenu($g_idContextDummy) Local $idContext1 = GUICtrlCreateMenuItem("Option 1", $idContextMenu) Local $idContext2 = GUICtrlCreateMenuItem("Option 2", $idContextMenu) Local $idContext3 = GUICtrlCreateMenuItem("Option 3", $idContextMenu) $g_hContextMenu = GuiCtrlGetHandle($idContextMenu) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $g_idComboCol, $g_idComboColDummy $g_iSearchCol = GUICtrlRead($g_idComboCol) _MoveMarker($g_iSearchCol) _GUICtrlListView_SetSelectedColumn($g_hListView, $g_iSearchCol) Case $g_idContextDummy _GUICtrlListView_SetSelectedColumn($g_hListView, $g_iSubItem) Local $iMenu_Choice = _TrackPopupMenu($g_hContextMenu, $g_hGui, MouseGetPos(0), MouseGetPos(1)) If $iMenu_Choice Then Switch $iMenu_Choice Case $idContext1 ConsoleWrite("Code for Option 1" & @lf) Case $idContext2 ConsoleWrite("Code for Option 2" & @lf) Case $idContext3 ConsoleWrite("Code for Option 3" & @lf) EndSwitch Local $sTextMenu = _GUICtrlMenu_GetItemText($g_hContextmenu, $iMenu_Choice, False) Local $sTextLV = _GUICtrlListView_GetItemText($g_hListView, $g_iItem, $g_iSubItem) MsgBox($MB_TOPMOST, $sTextMenu, "Row = " & $g_iItem & " Column = " & $g_iSubItem & " Text = " & $sTextLV & @lf) Else ConsoleWrite("Context menu cancelled by user" & @lf) Endif Case $GUI_EVENT_RESTORE ; needed, or Marker goes back in 0, 0 after Restore (why ?) _MoveMarker($g_iSearchCol) EndSwitch WEnd ; Cleanup GUIDelete($g_hGui) EndFunc ;==>Example ;======================================================================== Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) Switch HWnd(DllStructGetData($tNMHDR, "hWndFrom")) Case $g_hListView Switch DllStructGetData($tNMHDR, "Code") Case $NM_RCLICK Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam) $g_iItem = DllStructGetData($tInfo, "Index") If $g_iItem > -1 Then ; valid row $g_iSubItem = DllStructGetData($tInfo, "SubItem") GUICtrlSendToDummy($g_idContextDummy) EndIf EndSwitch Case $g_hHeader Switch DllStructGetData($tNMHDR, "Code") Case $HDN_ENDTRACKW, $HDN_DIVIDERDBLCLICKW ; let's forget $HDN_TRACKW... _MoveMarker(GUICtrlRead($g_idComboCol)) Case $NM_RCLICK Local $aHit = _GUICtrlListView_SubItemHitTest($g_hListView) ; $aHit[1] : 0-based index of the LV subitem... i.e. the column in our case (may be -1 if right click on empty part of header) If $aHit[1] > - 1 Then ; valid column GUICtrlSetData($g_idComboCol, $aHit[1]) GUICtrlSendToDummy($g_idComboColDummy) EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY ;======================================================================== Func _MoveMarker($iCol) Local $aRect = _GUICtrlHeader_GetItemRect($g_hHeader, $iCol) ControlMove($g_hGui, "", $g_idMarker, $g_iLeftLV + $aRect[0], $g_iTopLV - 3, $aRect[2] - $aRect[0] + 1, 3) EndFunc ;==>_MoveMarker ; ========================================================================================================================================= Func _TrackPopupMenu($hMenu, $hWnd, $iX, $iY) ; $TPM_RETURNCMD returns the menu item identifier of the user's selection in the return value. Return DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", $TPM_RETURNCMD, "int", $iX, "int", $iY, "hwnd", $hWnd, "ptr", 0)[0] EndFunc ;==>_TrackPopupMenu Note : nothing is "searched" in this example, which is based on the creation of a LV context menu which doesn't interfere with LV headers.
    1 point
  9. I love you admin, thanks.
    1 point
  10. The problem was solved: I went back to using the function _GetText... Instead _GUICtrlListView_GetItemText, as in the example. It's time to come up with additional LV use options and solve them. 😄 Thank you.
    1 point
  11. Somerset

    End line in section

    This person has not responded to a mod's open query.
    1 point
  12. yes, use a gui that’s not hidden
    1 point
  13. Rare is the moment when a humble member can seize on an apparent staff contradiction in an effort to trigger a game of mod vs. mod. Rarer still is the chance to lay the groundwork for an epic dev vs. dev clash...
    1 point
  14. Funny...lex & yacc is what is used already for parsing au3 files in au3check. Jos
    1 point
  15. Nah, by coming to terms with some of the nuances of writing a parser from tabla rasa, you'll be better equipped to integrate someone elses. I know what you mean. I hate learning someone else's holier than thou, be-all end-all, over-generalized abstraction with its inscrutably whimsical syntax, when I can be creating my own self-indulgent, turgid and pompus opus
    1 point
  16. I realized the search like this: I can't figure out how to mark the found rows in all columns at the same time. At this point my autoit knowledge is unfortunately at an end.
    1 point
  17. #include <ColorConstants.au3> #include <DateTimeConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPI.au3> Global $hGui Example() Func Example() $hGui = GUICreate("My GUI get time", 200, 200, 800, 200, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU)) ToggleColour() GUICtrlCreateGroup("Time", 8, 72, 153, 73) GUICtrlCreateLabel("Start:", 16, 94, 32, 17) GUICtrlCreateLabel("Stop:", 16, 118, 29, 17) Global $idTimeStart = GUICtrlCreateDate("", 56, 88, 89, 21, $DTS_TIMEFORMAT) Global $idTimeStop = GUICtrlCreateDate("", 56, 115, 89, 21, $DTS_TIMEFORMAT) GUISetState(@SW_SHOW) AdlibRegister(ToggleColour, 1000) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete() EndFunc ;==>Example Func ToggleColour() Local Static $bActive = False GUISetBkColor($bActive ? $COLOR_GREEN : $COLOR_RED) _WinAPI_RedrawWindow($hGui, 0, 0, $RDW_INVALIDATE+$RDW_ALLCHILDREN) $bActive = Not $bActive EndFunc
    1 point
  18. I was digging around some of my old code, and found this. Cleaned it up a little, and ensured it worked again. I used Call on these, so with one HMAC function, you could use different hashing algorithms. Course, you'll have to modify the BlockSize for some hashing functions, but that's easily made an optional parameter and passed in for the larger block sizes of some hashing functions. It's also just as easy to remove the calls for the actual hash functions, if that's what you want. #include <Crypt.au3> Func sha1($message) Return _Crypt_HashData($message, $CALG_SHA1) EndFunc Func md5($message) Return _Crypt_HashData($message, $CALG_MD5) EndFunc Func hmac($key, $message, $hash="md5") Local $blocksize = 64 Local $a_opad[$blocksize], $a_ipad[$blocksize] Local Const $oconst = 0x5C, $iconst = 0x36 Local $opad = Binary(''), $ipad = Binary('') $key = Binary($key) If BinaryLen($key) > $blocksize Then $key = Call($hash, $key) For $i = 1 To BinaryLen($key) $a_ipad[$i-1] = Number(BinaryMid($key, $i, 1)) $a_opad[$i-1] = Number(BinaryMid($key, $i, 1)) Next For $i = 0 To $blocksize - 1 $a_opad[$i] = BitXOR($a_opad[$i], $oconst) $a_ipad[$i] = BitXOR($a_ipad[$i], $iconst) Next For $i = 0 To $blocksize - 1 $ipad &= Binary('0x' & Hex($a_ipad[$i],2)) $opad &= Binary('0x' & Hex($a_opad[$i],2)) Next Return Call($hash, $opad & Call($hash, $ipad & Binary($message))) EndFunc ConsoleWrite(hmac("key", "the", "sha1") & @CRLF) Edit: Firefox ate my post, had to fix...
    1 point
  19. And while playing around... here is a version which passes commandline parameters to first instance via WM_COPYDATA before exiting... Compile and start multiple times with different commandline parameters to see whats happening... #NoTrayIcon #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $hwnd_AutoIt = _EnforceSingleInstance('e15ff08b-84ac-472a-89bf-5f92db683165') ; any 'unique' string; created with http://www.guidgen.com/Index.aspx Opt("TrayIconHide", 1) $hGUI = GUICreate("My GUI " & $hwnd_AutoIt,300,300,Default,Default) ; will create a dialog box that when displayed is centered $label = GUICtrlCreateLabel($CmdLineRaw,10,10,300,100) GUISetState(@SW_SHOW) ; will display an empty dialog box ControlSetText($hwnd_AutoIt,'',ControlGetHandle($hwnd_AutoIt,'','Edit1'),$hGUI) ; to pass hWnd of main GUI to AutoIt default GUI GUIRegisterMsg($WM_COPYDATA, "WM_COPYDATA") While 1 sleep(10) $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd GUIDelete() Func _EnforceSingleInstance($GUID_Program = "") If $GUID_Program = "" Then Return $hwnd = WinGetHandle($GUID_Program) If IsHWnd($hwnd) Then $hwnd_Target = ControlGetText($hwnd,'',ControlGetHandle($hwnd,'','Edit1')) WM_COPYDATA_SendData(HWnd($hwnd_Target), $CmdLineRaw) Exit EndIf AutoItWinSetTitle($GUID_Program) Return WinGetHandle($GUID_Program) EndFunc ;==>_EnforceSingleInstance Func WM_COPYDATA($hWnd, $MsgID, $wParam, $lParam) ; http://www.autoitscript.com/forum/index.php?showtopic=105861&view=findpost&p=747887 ; Melba23, based on code from Yashied Local $tCOPYDATA = DllStructCreate("ulong_ptr;dword;ptr", $lParam) Local $tMsg = DllStructCreate("char[" & DllStructGetData($tCOPYDATA, 2) & "]", DllStructGetData($tCOPYDATA, 3)) $msg = DllStructGetData($tMsg, 1) if $msg = " " then GUICtrlSetData($label, "") else GUICtrlSetData($label, DllStructGetData($tMsg, 1)) endif Return 0 EndFunc ;==>WM_COPYDATA Func WM_COPYDATA_SendData($hWnd, $sData) If Not IsHWnd($hWnd) Then Return 0 if $sData = "" then $sData = " " Local $tCOPYDATA, $tMsg $tMsg = DllStructCreate("char[" & StringLen($sData) + 1 & "]") DllStructSetData($tMsg, 1, $sData) $tCOPYDATA = DllStructCreate("ulong_ptr;dword;ptr") DllStructSetData($tCOPYDATA, 2, StringLen($sData) + 1) DllStructSetData($tCOPYDATA, 3, DllStructGetPtr($tMsg)) $Ret = DllCall("user32.dll", "lparam", "SendMessage", "hwnd", $hWnd, "int", $WM_COPYDATA, "wparam", 0, "lparam", DllStructGetPtr($tCOPYDATA)) If (@error) Or ($Ret[0] = -1) Then Return 0 Return 1 EndFunc ;==>WM_COPYDATA_SendData
    1 point
×
×
  • Create New...