Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/24/2019 in all areas

  1. My new 256-cubit quantum computer gives Time = 0.0 for all five. What gives?
    2 points
  2. Released a new update earlier today and would appreciate it if everyone would test the following new functions and review the coding to make sure that I haven't messed something up 😁 -- _WD_IsLatestRelease() _WD_UpdateDriver($sBrowser[, $sInstallDir = Default[, $lFlag64 = Default[, $lForce = Default]]]) Also, there were fixes / enhancements to some of the existing routines related to properly detecting and reporting timeouts. Please let me know if you run into any issues.
    1 point
  3. TheSaint

    _ReadIniSectionNames

    I tried that, but it went too overboard ... way too many keys per section. Keys are not that relevant to the issue, and neither is file size. Here is my simpler version, which is one key per section. #include <Array.au3> IniWriteTEST_2() Exit Func IniWriteTEST_2() Local $inifle = @ScriptDir & "\Testing_2.ini" Local $file = FileOpen($inifle, 1) If $file <> -1 Then For $i = 1 To 3000 ;IniWrite($inifle, "Section_" & $i, "key", "1234567890abcdef") FileWrite($file, "[Section_" & $i & "]" & @CRLF) FileWrite($file, "key=1234567890abcdef" & @CRLF) ConsoleWrite("Section_" & $i & @CRLF) Next FileClose($file) Local $value = IniRead($inifle, "Section_3000", "key", "") MsgBox(262192, "Last Section", "key = " & $value) Local $sections = IniReadSectionNames($inifle) _ArrayDisplay($sections) MsgBox(262192, "Last Section Name Reported", $sections[0]) ; NOTE - Limit for IniReadSectionNames is 32767 characters. Local $count = StringLen(_ArrayToString($sections, "|", 1)) MsgBox(262192, "Character Count", $count & " characters in Section Names!") EndIf EndFunc ;==>IniWriteTEST_2 Of those 3,000 sections, only the first 2,605 were returned for me in _ArrayDisplay, where the count [0] was also 2,605. This is with Windows 7 32 Bit. So IniReadSectionNames is definitely limited. 32,757 characters was returned, as the next section name would have taken it over the 32,767 limit. File size is 441 Kb. Opening the 'Testing_2.ini' file with SciTE, you can see that all 3,000 sections and keys exist. So it is only that one INI function that appears to be limited. Writing and Reading still work.
    1 point
  4. Progh0st

    _ReadIniSectionNames

    try this: Func MyIniReadSectionNames($Path) $File = FileRead($Path) If Not @error Then $Str = StringRegExp($File, "(?m)^\[{1}([^\[\]]+)\]{1}", 3) If IsArray($Str) Then $ArraySize = UBound($Str) Local $Array[$ArraySize] For $i = 0 To $ArraySize-1 $Array[$i] = $Str[$i] Next Return $Array EndIf EndIf EndFunc It will match anything between [....] For Section names only. Hopefully. Test speed please 😃 A little faster, using it directly like (seadoggie01) Func MyIniReadSectionNames($Path) $File = FileRead($Path) If Not @error Then $Str = StringRegExp($File, "(?m)^\[{1}([^\[\]]+)\]{1}", 3) If IsArray($Str) Then Return $Str EndIf EndIf EndFunc
    1 point
  5. TheDcoder

    _ReadIniSectionNames

    Good to see that my Array approach ins't falling behind too much with a consistent 2nd position Also surprised to see that RegEx is slower than _ArrayAdd
    1 point
  6. While I don't have a 1 Mb Ini file to test it on, it looks like this RegEx is simpler and faster at least on smaller files (210 Kb) by ~20 milliseconds (with file handles or the file name) Func _Ini_ReadSectionNames($sFileName) ;~ If Not FileExists($sFileName) Then Return SetError(1, 0, False) Local $sContents = FileRead($sFileName) ; (?m) - Allows new lines to be used ; ^ - Starting at the beginning of a line ; \[ - Match an open square bracket ; ([^\]]+) - Capture everything that isn't a closing square bracket (at least 1 character) ; \] - Match a closing square bracket ; \s* - Match as much blank space as you need, Taylor ; $ - Match the end of a line Local $aSections = StringRegExp($sContents, "(?m)^\[([^\]]+)\]\s*$", 3) Return SetError(@error, @extended, $aSections) EndFunc I ran some tests, but I'm not the expert of giant files Edit: Just realized that you return a 1-based array. Mine's 0-based (personal preference, it's in my ini file). It also works with brackets strewn about in the data.
    1 point
  7. Progh0st

    _ReadIniSectionNames

    Simple and faster... #include <Array.au3> #include <StringConstants.au3> ;For $i = 1 To 1000 ; IniWrite("TestIni.ini", "Numbers " & $i, "Results " & $i, $i) ;Next $Path = "TestIni.ini" $time = TimerInit() MyIniReadSectionNames($Path) MsgBox(0,"","My Example: " & TimerDiff($time)) $time = TimerInit() _ReadIniSectionNamesTheSaint($Path) MsgBox(0,"","TheSaint Example: " & TimerDiff($time)) $time = TimerInit() _ReadIniSectionNamesTheDcoder($Path) MsgBox(0,"","TheDcoder Example: " & TimerDiff($time)) Func MyIniReadSectionNames($Path) FileReadToArray($Path) Local $Array[@extended/2] $File = FileRead($Path) If Not @error Then $Str = StringRegExp($File, "(?!\[).+(?=\])", 3) If IsArray($Str) Then For $i = 0 To UBound($Str)-1 $Array[$i] = $Str[$i] Next Return $Array EndIf EndIf EndFunc Func _ReadIniSectionNamesTheSaint($INIfile) $INIread = FileRead($INIfile) $INIlines = StringSplit($INIread, @LF, 1) If @error Then Return SetError(1, 0, -1) Else $SectionNames = "" For $i = 1 To $INIlines[0] $linetxt = $INIlines[$i] If StringLeft($linetxt, 1) = "[" Then $INIsection = StringTrimLeft($linetxt, 1) $INIsection = StringStripCR($INIsection) $INIsection = StringTrimRight($INIsection, 1) If $INIsection <> "" Then If $SectionNames = "" Then $SectionNames = $INIsection Else $SectionNames = $SectionNames & "|" & $INIsection EndIf EndIf EndIf Next If $SectionNames = "" Then Return SetError(2, 0, -2) Else $SectionNames = StringSplit($SectionNames, "|", 1) Return $SectionNames EndIf EndIf EndFunc ;=> _ReadIniSectionNames Func _ReadIniSectionNamesTheDcoder($INIfile) $INIread = FileRead($INIfile) Local $iSectionCount = StringCount($INIread, '[') Local $aSections[$iSectionCount + 1] $aSections[0] = 0 $INIlines = StringSplit($INIread, @LF, 1) If @error Then Return SetError(1, 0, -1) Else For $i = 1 To $INIlines[0] $linetxt = $INIlines[$i] If StringLeft($linetxt, 1) = "[" Then $INIsection = StringTrimLeft($linetxt, 1) $INIsection = StringStripCR($INIsection) $INIsection = StringTrimRight($INIsection, 1) If $INIsection <> "" Then $aSections[0] += 1 $aSections[$aSections[0]] = $INIsection EndIf EndIf Next If $aSections[0] = 0 Then Return SetError(2, 0, -2) Else If $aSections[0] < $iSectionCount Then ReDim $aSections[$aSections[0] + 1] Return $aSections EndIf EndIf EndFunc ;=> _ReadIniSectionNames Func StringCount($sMasterString, $sString) Local $iPos = 0 Local $iCount = 0 While True $iPos = StringInStr($sMasterString, $sString, $STR_NOCASESENSEBASIC, 1, $iPos + 1) If @error Or $iPos = 0 Then ExitLoop $iCount += 1 WEnd Return $iCount EndFunc
    1 point
  8. Perfect. Play with this early Xmas toy and think how the global idea can fit your use case for storage/querying best. I didn't have enough clues about your actual requirements so my tentative may focus too much on language for example but ignore other aspects important to you; again I set this up quite fast as a basic sample. Be aware that there are a lot more features in SQLite, like FTS tables (Full Text Search), virtual tables and support for add-on functions. The joined archive contains one extension of mine (unifuzz), which offers several string functions to help dealing with Unicode, like fuzzy search (Typos), Latin languages unaccentuation, language-agnostic collations and more. The C source is included. The DLL is 32-bit but I know others have compiled it for x64. You can "auto-load" this extension in Expert so it's always transparently available. Another useful extension is regex, a PCRE implementation 100% compatible with what's behind AutoIt StringRegex(). I also have extensions providing math functions, hash (MD5) and others, but those aren't going to be very useful to you right now. Use x86 versions of SQLite Expert to use that stuff out of the zip. Don't hesitate to ring my bell for help in designing your schema or any other aspect of SQLite. The SQLite website is also of great help. Also remember that SQLite is by far the most widespread RDBMS in the world ever, one of the most ubiquitous piece of software along with curl and ziplib and runs on any hardware/software platform you can think of and any SQLite DB file is portable on every implementation. In fact you unknowingly use SQLite daily: you smart TV, GPS, smartphone, modern modem/router, tablet, PC, applications (Firefox, Win 10, all Adobe, ...) all use SQLite with probability > 98%. unifuzz.zip sqlite3-pcre.zip
    1 point
  9. This works properly (red retangle) on my system (Win7 x64 + Aero): #include <WinApi.au3> #include <Misc.au3> #include <Array.au3> #include <WindowsConstants.au3> #include <GuiConstantsEx.au3> _Singleton(@ScriptFullPath) Global $iCtrlOrder = 1, $iLayers, $sLayersNN, $hTopControl, $iUpVal = 0, $iTTx, $iTTy Local $aMouse, $tPoint, $hWnd, $hNextWin, $windowList, $hControl, $iPosX, $iPosY, $hOldTopControl = 0, $x, $y Local $aPos, $sClassNN, $sClass, $iCount, $iId, $sCtrl, $aPos, $aWinList, $aUniqList, $iInstances, $iStart Local $aClassNNList, $tRect, $sWin, $ExitBut, $WinClass, $WinAtPtFlag Local Const $frame_size = 3 Local $hGUI_Mark = GUICreate("", 0, 0, 0, 0, $WS_POPUP, $WS_EX_TOPMOST + $WS_EX_TOOLWINDOW), $x1, $x2, $y1, $y2, $x1o, $y1o GUISetBkColor(0xFF0000, $hGUI_Mark) GUISetState() HotKeySet("!h", "_Help") HotKeySet("!s", "_CtrlOrder") HotKeySet("!q", "_Exit") HotKeySet("!{UP}", "_UpLayers") HotKeySet("!{DOWN}", "_UpLayers") While 1 $tPoint = _WinAPI_GetMousePos() $x = DllStructGetData($tPoint, "x") $y = DllStructGetData($tPoint, "y") If ($x <> $iTTx Or $y <> $iTTy) Then $WinAtPtFlag = 0 $iUpVal = 0 $hWnd = _WinAPI_GetAncestor(_WinAPI_WindowFromPoint($tPoint), 2); 2 = $GA_ROOT $WinClass = _WinAPI_GetClassName($hWnd) $hNextWin = "" $hTopControl = "" ; -------- ClassNN List ------------------------------ $windowList = WinGetClassList($hWnd) ;ConsoleWrite($windowList & @LF) $aWinList = StringRegExp($windowList, "[^\v]+", 3) $aUniqList = _ArrayUnique($aWinList) ;_ArrayDisplay($aUniqList) If IsArray($aUniqList) Then For $j = 1 To $aUniqList[0] StringRegExpReplace($windowList, "(?sm)^(" & $aUniqList[$j] & ")$", "") ; The number of replacements performed is stored in @extended. $iInstances = @extended ;ConsoleWrite($aUniqList[$j] & " " & $iInstances & @LF) For $k = $iInstances To 1 Step -1 $iStart = StringInStr($windowList, $aUniqList[$j] & @LF, 2, $k) $windowList = StringRegExpReplace($windowList, "(?sm)^(.{" & $iStart - 1 & "}^" & $aUniqList[$j] & ")$", "${1}" & $k) Next Next ;ConsoleWrite($windowList & @LF & "-----------" & @LF) $aClassNNList = StringRegExp($windowList, "[^\v]+", 3) ; --------> End of ClassNN List ------------------------------ ; --------- Get all layers under Mouse ---------------- $iLayers = 0 $sLayersNN = "" For $j = 0 To UBound($aClassNNList) - 1 $hControl = ControlGetHandle($hWnd, "", $aClassNNList[$j]) ;ConsoleWrite($aClassNNList[$j] & " " & $hControl & @LF) $tRect = _WinAPI_GetWindowRect($hControl) If ControlCommand($hWnd, "", $aClassNNList[$j], "IsVisible") And _ ; Check if control is visible under mouse DllStructGetData($tRect, "Left") <= $x And DllStructGetData($tRect, "Right") >= $x And _ ; Check if control is under mouse DllStructGetData($tRect, "Top") <= $y And DllStructGetData($tRect, "Bottom") >= $y Then $sLayersNN &= @TAB & @TAB & @TAB & $aClassNNList[$j] & @TAB & $hControl & @TAB & @LF ; Add ClassnameNN & Ctrl handle to string. $iLayers += 1 ; Number of controls (layers) If $iCtrlOrder = 0 And $iLayers = 1 Then ; After Alt+s keys has been pressed, the top most control is the first control encountered. $hTopControl = $hControl $sClassNN = $aClassNNList[$j] ElseIf $iCtrlOrder <> 0 Then ; Before Alt+s keys is pressed, the top most control is the last control encountered in the For-Next loop. $hTopControl = $hControl $sClassNN = $aClassNNList[$j] EndIf #cs ; _WinAPI_GetWindow() was found not to be useful in this application. ConsoleWrite($aClassNNList[$j] & " HWNDFIRST: " & _WinAPI_GetWindow($hControl & $iCount, 0) & _ " HWNDLAST: " & _WinAPI_GetWindow($hControl & $iCount, 1) & _ " HWNDNEXT: " & _WinAPI_GetWindow($hControl & $iCount, 2) & _ " HWNDPREV: " & _WinAPI_GetWindow($hControl & $iCount, 3) & _ " OWNER: " & _WinAPI_GetWindow($hControl & $iCount, 4) & _ " CHILD: " & _WinAPI_GetWindow($hControl & $iCount, 5) & @LF) #ce ;ConsoleWrite("From Pt " & _WinAPI_WindowFromPoint($tPoint)& @LF) EndIf Next ;ConsoleWrite("-------------------" & @LF) ; -----> End of "Get all layers under Mouse" ---------------- EndIf ; ------------- Gather all info for Tooltip -------------- $sWin = ">>>>Window<<<< Press Alt+h for Help" & @LF & _ "Title:" & @TAB & WinGetTitle("[Handle:" & $hWnd & "]", "") & @LF & _ "Class:" & @TAB & $WinClass & @LF & _ "Handle:" & @TAB & $hWnd & @LF & @LF & _ ">>>>Mouse<<<< " & @LF & _ "Absolute Position: " & DllStructGetData($tPoint, "x") & ", " & DllStructGetData($tPoint, "y") & @LF _WinAPI_ScreenToClient($hTopControl, $tPoint) If $hTopControl = "" Then ; Window only - no controls under mouse. $sCtrl = "" $tRect = _WinAPI_GetWindowRect($hWnd) Else $tRect = _WinAPI_GetWindowRect($hTopControl) $iId = _WinAPI_GetDlgCtrlID($hTopControl) If $iId = 0 Then $iId = "" $aPos = ControlGetPos($hWnd, "", $sClassNN) $sCtrl = @LF & _ ">>>>Control<<<< " & @LF & _ "ClassNameNN:" & @TAB & $sClassNN & @LF & _ "ID:" & @TAB & @TAB & $iId & @LF & _ "Handle:" & @TAB & @TAB & $hTopControl & @LF & _ "Position:" & @TAB & @TAB & $aPos[0] & ", " & $aPos[1] & "; Abs:" & DllStructGetData($tRect, "Left") & ", " & DllStructGetData($tRect, "Top") & @LF & _ "Size:" & @TAB & @TAB & $aPos[2] & ", " & $aPos[3] & @LF & _ "ControlClick Coords: " & DllStructGetData($tPoint, "x") & ", " & DllStructGetData($tPoint, "y") & @LF & _ "No. of Ctrl Layers under Mouse: " & @TAB & $iLayers & @LF If $iLayers > 1 Then $sCtrl &= "Ctrl Layers ClassNN/Hnd:- " & @LF & $sLayersNN EndIf ; ----- Tooltip ---- $aPos = MouseGetPos() $iPosX = ($aPos[0] - 400) * ($aPos[0] > @DesktopWidth - 400) + ($aPos[0] <= @DesktopWidth - 400) * ($aPos[0] + 20) $iPosY = ($aPos[1] - 400) * ($aPos[1] > @DesktopHeight - 400) + ($aPos[1] <= @DesktopHeight - 400) * ($aPos[1] + 20) ; ---> Eng of Tooltip ---- $iTTx = $x ; For "If ($x <> $iTTx Or $y <> $iTTy) Then" line @ top of While loop - Steadies tooltip display. $iTTy = $y If $hOldTopControl <> $hTopControl Then ; - Steadies red outline display. _WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), 0, 0, $RDW_INVALIDATE + $RDW_ALLCHILDREN) ; Clears Red outline graphics. $hOldTopControl = $hTopControl EndIf ;~ _DrawtRect($tRect) $x1 = DllStructGetData($tRect, "Left") $y1 = DllStructGetData($tRect, "Top") $x2 = DllStructGetData($tRect, "Right") $y2 = DllStructGetData($tRect, "Bottom") If $x1 <> $x1o Or $y1 <> $y1o Then ToolTip($sWin & $sCtrl, $iPosX, $iPosY) WinMove($hGUI_Mark, "", $x1, $y1, $x2 - $x1, $y2 - $y1) _GuiHole($hGUI_Mark, $frame_size, $frame_size, ($x2 - $x1) - 2 * $frame_size, ($y2 - $y1) - 2 * $frame_size, ($x2 - $x1), ($y2 - $y1)) GUISetState(@SW_SHOW, $hGUI_Mark) WinSetOnTop($hGUI_Mark, 0, 1) $x1o = $x1 $y1o = $y1 EndIf EndIf Sleep(30) WEnd Func _GuiHole($hWnd, $i_x, $i_y, $i_sizew, $i_sizeh, $width, $height) Local $outer_rgn, $inner_rgn, $combined_rgn $outer_rgn = _WinAPI_CreateRectRgn(0, 0, $width, $height) $inner_rgn = _WinAPI_CreateRectRgn($i_x, $i_y, $i_x + $i_sizew, $i_y + $i_sizeh) $combined_rgn = _WinAPI_CreateRectRgn(0, 0, 0, 0) _WinAPI_CombineRgn($combined_rgn, $outer_rgn, $inner_rgn, $RGN_DIFF) _WinAPI_DeleteObject($outer_rgn) _WinAPI_DeleteObject($inner_rgn) _WinAPI_SetWindowRgn($hWnd, $combined_rgn) EndFunc ;==>_GuiHole Func _Help() Local $myedit, $msg, $Text ToolTip("") $Text = @LF & @TAB & @TAB & @TAB & _ " Hot Keys" & @LF & @LF & _ " Press Alt + s keys toggles reversing the detection order of the" & @LF & _ " layered controls. (If a control that the mouse" & @LF & _ " is hovering is not being selected but the control " & @LF & _ " at the bottom of the layers is selected, pressing the" & @LF & _ " Alt+s keys may enable that top control to be selected.);" & @LF & @LF & _ ' Press Alt + UP keys when the Alt + s keys are in the "have not been pressed' & @LF & _ ' state". Each Alt+UP keys press selects in green the' & @LF & _ " next below layered control. At the bottom of the" & @LF & _ ' tooltip each "Ctrl Layer" progressively climbs up' & @LF & _ " from the bottom of the red highlited control in the list." & @LF & @LF & _ ' Press Alt + DOWN keys when the Alt + s keys are in the "have been pressed' & @LF & _ ' state". Each Alt+Down keys press selects in green, for' & @LF & _ " 2 secs, the next below layered control. At the bottom of" & @LF & _ ' the tooltip each "Ctrl Layer" progressively decended away' & @LF & _ " from the top red highlited control in the list." & @LF & @LF & _ " Note: While scrolling up and down through the layers, the mouse must not move." & @LF & @LF & _ " Press Alt + q keys to quit;" & @LF & @LF & _ " Press Alt + h keys for this help window." GUICreate("Help Window", 450, 450) ; will create a dialog box that when displayed is centered GUISetFont(9) $myedit = GUICtrlCreateLabel($Text, 2, 0) $ExitBut = GUICtrlCreateButton('Continue', 190, 410, 70, 20) GUISetState() While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Or $msg = $ExitBut Then ExitLoop WEnd GUIDelete() EndFunc ;==>_Help Func _UpLayers() Local $aLay, $iIndex, $tRect, $tRectGrn, $iUbIndx ;ConsoleWrite(@HotKeyPressed & @LF) $iUpVal += 1 $aLay = StringRegExp($sLayersNN, "\h(0x[^\s]+)", 3) If IsArray($aLay) Then $iUbIndx = UBound($aLay) - 1 $iIndex = _ArraySearch($aLay, $hTopControl) ;if $iIndex < $iUbIndx then $iIndex += $iUpVal Switch @HotKeyPressed Case "!{UP}" If $iIndex - $iUpVal >= 0 Then $iIndex -= $iUpVal Else $iIndex = 0 EndIf Case "!{DOWN}" If $iIndex + $iUpVal <= $iUbIndx Then $iIndex += $iUpVal Else $iIndex = $iUbIndx EndIf EndSwitch $tRect = _WinAPI_GetWindowRect($hTopControl) $tRectGrn = _WinAPI_GetWindowRect($aLay[$iIndex]) ;ConsoleWrite($iUpVal & " " & $aLay[$iIndex] & @LF) _DrawtRect($tRect) _DrawtRect($tRectGrn, 0x00ff00) While Sleep(2000) = 0 WEnd _WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), 0, 0, $RDW_INVALIDATE + $RDW_ALLCHILDREN) EndIf EndFunc ;==>_UpLayers Func _CtrlOrder() If $iCtrlOrder = 1 Then ; Alt+S has not been pressed. $iCtrlOrder = 0 ; Means Alt+S has been pressed. Else $iCtrlOrder = 1 ; Alt+S is in not been pressed state. EndIf EndFunc ;==>_CtrlOrder ; Draws coloured rectangle on screen. Func _DrawtRect($tRect, $color = 0xFF, $PenWidth = 2) Local $hDC, $hPen, $obj_orig, $x1, $x2, $y1, $y2 $x1 = DllStructGetData($tRect, "Left") $x2 = DllStructGetData($tRect, "Right") $y1 = DllStructGetData($tRect, "Top") $y2 = DllStructGetData($tRect, "Bottom") $hDC = _WinAPI_GetWindowDC(0) ; DC of entire screen (desktop) $hPen = _WinAPI_CreatePen($PS_SOLID, $PenWidth, $color) $obj_orig = _WinAPI_SelectObject($hDC, $hPen) _WinAPI_DrawLine($hDC, $x1, $y1, $x2, $y1) ; horizontal to right _WinAPI_DrawLine($hDC, $x2, $y1, $x2, $y2) ; vertical down on right _WinAPI_DrawLine($hDC, $x2, $y2, $x1, $y2) ; horizontal to left right _WinAPI_DrawLine($hDC, $x1, $y2, $x1, $y1) ; vertical up on left ; clear resources _WinAPI_SelectObject($hDC, $obj_orig) _WinAPI_DeleteObject($hPen) _WinAPI_ReleaseDC(0, $hDC) EndFunc ;==>_DrawtRect Func _Exit() _WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), 0, 0, $RDW_INVALIDATE + $RDW_ALLCHILDREN) Exit EndFunc ;==>_Exit Btw, do you know how I can check whether a frame has a scrollbar? E.g. if you open the help file you will see on the right frame a scrollbar.... Br, UEZ
    1 point
×
×
  • Create New...