Leaderboard
Popular Content
Showing content with the highest reputation on 12/10/2017 in all areas
-
For the general solution (not limited to integers, not limited to single character values, not limited to sorted arrays) you'll not find anything faster than this. Try yourself. #include <Array.au3> Global $aArray[10] = [1,1,2,3,3,3,3,4,5,5] Global $aRes = Example( $aArray ) _ArrayDisplay( $aRes ) Global $iItems = 100000 ReDim $aArray[$iItems] For $i = 0 To $iItems - 1 Step 2 $aArray[$i] = $i/2 $aArray[$i+1] = $i/2 Next _ArrayDisplay( $aArray ) $aRes = Example( $aArray ) _ArrayDisplay( $aRes ) Func Example( $aArray ) Local $oTst = ObjCreate( "Scripting.Dictionary" ) Local $oRes = ObjCreate( "Scripting.Dictionary" ) For $i = 0 To UBound( $aArray ) - 1 If Not $oTst.Exists( $aArray[$i] ) Then $oTst( $aArray[$i] ) = 1 ElseIf Not $oRes.Exists( $aArray[$i] ) Then $oRes( $aArray[$i] ) = 1 EndIf Next Return $oRes.Keys() EndFunc2 points
-
Hello guys. Here is a small function to create a hash hmac similar to hash_hmac PHP function. Supported are: SHA512,SHA256,SHA1,SHA384,MD5 and RIPEMD160. Local $sSecret = "SecretKey" Local $sMessage = "AutoIt Rocks!!!" ConsoleWrite("HMAC-SHA256: " & @TAB & @TAB & _HashHMAC("SHA512", $sMessage, $sSecret) & @CRLF) ConsoleWrite("HMAC-SHA256: " & @TAB & @TAB & _HashHMAC("SHA256", $sMessage, $sSecret) & @CRLF) ConsoleWrite("HMAC-SHA1: " & @TAB & @TAB & _HashHMAC("SHA1", $sMessage, $sSecret) & @CRLF) ConsoleWrite("HMAC-SHA384: " & @TAB & @TAB & _HashHMAC("SHA384", $sMessage, $sSecret) & @CRLF) ConsoleWrite("HMAC-MD5: " & @TAB & @TAB & _HashHMAC("MD5", $sMessage, $sSecret) & @CRLF) ConsoleWrite("HMAC-RIPEMD160: " & @TAB & _HashHMAC("RIPEMD160", $sMessage, $sSecret) & @CRLF) Func _HashHMAC($sAlgorithm, $bData, $bKey, $bRaw_Output = False) Local $oHashHMACErrorHandler = ObjEvent("AutoIt.Error", "_HashHMACErrorHandler") Local $oHMAC = ObjCreate("System.Security.Cryptography.HMAC" & $sAlgorithm) If @error Then SetError(1, 0, "") $oHMAC.key = Binary($bKey) Local $bHash = $oHMAC.ComputeHash_2(Binary($bData)) Return SetError(0, 0, $bRaw_Output ? $bHash : StringLower(StringMid($bHash, 3))) EndFunc ;==>_HashHMAC Func _HashHMACErrorHandler($oError) ;Dummy Error Handler EndFunc ;==>_HashHMACErrorHandler It requires .NET Framework 2.0 or higher. Saludos1 point
-
Shouldn't that be: ; =============================================================================================================================== ; SetChecked State : Set checked state of Checkbox or Radio button ; =============================================================================================================================== Func SetCheckedState($nCtrl, $iState) If $iState > 0 Then GUICtrlSetState($nCtrl, $GUI_CHECKED) If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then GUICtrlSetData($log, _NowTime() & "Checkbox 1 is checked" & @CRLF, 1) EndIf Else GUICtrlSetState($nCtrl, $GUI_UNCHECKED) EndIf EndFunc ;==>SetCheckedState .. as you specify the controlhandle to check in the first parameter? Jos1 point
-
UIA Need to speed this code up
Earthshine reacted to Danyfirex for a topic
Hello I know you're asking for another thing. But You can probably speed of the first part too to avoid the pageFileAssoc and the listview loop part too. You can create a dummy file with the extension you want (".mp3"). Show the Properties Windows. Click the change progam button. handle the UI window. Saludos1 point -
"as bulletproof as possible" obviously means : as precise/specific as possible Local $s_Line1 = "Local $i_LineNumber = 133 ; some comment" Local $i_NewNumber = 25 $s_Line1 = StringRegExpReplace($s_Line1, 'i_LineNumber = \K\d+', $i_NewNumber) MsgBox(0, '$i_LineNumber', $s_Line1) $s_Line2 = "__Msi_ErrorSetValues(133, '$o_Records.StringData[2]') ; update variables for future COM errors" $s_Line2 = StringRegExpReplace($s_Line2, '__Msi_ErrorSetValues\(\K\d+', $i_NewNumber) MsgBox(0, '__Msi_ErrorSetValues', $s_Line2) $s_Line3 = "_Log_ErrorRoute('update', 'MSI', 133, '__Msi_ViewClose', '$o_View (' & IsObj($o_View) & ')')" $s_Line3 = StringRegExpReplace($s_Line3, "_Log_ErrorRoute\('update', 'MSI', \K\d+", $i_NewNumber) MsgBox(0, '_Log_ErrorRoute', $s_Line3) Please note that as the patterns are similar, in your example it could eventually be done like this Local $s_Lines = "Local $i_LineNumber = 133 ; some comment" & @crlf & _ "__Msi_ErrorSetValues(133, '$o_Records.StringData[2]') ; update variables for future COM errors" & @crlf & _ "_Log_ErrorRoute('update', 'MSI', 133, '__Msi_ViewClose', '$o_View (' & IsObj($o_View) & ')')" $subpattern = "(i_LineNumber = |__Msi_ErrorSetValues\(|_Log_ErrorRoute\('update', 'MSI', )" $s_Lines = StringRegExpReplace($s_Lines, $subpattern & "\K\d+", $i_NewNumber) MsgBox(0, 'all', $s_Lines)1 point
-
Keep duplicates from array
pixelsearch reacted to jchd for a topic
Maps are faster: #include <Array.au3> Global $iItems = 100000 Global $aArray[$iItems] For $i = 0 To $iItems - 1 $aArray[$i] = Random(0, $iItems * 0.2, 1) Next Local $t, $aRes _ArrayDisplay( $aArray ) $t = TimerInit() $aRes = Example( $aArray ) ConsoleWrite(TimerDiff($t) & @LF) _ArrayDisplay( $aRes ) $t = TimerInit() $aRes = MapExample( $aArray ) ConsoleWrite(TimerDiff($t) & @LF) _ArrayDisplay( $aRes ) Func Example( ByRef $aArray ) Local $oTst = ObjCreate( "Scripting.Dictionary" ) Local $oRes = ObjCreate( "Scripting.Dictionary" ) For $i = 0 To UBound( $aArray ) - 1 If Not $oTst.Exists( $aArray[$i] ) Then $oTst( $aArray[$i] ) = 1 ElseIf Not $oRes.Exists( $aArray[$i] ) Then $oRes( $aArray[$i] ) = 1 EndIf Next Return $oRes.Keys() EndFunc Func MapExample(ByRef $aArray) Local $mRes[] For $i = 0 To UBound($aArray) - 1 If MapExists($mRes, $aArray[$i]) Then $mRes[$aArray[$i]] += 1 Else $mRes[$aArray[$i]] = 1 EndIf Next For $i = 0 To UBound($aArray) - 1 If $mRes[$aArray[$i]] = 1 Then MapRemove($mRes, $aArray[$i]) EndIf Next Return $mRes.Keys() EndFunc1 point -
Func _DoOneSequence($iNumOfTimes = 1) For $eCC = 1 To $iNumOfTimes If _WaitForTheSettingsButtonToAppear()=1 Then _Main() Next EndFunc ;==>_DoOneSequence Func _WaitForTheSettingsButtonToAppear() _ShowScreen() Local $sColor = 0xDEF4FB $aColorFound = PixelSearch(200, 105, 228, 133, $sColor, 75) If IsArray($aColorFound) Then ConsoleWrite("Settings Button Found" & @CRLF) Return 1 EndIf ConsoleWrite("Settings Button NOT Found" & @CRLF) Sleep(5555) Return _WaitForTheSettingsButtonToAppear() EndFunc ;==>_WaitForTheSettingsButtonToAppear or Func _DoOneSequence($iNumOfTimes = 1) For $eCC = 1 To $iNumOfTimes _WaitForTheSettingsButtonToAppear() _Main() Next EndFunc ;==>_DoOneSequence Func _WaitForTheSettingsButtonToAppear() _ShowScreen() $aColorFound = PixelSearch(200, 105, 228, 133, 0xDEF4FB, 75) If IsArray($aColorFound) Then ConsoleWrite("Settings Button Found" & @CRLF) Return EndIf ConsoleWrite("Settings Button NOT Found" & @CRLF) Sleep(5555) _WaitForTheSettingsButtonToAppear() EndFunc ;==>_WaitForTheSettingsButtonToAppear1 point
-
The value of your Return statement is "$iSettingsButtonFound = 1", which is parsed as a condition, testing whether $iSettingsButtonFound has value 1 or not. Since it's clear that the condition is never met, it evaluates to False. So you return the boolean value False. You want just "Return 1". But I don't understand why you think recursion is needed here. I believe you just need a single loop, not two functions with one using recursion. Which program do you automate? There may exist a cleaner way to achieve your goal.1 point
-
Print Preview
argumentum reacted to x_bennY for a topic
someone has the link or the file to share? or another solution? i really need this. --------------------------------------------- Wow! Good news... after a long time of researching i found the file in a japonese forum! I'm attaching the original and the one that i've quickly edited to work on actual autoit version. I suggest to add this files into the forum database, at the download section. 459b1469257663.rar PrintPreview xbY.rar1 point -
Drive Mapping Issue
GoogleDude reacted to Echbiahn for a topic
For those who are curious, I found my solution from this article: http://woshub.com/how-to-access-mapped-network-drives-from-the-elevated-apps/ I discovered from testing that the script would not map the network drive with #RequireAdmin line in the code. Using the article above I added the missing registry key and rebooted. All testing after that worked 100% with and without #RequireAdmin.1 point