Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/14/2017 in all areas

  1. LarsJ

    SQLite performance

    You'll not get anything faster than this: #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 ;#AutoIt3Wrapper_UseX64=y #include <GUIConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <SQLite.au3> Opt( "MustDeclareVars", 1 ) Global $pTable, $iCols, $hLV Example() Func Example() _SQLite_Startup() _SQLite_Open( "random_data.db" ) Local $iRows Local $sSQL = "SELECT * FROM RandomData;" _SQLite_GetTableEx( -1, $sSQL, $pTable, $iRows, $iCols ) $pTable += $iCols * ( @AutoItX64 ? 8 : 4 ) GUICreate( "Virtual ListView", 1650, 800 ) Local $idLV = GUICtrlCreateListView( "", 10, 10, 1650-20, 800-20, $LVS_OWNERDATA, BitOR( $WS_EX_CLIENTEDGE, $LVS_EX_DOUBLEBUFFER, $LVS_EX_FULLROWSELECT ) ) $hLV = GUICtrlGetHandle( $idLV ) ; Virtual listview Reduces flicker For $i = 0 To $iCols - 1 _GUICtrlListView_AddColumn( $idLV, "Col" & $i, 160 ) Next GUICtrlSendMsg( $idLV, $LVM_SETITEMCOUNT, $iRows, 0 ) GUIRegisterMsg( $WM_NOTIFY, "WM_NOTIFY" ) GUISetState( @SW_SHOW ) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd $pTable -= $iCols * ( @AutoItX64 ? 8 : 4 ) _SQLite_FreeTable( $pTable ) _SQLite_Close() _SQLite_Shutdown() EndFunc Func WM_NOTIFY( $hWnd, $iMsg, $wParam, $lParam ) Static $iPtrSize = @AutoItX64 ? 8 : 4, $hDLL = DllOpen( "kernel32.dll" ), $aDisplay[100][$iCols], $iFrom, $iTo Static $tText = DllStructCreate( "wchar[4094]" ), $pText = DllStructGetPtr( $tText ) Static $tagNMLVCACHEHINT = $tagNMHDR & ";int iFrom;int iTo" 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 Local $tNMLVDISPINFO = DllStructCreate( $tagNMLVDISPINFO, $lParam ) If Not BitAND( DllStructGetData( $tNMLVDISPINFO, "Mask" ), 1 ) Then Return ; 1 = $LVIF_TEXT Local $iItem = DllStructGetData( $tNMLVDISPINFO, "Item" ) - $iFrom If $iItem < 0 Or $iItem > $iTo - $iFrom Then Return Local $iSubItem = DllStructGetData($tNMLVDISPINFO,"SubItem") Local $sItem = $aDisplay[$iItem][$iSubItem] Local $l = StringLen( $sItem ) DllStructSetData( $tText, 1, $sItem ) DllStructSetData( $tNMLVDISPINFO, "Text", $pText ) DllStructSetData( $tNMLVDISPINFO, "TextMax", ( $l <= 4094 ? $l : 4094 ) ) Return Case $LVN_ODCACHEHINT Local $tNMLVCACHEHINT = DllStructCreate( $tagNMLVCACHEHINT, $lParam ) $iFrom = DllStructGetData( $tNMLVCACHEHINT, "iFrom" ) $iTo = DllStructGetData( $tNMLVCACHEHINT, "iTo" ) Local $pFrom, $pStr, $iLen, $tWstr For $i = $iFrom To $iTo $pFrom = $pTable + $i * $iCols * $iPtrSize For $j = 0 To $iCols - 1 $pStr = DllStructGetData( DllStructCreate( "ptr", $pFrom + $j * $iPtrSize ), 1 ) $iLen = DllCall( $hDLL, "int", "MultiByteToWideChar", "uint", 65001, "dword", 0, "ptr", $pStr, "int", -1, "ptr", 0, "int", 0 )[0] $tWstr = DllStructCreate( "wchar[" & $iLen & "]" ) DllCall( $hDLL, "int", "MultiByteToWideChar", "uint", 65001, "dword", 0, "ptr", $pStr, "int", -1, "struct*", $tWstr, "int", $iLen ) $aDisplay[$i-$iFrom][$j] = DllStructGetData( $tWstr, 1 ) Next Next Return EndSwitch EndSwitch Return $GUI_RUNDEFMSG #forceref $hWnd, $iMsg, $wParam EndFunc Func _SQLite_GetTableEx( $hDB, $sSQL, ByRef $pTable, ByRef $iRows, ByRef $iCols ) If __SQLite_hChk($hDB, 2) Then Return SetError(@error, 0, $SQLITE_MISUSE) Local $tSQL8 = __SQLite_StringToUtf8Struct($sSQL) If @error Then Return SetError(3, @error, 0) Local $avRval = DllCall($__g_hDll_SQLite, "int:cdecl", "sqlite3_get_table", _ "ptr", $hDB, _ ; An open database "struct*", $tSQL8, _ ; SQL to be executed "ptr*", 0, _ ; Results of the query "int*", 0, _ ; Number of result rows "int*", 0, _ ; Number of result columns "long*", 0) ; Error msg written here If @error Then Return SetError(1, @error, $SQLITE_MISUSE) ; DllCall error $pTable = $avRval[3] $iRows = $avRval[4] $iCols = $avRval[5] EndFunc Func _SQLite_FreeTable( $pTable ) DllCall($__g_hDll_SQLite, "int:cdecl", "sqlite3_free_table", "ptr", $pTable) If @error Then Return SetError(1, @error, $SQLITE_MISUSE) ; DllCall error EndFunc
    2 points
  2. Melba23

    listview

    mnaboud76, How about using groups within the ListView: #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiListView.au3> Example() Func Example() Local $aInfo, $hImage, $idListview GUICreate("ListView Set Group Info", 400, 300) $idListview = GUICtrlCreateListView("", 2, 2, 394, 268) GUISetState(@SW_SHOW) ; Add columns _GUICtrlListView_AddColumn($idListview, "Column 1", 100) _GUICtrlListView_AddColumn($idListview, "Column 2", 100) _GUICtrlListView_AddColumn($idListview, "Column 3", 100) ; Add items _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0) _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1) _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2) _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1) _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1) _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2) ; Build groups _GUICtrlListView_EnableGroupView($idListview) _GUICtrlListView_InsertGroup($idListview, -1, 1, "Group 1") _GUICtrlListView_InsertGroup($idListview, -1, 2, "Group 2") _GUICtrlListView_SetItemGroupID($idListview, 0, 1) _GUICtrlListView_SetItemGroupID($idListview, 1, 2) _GUICtrlListView_SetItemGroupID($idListview, 2, 2) _GUICtrlListView_SetGroupInfo($idListview, 2, "Group 2", 0, $LVGS_COLLAPSIBLE) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example As you can see, group 2 can be expanded and collapsed as required. M23
    1 point
  3. Simpel

    replace url and split?

    Hi. Hope this will fit: (?i)(?m)^(?:https?:\/\/)?(?:www\.)?(\w[^\/]+) Conrad
    1 point
  4. One way to get around the problem is to run _ArrayDisplay in a new process and then transfer the array to the new process through a system global object created with AutoItObject: #include <GUIConstantsEx.au3> #include <AutoItObject.au3> Example() Func Example() _AutoItObject_StartUp() ; Register object to transfer data Local $sDataTransferObject = "DataTransferObject" Local $oDataTransferClass, $oDataTransferObject, $hDataTransferObject $oDataTransferClass = _AutoItObject_Class() $oDataTransferClass.AddProperty( "ArrayData" ) $oDataTransferObject = $oDataTransferClass.Object $hDataTransferObject = _AutoItObject_RegisterObject( $oDataTransferObject, $sDataTransferObject ) ; Create array Local $aArray[1000][8] For $i = 0 To 1000 - 1 For $j = 0 To 7 $aArray[$i][$j] = $i & "/" & $j Next Next ; Transfer data $oDataTransferObject.ArrayData = $aArray ; Open ArrayDisplay script Local $iPID = ShellExecute( "Display.au3" ) GUICreate("Example", 300, 200, 100, 100) Local $idButton = GUICtrlCreateButton("Button", 105, 85, 90, 30) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $idButton MsgBox( 0, "", "" ) Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd If $iPID Then ProcessClose($iPID) ; Unregister data transfer object _AutoItObject_UnregisterObject( $hDataTransferObject ) _AutoItObject_Shutdown() EndFunc Display.au3: #include <Array.au3> Example() Func Example() ; Data transfer object Local $sDataTransferObject = "DataTransferObject" Local $oDataTransferObject = ObjGet( $sDataTransferObject ) ; Get array Local $aArray = $oDataTransferObject.ArrayData _ArrayDisplay( $aArray ) EndFunc
    1 point
  5. mikell

    replace url and split?

    It's not very clear. Is this you want ? (first urls on the left) #Include <Array.au3> $aUrl = "https://www.autoitscript.com/testurlsimilar" & @CRLF & _ "https://www.autoitscript.com/autoitscript2.com/autoitscriptasdf.com" & @CRLF & _ "https://www.autoitscript3.com/autoitscript.com" & @CRLF & _ "https://www.autoitscript4.com/autoitscript5.com/autoitscript.com" $aArray = StringRegExp($aUrl, 'https?://[^/]+', 3) _ArrayDisplay($aArray)
    1 point
×
×
  • Create New...