Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/17/2023 in all areas

  1. Jos

    gui skin builder

    Please don't post these kind of post. Only report in case you really can't suppress the urge to do something about it. thanks!
    1 point
  2. How is this different from your prior thread?
    1 point
  3. Shark007

    WINMM.DLL Media Player

    Thanks for sharing! Using the script in the 1st post tagged with, (Updated at 07:30 of May 31, 2023 UTC) In this release, I have not added any GUI scaling at all. I opted to just do some subtle changes to the main GUI only to make it more presentable with all Windows Display Scaling presentations. I tested it with 100 % all the way through to 225 % scaling. @CYCho, I suggest you review the subtle changes I have made in this release and consider adopting them into your own. Attachment removed.
    1 point
  4. pixelsearch

    Txt split to ini file

    @ioa747 I tried to improve the processing time of the script, in case there are plenty of users (100, 500 you name it) and a big datalar.txt file, like the one provided by mucitbey last year, which had 6.535 lines and generated 75 ini files (from 30/05/2022 to 12/08/2022 included) In my precedent script (and probably yours) I found the 2 instructions that slowed the damn thing : * IniWrite is slow, when there are plenty of sections, probably because the file is opened and closed for each Iniwrite, idk. * _ArraySearch is slow too (e.g GetUserIndex) Retrieving constantly a user name (while providing his ID) is slow when we have to loop through all rows of an array, again and again. _ArrayBinarySearch would certainly retrieve the name faster So, this is what I did to get super quick results, even on thousands of lines in Datalar.txt * No more IniWrite, but FileWriteLine, as you will notice in the script below. * Scripting.Dictionary object (instead of _ArraySearch) which retrieves a username at the speed of light. Also, Scripting.Dictionary can be used for other interesting purposes (like $oData in the script) Here are some notes concerning the 2 major arrays and 2 dictionaries objects found in the script below : $aUser[ ][4] ============ $aUser[ ][0] = User ID (unique) $aUser[ ][1] = User Name (unique, as Name is also, unfortunately, a unique section in daily .ini files) $aUser[ ][2] = Time1 (if empty, then user was absent this day, this will be useful to add absents in LV) $aUser[ ][3] = Time2 (if filled, then Time1 is already filled, e.g user ID found twice in $adata for same day) $oUser() ======== Key = User ID (unique) . Same number of Keys as $aUser number of rows Item = Index of this User in $aUser, it will allow an immediate search in $aUser, instead of slow _ArraySearch $aData[ ][5] ============ $aData[ ][0] = unused $aData[ ][1] = User ID (not unique, usually same ID found twice each day) $aData[ ][2] = unused $aData[ ][3] = Date (same date on contiguous rows, processed day by day) $aData[ ][4] = Time1 OR Time2 (this column is already sorted for same day) $oData() ======== Key = User ID (unique). Used when day changes, to add at once in LV all daily workers, sorted by day & time. Item = Index of this User in $aUser, it will allow an immediate search in $aUser, instead of slow _ArraySearch #include <File.au3> #include <MsgBoxConstants.au3> #include <SendMessage.au3> Opt("MustDeclareVars", 1) Global $g_iLinesUser, $g_idListview Main() Func Main() Local $aUser, $aUserBackup, $oUser, $aData, $oData Local $WM_SETREDRAW = 0x000B, $LVM_GETITEMCOUNT = 0X1004, $GUI_EVENT_CLOSE = -3 _FileReadToArray(@ScriptDir & "\" & "Users.txt", $aUser, $FRTA_NOCOUNT, "=") ; 2D array If @error Then Exit MsgBox($MB_TOPMOST, "_FileReadToArray error = " & @error, "Users.txt") $g_iLinesUser = UBound($aUser) ReDim $aUser[$g_iLinesUser][4] ; add 2 empty columns at the right (to update time1 and time2 per user for 1 working day) $aUserBackup = $aUser ; keep a copy with last 2 empty columns for all users. Reuse this backup when date changes. $oUser = ObjCreate("Scripting.Dictionary") Fill_oUser($aUser, $oUser) _FileReadToArray(@ScriptDir & "\" & "Datalar.txt", $aData, $FRTA_NOCOUNT) ; 1D array If @error Then Exit MsgBox($MB_TOPMOST, "_FileReadToArray error = " & @error, "Datalar.txt") $oData = ObjCreate("Scripting.Dictionary") Local $hGUI = GUICreate("", 470, 500, -1, -1) ; title later, to include number of rows in it $g_idListview = GUICtrlCreateListView("CART ID | DATE|TIME-1 |TIME-2 |NAME AND SURNAME ", 10, 10, 450, 480) Local $hListview = GUICtrlGetHandle($g_idListview) _SendMessage($hListview, $WM_SETREDRAW, False) ; _GUICtrlListView_BeginUpdate . False = don't redraw after a change Local $sDate = "", $aTemp, $iEmptyRows, $UserIndex For $li = 0 To UBound($aData) - 1 $aTemp = StringSplit(StringStripWS($aData[$li], 1+2), ", ", $STR_NOCOUNT) ; strip leading (1) and trailing (2) eventual white space If @error Then ContinueLoop ; eliminate accidental blank lines. Help file StringSplit: "@error = 1 when no delimiters were found" If StringLen($aTemp[3]) < 10 Then $aTemp[3] = "0" & $aTemp[3] ; days "1" to "9" will become "01" to "09" everywhere in the script. If $sDate <> $aTemp[3] Then ; $sDate is the old date, $aTemp[3] is the new date. If $sDate Then ; always False when $li = 0 (first data line processed) ; Update LV : add all working users for 1 day, then add all absents for 1 day . Prepare ini file for 1 day (all users) DayChange($sDate, $aUser, $oData) ; Reuse $aUserBackup (before processing a new date) $aUser = $aUserBackup ; reuse backup, e.g. blank columns 2 & 3 in $aUser, for all users, when date changes. $g_iLinesUser = UBound($aUser) ; as it may have increased in Func GetUserIndex (if an eventual ID wasn't found in $aUser) ; If undefined ID's had been added to $oUser, then re-generate $oUser (this shouldn't happen, according to mucitbey) If $oUser.Count <> $g_iLinesUser Then $oUser.RemoveAll() Fill_oUser($aUser, $oUser) EndIf ; remove all keys in $oData (before processing a new date) $oData.RemoveAll() ; add 1 empty line between each day processed in LV (sort of vertical separator) GUICtrlCreateListViewItem("", $g_idListview) $iEmptyRows += 1 ; don't count this line in the total number of lines in LV (displayed later in GUI title) EndIf $sDate = $aTemp[3] ; old date = new date EndIf $UserIndex = GetUserIndex($aTemp[1], $aUser, $oUser) ; user index (row) in $aUser If Not $oData.Exists($aTemp[1]) Then ; 1st entry for this ID (will update column Time1 in $aUser) $aUser[$UserIndex][2] = $aTemp[4] ; time1 $oData.Add($aTemp[1], $UserIndex) ; key = User ID, item = User index in $aUser Else ; 2nd entry for this ID (it will update column Time2 in $aUser) $aUser[$UserIndex][3] = $aTemp[4] ; time2 EndIf Next If $sDate Then DayChange($sDate, $aUser, $oData) _SendMessage($hListview, $WM_SETREDRAW, True) ; _GUICtrlListView_EndUpdate . True = redraw after a change Local $iNbRows = GUICtrlSendMsg($g_idListview, $LVM_GETITEMCOUNT, 0, 0) WinSetTitle($hGUI, "", "_ank_ File Splitting (" & ($iNbRows - $iEmptyRows) & " rows)") GUISetState(@SW_SHOW, $hGUI) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE ; Cleaning (not really necessary but ok) $oUser = 0 ; force Object deletion (AutoIt help file, topic "Obj/COM Reference") $oData = 0 ; ditto GUIDelete($hGUI) EndFunc ;==>Main ;================================================ Func GetUserIndex($ID, ByRef $aUser, ByRef $oUser) If $oUser.Exists($ID) Then Local $iIndex = $oUser.Item($ID) ; $iIndex in $aUser of regular ID Else ; this should never happen (mucitbey) but better prevent it, just in case... Local $iIndex = $g_iLinesUser ; $iIndex in $aUser of Undefined ID ; add the Undefined ID in $aUser $g_iLinesUser += 1 ReDim $aUser[$g_iLinesUser][4] ; not really fast but as it should never happen... $aUser[$iIndex][0] = $ID $aUser[$iIndex][1] = "Undefined ID " & $ID ; this creates a unique "name" (+++) ; add the Undefined ID in $oUser $oUser.Add($ID, $iIndex) ; key = User Undefined ID, item = User index in $aUser EndIf Return $iIndex ; 0+ EndFunc ;==>GetUserIndex ;================================================ Func DayChange($sDate, ByRef $aUser, ByRef $oData) ; Update LV : add all working users for 1 day ; Color eventually background of LV rows Local $aPresent = $oData.Keys(), $iIndex For $i = 0 To Ubound($aPresent) - 1 $iIndex = $oData.Item($aPresent[$i]) ; $iIndex in $aUser of an ID GUICtrlCreateListViewItem($aUser[$iIndex][0] &"|"& $sDate &"|"& _ $aUser[$iIndex][2] &"|"& $aUser[$iIndex][3] &"|"& $aUser[$iIndex][1], $g_idListview) ; color eventually background of this LV row If StringLeft($aUser[$iIndex][1], 12) = "Undefined ID" Then GUICtrlSetBkColor(-1, 0xFF0000) ; red ElseIf ($aUser[$iIndex][2] > "08:10:00" And $aUser[$iIndex][2] < "17:00:00") _ OR ($aUser[$iIndex][3] > "08:10:00" And $aUser[$iIndex][3] < "17:00:00") Then GUICtrlSetBkColor(-1, 0xC0FFFF) ; light blue EndIf Next ; Prepare .ini file for 1 day (all users) ; Update LV : add all absents for 1 day Local $sIniFile = @ScriptDir & "\" & $sDate & ".ini" Local $hIni = FileOpen($sIniFile, $FO_OVERWRITE + $FO_UNICODE) ; more reliable than $FO_ANSI If $hIni = -1 Then Exit MsgBox($MB_TOPMOST, "FileOpen error", $sIniFile) For $i = 0 To $g_iLinesUser - 1 FileWriteLine($hIni, _ "[" & $aUser[$i][1] & "]" & @crlf & _ ; ini section = [User Name] "Value01=" & $aUser[$i][0] & @crlf & _ ; User ID "Value02=" & $sDate & @crlf & _ ; Date "Value03=" & $aUser[$i][2] & @crlf & _ ; Time1 "Value04=" & $aUser[$i][3] & @crlf) ; Time2 If Not $aUser[$i][2] Then ; user was absent that day (as he got no time1) ; add 1 line in ListView for the absent user (with blank time1 & time2) GUICtrlCreateListViewItem($aUser[$i][0] &"|"& $sDate &"|"& "" &"|"& "" &"|"& $aUser[$i][1], $g_idListview) EndIf Next FileClose($hIni) EndFunc ;==>DayChange ;================================================ Func Fill_oUser(ByRef $aUser, ByRef $oUser) For $i = 0 To $g_iLinesUser - 1 $oUser.Add($aUser[$i][0], $i) ; key = User ID, item = User index in $aUser (immediate retrieve of a user in $aUser, instead of slow _ArraySearch) Next EndFunc ;==>Fill_oUser My only regret ? I wish I used the Scripting.Dictionary Object a long time ago, it's damn quick and easy to use
    1 point
  5. Here is part of a environment variable udf that I started working on. ConsoleWrite("System Path = " & _EnvVarGet("Path", 2) & @CRLF & @CRLF) ConsoleWrite("User Path = " & _EnvVarGet("Path", 3) & @CRLF & @CRLF) ; #FUNCTION# ==================================================================================================================== ; Name ..........: _EnvVarGet ; Description ...: Get Environment Variables ; Syntax ........: _EnvVarGet($_sEnvVarGet[, $_iEnvVarType = 3[, $_bExpVarValue = False]]) ; Parameters ....: $_sEnvVarGet - Environment variable name ; : $_iEnvVarType - [optional] Environment variable type. Default is 3. ; : - 0 - Returns Enviroment variable from all profile types ; : - 1 - Process Enviornment Variable ; : - 2 - System Enviornment Variable ; : - 3 - User Enviornment Variable (default) ; : - 4 - Volatile Enviornment Variable ; : $_bExpVarValue - [optional] Expand Environment Variables within result. Default is False. ; Return values .: ; : Flag: $_iEnvVarType ; : - 0 - Returns Enviroment variable from all profile types as an array ; : - 1 - Process Enviornment Variable as a string ; : - 2 - System Enviornment Variable as a string ; : - 3 - User Enviornment Variable as a string ; : - 4 - Volatile Enviornment Variable as a string ; Author ........: Subz ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _EnvVarGet($_sEnvVarGet, $_iEnvVarType = 3, $_bExpVarValue = False) Local $iExpandEnvStrings = Opt("ExpandEnvStrings") Local $sEnvVarValue, $aEnvVarValue[5] = [4] Local $oEnvVarType, $aEnvVarType[5] = [4, "PROCESS", "SYSTEM", "USER", "VOLATILE"] Local $oWshShell = ObjCreate("WScript.Shell") Switch $_iEnvVarType Case 0 If $_bExpVarValue == True Then Opt("ExpandEnvStrings", 1) For $i = 1 To $aEnvVarType[0] $oEnvVarType = $oWshShell.Environment($aEnvVarType[$i]) $aEnvVarValue[$i] = $oEnvVarType($_sEnvVarGet) Next Opt("ExpandEnvStrings", $iExpandEnvStrings) Return $aEnvVarValue Case 1 To 4 If $_bExpVarValue == True Then Opt("ExpandEnvStrings", 1) $oEnvVarType = $oWshShell.Environment($aEnvVarType[$_iEnvVarType]) $sEnvVarValue = $oEnvVarType($_sEnvVarGet) Opt("ExpandEnvStrings", $iExpandEnvStrings) Return $sEnvVarValue Case Else Return SetError(1, 0, "") EndSwitch EndFunc
    1 point
  6. Yashied

    WinAPIEx UDF

    LAST VERSION - 3.8 03-Jul-12 This library contains the WinAPI functions are not included for unknown reasons to the native AutoIt WinAPI library. I use this UDF in nearly all of my programs, and decided to share it with the AutoIt community. I agree that over time some of these functions will be part of the native AutoIt library, but still... The library includes some undocumented, but useful functions (eg _WinAPI_GetFontResourceInfo()). The library also contains all the necessary constants to work with the appropriate functions. Most functions from this UDF intended for experienced users, but beginners will find the same lot of useful information for yourself. I will be to periodically add new functions to the library. The archive contains WinAPIEx library, and as usual an excellent examples from me. Some examples I took from this forum and to simplify them for better understanding. For those who use SciTE (full version) I have prepared the au3.userudfs.properties and au3.user.calltips.api files to highlight functions from this UDF in your scripts. Just copy this files to ...SciTEProperties and ...SciTEAPI, respectively. I hope this UDF will be useful for many as for me. I look forward to any feedback and suggestions. Maybe somebody wants to add new WinAPI functions? Credits Available functions Files to download WinAPIEx UDF v3.8 for AutoIt 3.3.6.1 Previous downloads: 27953 WinAPIEx UDF v3.8 for AutoIt 3.3.8.x Previous downloads: 14850
    1 point
  7. I have used it this way before: $a = "|Test|Test2|Test3|Test4|" $b = "Test2" If StringInStr($a, "|" & $b & "|") Then ConsoleWrite("True" & @CR) Else ConsoleWrite("False" & @CR) EndIf
    1 point
×
×
  • Create New...