Leaderboard
Popular Content
Showing content with the highest reputation on 03/19/2015 in all areas
-
Xbase I/O - transfer data between dbf file and array
boomingranny reacted to RTFC for a topic
This is basically two functions (plus supporting infrastructure): _Xbase_ReadToArray($filename, Byref $array, [...]) _Xbase_WriteFromArray($filename, Byref $array, [...]) that transfer all data from one container to the other. Various optional formatting parameters are detailed in the Remarks section of the script; a small test script plus dbf test file (the latter from the (free) Harbour distribution, see here) are provided for your entertainment. Note that the $array variable has to exist already, as it's parsed ByRef, but it does not have to have the correct dimensions. This is pure AutoIt (no SQL, no ADO, no dlls, no external dependencies). The Xbase specification was gleaned from here. There is no support (either currently or planned) for a GUI, or additional functionality; it's just a simple data interface I needed for my MatrixFileConverter for Eigen4Autoit (link in signature), that might be of use to others (see MatrixFileConverter.au3 for an implementation example). One thing to keep in mind is AutoIt's array size limitation (16 MB elements); Xbase files can be considerably larger. On the other hand, AutoIt arrays are less restricted in their number of columns than (certain versions of) Xbase (see script for details). Appropriate error messages will inform you when you've hit these buffers. Xbase.v0.8.7z third beta release1 point -
GUIListViewEx - Deprecated Version
dynamitemedia reacted to Melba23 for a topic
dynamitemedia, Indeed. When you initiated the ListView, you asked the UDF not to use a count element (you set the $iStart parameter to 0) so the returned array does not have the count in the [0] element. AutoIt expects the values of loops to be numeric and so it converts $aLV_List_Right[0] to a number - as the content is a string this returns "0". Thus your loop tries to run from 1 to 0 - and as a result does not run at all. If you were to code the loop as follows: For $i = 0 To UBound($aLV_List_Right) - 1 $test = "video '" & $fullPath & "\" & $aLV_List_Right[$i] & "'" ConsoleWrite($test & @CRLF) Next you should get what you require. M231 point -
AD UDF - Performance improvements
mLipok reacted to JLogan3o13 for a topic
An increase of 5x speed is always worth a minor script modification on my part, in my humble opinion.1 point -
Look here at my simple example: EDIT: If you need it to hide GUI after launch of application then do this before main GUI loop: - remove GuiSetState() - add TrayShow(1)1 point
-
Here is an example that shows the potential of this method. A virtual listview is filled with 10 columns and 10000/50000/100000 rows. All items are drawn with a random background color. I think it's pretty impressive. #include <GUIConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <GuiTab.au3> Opt( "MustDeclareVars", 1 ) Global $hGui, $hLV, $aItems[100000][10], $aColors[100000][10], $iRows Global $tText = DllStructCreate( "wchar[100]" ) Example() Func Example() ; Create GUI $hGui = GUICreate( "Virtual listview", 850, 400 ) ; Create Tab Local $idTab = GUICtrlCreateTab( 10, 10, 850-20, 400-20 ) GUICtrlCreateTabItem( "10000 rows" ) GUICtrlCreateTabItem( "50000 rows" ) GUICtrlCreateTabItem( "100000 rows" ) GUICtrlCreateTabItem( "" ) ; Create ListView Local $idLV = GUICtrlCreateListView( "", 20, 40, 850-40, 400-60, $LVS_OWNERDATA, BitOR( $WS_EX_CLIENTEDGE, $LVS_EX_DOUBLEBUFFER, $LVS_EX_FULLROWSELECT ) ) $hLV = GUICtrlGetHandle ( $idLV ) For $i = 0 To 9 _GUICtrlListView_AddColumn( $hLV, "Col" & $i, 75 ) Next GUIRegisterMsg( $WM_NOTIFY, "WM_NOTIFY" ) GUISetState( @SW_SHOW ) $iRows = 10000 FillArray( $iRows ) FillColors( $iRows ) GUICtrlSendMsg( $idLV, $LVM_SETITEMCOUNT, $iRows, 0 ) ; Message loop While 1 Switch GUIGetMsg() Case $idTab Switch GUICtrlRead( $idTab ) Case 0 $iRows = 10000 Case 1 $iRows = 50000 Case 2 $iRows = 100000 EndSwitch FillArray( $iRows ) FillColors( $iRows ) GUICtrlSendMsg( $idLV, $LVM_SETITEMCOUNT, $iRows, 0 ) Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd EndFunc Func FillArray( $iRows ) For $i = 0 To $iRows - 1 If Not Mod( $i, 10000 ) Then _ WinSetTitle( $hGui, "", "Virtual listview. Fills arrays: " & $i & " rows" ) For $j = 0 To 9 $aItems[$i][$j] = $i & "|" & $j Next Next If Not Mod( $i, 10000 ) Then _ WinSetTitle( $hGui, "", "Virtual listview: " & $i & " rows" ) EndFunc Func FillColors( $iRows ) Local $aItemCols = [ 0xCCCCFF, 0xCCFFFF, 0xCCFFCC, 0xFFFFCC, 0xFFCCCC, 0xFFCCFF ] ; BGR For $i = 0 To $iRows - 1 If Not Mod( $i, 10000 ) Then _ WinSetTitle( $hGui, "", "Virtual listview. Fills arrays: " & $iRows & " rows and " & $i & " colors" ) For $j = 0 To 9 $aColors[$i][$j] = $aItemCols[Random(0,5,1)] Next Next If Not Mod( $i, 10000 ) Then _ WinSetTitle( $hGui, "", "Virtual listview: " & $iRows & " rows and " & $i & " colors" ) EndFunc Func WM_NOTIFY( $hWnd, $iMsg, $wParam, $lParam ) #forceref $hWnd, $iMsg, $wParam Local $tNMHDR, $hWndFrom, $iCode $tNMHDR = DllStructCreate( $tagNMHDR, $lParam ) $hWndFrom = HWnd( DllStructGetData( $tNMHDR, "hWndFrom" ) ) $iCode = DllStructGetData( $tNMHDR, "Code" ) Switch $hWndFrom Case $hLV Switch $iCode Case $LVN_GETDISPINFOW ; Fill virtual listview Local $tNMLVDISPINFO = DllStructCreate( $tagNMLVDISPINFO, $lParam ) If BitAND( DllStructGetData( $tNMLVDISPINFO, "Mask" ), $LVIF_TEXT ) Then Local $sItem = $aItems[DllStructGetData($tNMLVDISPINFO,"Item")][DllStructGetData($tNMLVDISPINFO, "SubItem")] DllStructSetData( $tText, 1, $sItem ) DllStructSetData( $tNMLVDISPINFO, "TextMax", StringLen( $sItem ) ) DllStructSetData( $tNMLVDISPINFO, "Text", DllStructGetPtr( $tText ) ) EndIf Case $NM_CUSTOMDRAW Local $tNMLVCUSTOMDRAW = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam) Local $dwDrawStage = DllStructGetData($tNMLVCUSTOMDRAW, "dwDrawStage") Switch $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 BitOR( $CDDS_ITEMPREPAINT, $CDDS_SUBITEM ) ; Before painting a subitem ;Local $iItem = DllStructGetData($tNMLVCUSTOMDRAW, "dwItemSpec") ; Item index ;Local $iSubItem = DllStructGetData($tNMLVCUSTOMDRAW, "iSubItem") ; Subitem index ;DllStructSetData( $tNMLVCUSTOMDRAW, "ClrTextBk", $aColors[$iItem][$iSubItem] ) ; Backcolor of item/subitem DllStructSetData( $tNMLVCUSTOMDRAW, "ClrTextBk", $aColors[DllStructGetData($tNMLVCUSTOMDRAW, "dwItemSpec")][DllStructGetData($tNMLVCUSTOMDRAW, "iSubItem")] ) Return $CDRF_NEWFONT ; $CDRF_NEWFONT must be returned after changing font or colors EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc1 point
-
Real-time Line Counter
jaberwacky reacted to Melba23 for a topic
jaberwacky & dreamzboy, I would do it this way: Case $button $count = ControlCommand("Host Count", "", $hostEdit, "GetLineCount", "") GUICtrlSetData($label, $count) M231 point -
Here you go (3.3.10 or later) #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <Array.au3> Global $aFirstArray[10][5] = [["Type1", "Subtype1", 10, 1, 0.1],["Type1", "Subtype2", 20, 2, 0.2], _ ["Type1", "Subtype3", 30, 3, 0.3],["Type2", "Subtype4", 40, 4, 0.4], _ ["Type2", "Subtype5", 50, 5, 0.5],["Type3", "Subtype5", 60, 6, 0.6], _ ["Type4", "Subtype6", 70, 7, 0.7],["Type4", "Subtype7", 80, 8, 0.8], _ ["Type5", "Subtype8", 90, 9, 0.9],["Type5", "Subtype9", 100, 10, 0.0]] ;_ArrayDisplay($aFirstArray, "First") Local $iCols = UBound($aFirstArray, 2) - 1 Local $aResult[UBound($aFirstArray) * 2][$iCols], $sLast, $n = 0 For $x = 2 To $iCols $sLast = "" $n = 0 For $i = 0 To UBound($aFirstArray) - 1 If $aFirstArray[$i][0] <> $sLast Or $n = 0 Then $sLast = $aFirstArray[$i][0] $aResult[$n][0] = $sLast ; Add Type to array $n += 1 $aResult[$n][0] = $aFirstArray[$i][1] ; Add Subtype to array $aResult[$n][$x - 1] = $aFirstArray[$i][$x] ; Add Value to array Else $aResult[$n][0] = $aFirstArray[$i][1] ; Add Subtype to array $aResult[$n][$x - 1] = $aFirstArray[$i][$x] ; Add Value to array EndIf $n += 1 Next Next ReDim $aResult[$n][$iCols] ;_ArrayDisplay($aResult, "Second") ; Adding The values of subtypes $iTotalIndex = 0 $iTotalValue = 0 $iCols = UBound($aResult, 2) - 1 For $x = 1 To $iCols $iTotalIndex = 0 $iTotalValue = 0 For $i = 1 To UBound($aResult) - 1 If $aResult[$i][$x] <> "" Then $iTotalValue += $aResult[$i][$x] ; Add value of Subtype Else $aResult[$iTotalIndex][$x] = $iTotalValue ; Insert total of subtype values into parent type $iTotalValue = 0 ; Reset Total $iTotalIndex = $i ; Remember index of lat parent type EndIf Next $aResult[$iTotalIndex][$x] = $iTotalValue ; Insert last total of subtype values into parent type Next ;_ArrayDisplay($aResult, "Third") ; All colors in BGR ; Colors for types/subtypes in col 0 Global $aColTypes = [ 0xADDEFF, 0xFFFFE0, 0xC1B6FF, 0xFFFF00, 0xFF0000, 0xFFFF00 ], $iColTypes = 0 Global $iWhite = 0xFFFFFF, $iRed = 0xCCCCFF, $iGreen = 0xCCFFCC ; Color array $iRows = UBound($aResult) $iCols = UBound($aResult, 2) Global $aColors[$iRows][$iCols] ; Fill color array For $i = 0 To $iRows - 1 If StringLeft( $aResult[$i][0], 4 ) = "Type" Then $iColorCol0 = $aColTypes[$iColTypes] $iColTypes += 1 EndIf $aColors[$i][0] = $iColorCol0 $aColors[$i][1] = $iWhite For $j = 2 To $iCols - 1 $aColors[$i][$j] = $aResult[$i][$j-1] > $aResult[$i][$j] ? $iRed : $iGreen Next Next ;_ArrayDisplay($aColors, "Colors") ; Listview GUICreate("Listview", 400, 300) $idLV = GUICtrlCreateListView("col0 |col1|col2|col3", 10, 10, 380, 280) $hLV = GUICtrlGetHandle( $idLV ) For $i = 0 To $iRows - 1 $s = $aResult[$i][0] For $j = 1 To $iCols - 1 $s &= "|" & $aResult[$i][$j] Next GUICtrlCreateListViewItem($s, $idLV) Next GUIRegisterMsg( $WM_NOTIFY, "WM_NOTIFY" ) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $tNMHDR, $hWndFrom, $iCode $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hLV Switch $iCode Case $NM_CUSTOMDRAW Local $tNMLVCUSTOMDRAW = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam) Local $dwDrawStage = DllStructGetData($tNMLVCUSTOMDRAW, "dwDrawStage") Switch $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 BitOR( $CDDS_ITEMPREPAINT, $CDDS_SUBITEM ) ; Before painting a subitem ;Local $iItem = DllStructGetData($tNMLVCUSTOMDRAW, "dwItemSpec") ; Item index ;Local $iSubItem = DllStructGetData($tNMLVCUSTOMDRAW, "iSubItem") ; Subitem index ;DllStructSetData( $tNMLVCUSTOMDRAW, "ClrTextBk", $aColors[$iItem][$iSubItem] ) ; Backcolor of item/subitem DllStructSetData( $tNMLVCUSTOMDRAW, "ClrTextBk", $aColors[DllStructGetData($tNMLVCUSTOMDRAW, "dwItemSpec")][DllStructGetData($tNMLVCUSTOMDRAW, "iSubItem")] ) Return $CDRF_NEWFONT ; $CDRF_NEWFONT must be returned after changing font or colors EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc1 point
-
A listview is the proper control. It is very easy to code with an array to hold the colors, and it will be lightning fast. I'll show some code tomorrow.1 point
-
That Hotkey doesn't do didly. try this one liner script: MsgBox(0, "", "I LOVE AUTOIT") run it and hit ESC. same result. MsgBox() is a blocking Function so cannot be closed with a hotkey. Build your own GUI msgbox if anything like this is required. Jos1 point