jchd Posted September 5, 2014 Share Posted September 5, 2014 AFAIK Int64 are a problem for both scripting dict and our new Tables. That shouldn't be. Wrapping generic functions around that misfeature will be another headache. And we've had Int64 for how long already? Geez, that's prehistoric. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
BrewManNH Posted September 6, 2014 Share Posted September 6, 2014 I just tested this on my home system, running 3.3.13.19, and when the element to be added is an Int64 or binary the function crashes. Running the same script on 3.3.12.0 it runs ok but the stripped array still occurs. Array.au3" (2294) : ==> The requested action with this object has failed.: $oDictionary.Item($vElem) $oDictionary^ ERROR Using 3.3..13.16 I'd get a "function not found" error in the same place. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 6, 2014 Moderators Share Posted September 6, 2014 Hi,You can certainly store an Int64 as a value - which led me to produce this:expandcollapse popup; snippet for AutoIt 3.3.12.0 #include <Array.au3> #include <security.au3> Global Const $WTS_CURRENT_SERVER_HANDLE = 0 Global Const $tagWTS_PROCESS_INFO = _ "DWORD SessionId;" & _ "DWORD ProcessId;" & _ "PTR pProcessName;" & _ "PTR pUserSid" ;# do the test: Local $a = _GetProcessContexts("iexplore.exe") ;***************************************** ;# returns an array of unique session IDs running the specified process. first element holds the count: $arReturn[0] Func _GetProcessContexts(Const $sProcessName) Local $aContexts[1] = [0] Local Const $aProcesses = _GetProcessList() If @error Or (UBound($aProcesses) <= 0) Then MsgBox(4096 + 48, "Error", "GetProcessContexts() failed to retrieve running processes. " & @CRLF & @CRLF & "Terminating!") Exit (1) EndIf For $i = 0 To UBound($aProcesses, 1) - 1 If (0 == StringCompare($aProcesses[$i][0], $sProcessName)) Then _ArrayAdd($aContexts, $aProcesses[$i][2]) EndIf Next $aContexts[0] = UBound($aContexts, 1) - 1 _ArrayDisplay($aContexts, "Before") ;## DEBUG <----- $aContexts = _ArrayUnique_Mod($aContexts, 0, 1, 0, 1) ;## this is ArrayUnique <----- ConsoleWrite("Ret: " & $aContexts[1] & " - " & VarGetType($aContexts[1]) & @CRLF) _ArrayDisplay($aContexts, "After") ;## DEBUG <----- If ((Not IsArray($aContexts)) Or (UBound($aContexts) < 1)) Then MsgBox(4096 + 48, "Error", "$aSessionIDs is NOT an array!") ;## DEBUG <----- EndIf Return $aContexts EndFunc ;==>_GetProcessContexts ;***************************************** ;# returns an array: ProcessName | ProcessID | SessionID | ProcessOwner ;# on error: returns -1, @error is set to 1 Func _GetProcessList() Local $i, $aRet, $ret1, $mem $aRet = DllCall("WTSApi32.dll", "int", "WTSEnumerateProcesses", "int", $WTS_CURRENT_SERVER_HANDLE, "int", 0, "int", 1, "ptr*", 0, "int*", 0) If @error Or ($aRet[0] == 0) Then MsgBox(4096 + 48, "Error", "Failed invoking WTSEnumerateProcesses") ;# DEBUG Return (SetError(1, 0, -1)) EndIf Local $array[$aRet[5]][4] $mem = DllStructCreate($tagWTS_PROCESS_INFO, $aRet[4]) For $i = 0 To $aRet[5] - 1 $mem = DllStructCreate($tagWTS_PROCESS_INFO, $aRet[4] + ($i * DllStructGetSize($mem))) Local $string = DllStructCreate("char[256]", DllStructGetData($mem, "pProcessName")) $array[$i][0] = DllStructGetData($string, 1) $array[$i][1] = DllStructGetData($mem, "ProcessId") $array[$i][2] = DllStructGetData($mem, "SessionId") $ret1 = _Security__LookupAccountSid(DllStructGetData($mem, "pUserSid")) If IsArray($ret1) Then $array[$i][3] = $ret1[1] & "\" & $ret1[0] Next DllCall("WTSApi32.dll", "int", "WTSFreeMemory", "int", $aRet[4]) Return $array EndFunc ;==>_GetProcessList Func _ArrayUnique_Mod(Const ByRef $aArray, $iColumn = 0, $iBase = 0, $iCase = 0, $iFlags = 1) If $iColumn = Default Then $iColumn = 0 If $iBase = Default Then $iBase = 0 If $iCase = Default Then $iCase = 0 If $iFlags = Default Then $iFlags = 1 ; Start bounds checking If UBound($aArray, $UBOUND_ROWS) = 0 Then Return SetError(1, 0, 0) ; Check if array is empty, or not an array ; Parameters can only be 0 or 1, if anything else return with an error If $iBase < 0 Or $iBase > 1 Or (Not IsInt($iBase)) Then Return SetError(3, 0, 0) If $iCase < 0 Or $iCase > 1 Or (Not IsInt($iCase)) Then Return SetError(3, 0, 0) If $iFlags < 0 Or $iFlags > 1 Or (Not IsInt($iFlags)) Then Return SetError(4, 0, 0) Local $iDims = UBound($aArray, $UBOUND_DIMENSIONS), $iNumColumns = UBound($aArray, $UBOUND_COLUMNS) If $iDims > 2 Then Return SetError(2, 0, 0) ; Checks the given dimension is valid If $iColumn < 0 Or ($iNumColumns = 0 And $iColumn > 0) Or ($iNumColumns > 0 And $iColumn >= $iNumColumns) Then Return SetError(5, 0, 0) ; create dictionary Local $oDictionary = ObjCreate("Scripting.Dictionary") ; compare mode for strings ; 0 = binary, which is case sensitive ; 1 = text, which is case insensitive ; this expression forces either 1 or 0 $oDictionary.CompareMode = Number(Not $iCase) Local $vElem = 0 ; walk the input array For $i = $iBase To UBound($aArray) - 1 If $iDims = 1 Then ; 1D array $vElem = $aArray[$i] Else ; 2D array $vElem = $aArray[$i][$iColumn] EndIf ; add key to dictionary ; keys are guaranteed to be unique ConsoleWrite("Elem: " & $vElem & " - " & VarGetType($vElem) & @CRLF) ; Get datatype ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< If Not $oDictionary.Item(String($vElem)) Then $oDictionary(String($vElem)) = $vElem EndIf Next ; return the array of values associated with unique keys Local $aValues[$oDictionary.Count] $i = 0 For $vKey In $oDictionary.Keys() $aValues[$i] = $oDictionary($vKey) Next If BitAND($iFlags, 1) = 1 Then _ArrayInsert($aValues, 0, $oDictionary.Count) EndIf Return $aValues ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< EndFunc ;==>_ArrayUniqueThat works for me on 3.3.12.0 and 3.3.13.19. I have not yet looked at the time penalty involved, and there will have to be a method of distinguishing between similar numeric and string keys, but the principle seems valid. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
BrewManNH Posted September 6, 2014 Share Posted September 6, 2014 Doesn't work so well with handles. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now