Leaderboard
Popular Content
Showing content with the highest reputation on 12/06/2018 in all areas
-
So I wanted a free obfuscator that was coded in AutoIt3 and was actually decent. So I spliced together several different ones found across the web and spent about two weeks programming this one. It is capable of: Encrypting ALL strings (len > 1) Renaming vars Renaming functions The string encryption is really the most innovative part of my obfuscator and also was the biggest pain in the ass. If you need or want to use a seperate string encryption method just make sure its a stream algorithm similar to the way XOR functions (one mode) Anyways here's the script. ENJOY!!!! ; Title: CryptoDragon AutoIt Obfuscator ; Version: v1.4.0.1 ; Requirements: AutoIt Version 3.1.1.0 (Beta is NOT required) ; Date: November 6th, 2018 ; Authors: Freak, taurus905 ; Purpose: This script obfuscates an AutoIt script by identifying, counting and replacing all ; variables and functions within that script, as well as encrypting strings. according to the following notes. ; Notes: Variables that are all UPPERCASE, such as, $GUI_EVENT_CLOSE, will not be obfuscated. ; All strings with single and double quotes are to be encrypted with a multikey XOR algo. (in order) ; Add arguments in the "Functions_NOT_to_obfuscate_section:" to bypass these functions. ; Uncomment: (in the script) ; Global $Show_Messages = "Yes" ; to show Message Boxes and Array Displays during execution. ; Input: An AutoIt Script --> OriginalScriptName.au3 ; Output: Variables to be Obfuscated --> OriginalScriptName - Vars to Obfuscate.txt ; Functions to be Obfuscated --> OriginalScriptName - Funcs to Obfuscate.txt ; Random Names --> OriginalScriptName - Random Names.txt ; CryptoDragon Obfuscated Script --> OriginalScriptName - CryptoDragon Obfuscated.au3 ; Modified by Freak to encrypt all strings in target program with multichar XOR, also added bug fixes. ; :::ChAnGeLoG:::: ; v1.2 - Original "Simple Obfuscator" by taurus905 ; v1.3 - Freak creates CryptoDragon project based off taurus905's "Simple Obfuscator" ; v1.3.4 - Added improved speed ; v1.3.5.1 - Improved functionality ; v1.3.6 - Added string length to _CryptoDragon_Crypt function for improved stability handling funny strings in version ; v1.4 - Improved security on encryption algorythm. Also obfuscator automatically writes encryption function to top of file automatically. ; v1.4.0.1 - Fixed encrypt function writing process. ; =================================================================================================== #include <GUIConstants.au3> #include <Array.au3> Func _CryptoDragon_Crypt($s_String, $s_Key, $iLen, $xorK2 = 0x12, $s_Level = 1.337) Local $s_Encrypted = "", $fin_Encrypted = "", $s_kc = 1 If StringLen($s_Key) = 0 Or $s_Level < 1 Then Return 0 $s_Key = StringSplit($s_Key, '') $s_String = StringSplit($s_String, '') For $x = 1 To $s_String[0] If $s_kc > $s_Key[0] Then $s_kc = 1 $s_Encrypted = $s_Key[$s_kc] $s_Encrypted += Floor(Asc($s_Key[$s_kc]) * $s_Level); $s_Encrypted = BitNOT($s_Encrypted); $s_Encrypted = BitXOR($s_Encrypted, Floor(Asc($s_Key[$s_kc]) * $s_Level)); $s_Encrypted += Floor(Asc($s_Key[$s_kc]) * $s_Level); $s_Encrypted -= Floor(Asc($s_Key[$s_kc]) * $s_Level); $s_Encrypted = BitXOR($s_Encrypted, Floor(Asc($s_Key[$s_kc]) * $s_Level)); $s_Encrypted = $s_Encrypted - 1; $s_Encrypted = BitXOR($s_Encrypted, Floor(Asc($s_Key[$s_kc]) * $s_Level)); $s_Encrypted = $s_Encrypted + 1; $s_Encrypted += Floor(Asc($s_Key[$s_kc]) * $s_Level); $s_Encrypted = BitXOR($s_Encrypted, $xorK2); $s_Encrypted = BitNOT($s_Encrypted); $s_Encrypted += Floor(Asc($s_Key[$s_kc]) * $s_Level); $fin_Encrypted &= Chr(BitXOR(Asc($s_String[$x]), Floor(Asc($s_Key[$s_kc]) * $s_Level))) $s_kc += 1 Next Return StringLeft($fin_Encrypted, $iLen) EndFunc ;==>_CryptoDragon_Crypt Global $Show_Messages = "No" ; Uncomment the following line to see progress messages and arrays during execution. ;Global $Show_Messages = "Yes" ; =================================================================================================== Global $file_Script_to_Obfuscate _Choose_Script_to_Obfuscate() ; Choose Script to Obfuscate ; =================================================================================================== ; Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines Global $Num_of_Lines _Count_Lines() ; Count Lines of Script to Obfuscate If $Show_Messages = "Yes" Then MsgBox(0, "$Num_of_Lines", $Num_of_Lines) Global $Array_of_Lines[$Num_of_Lines + 1] _Read_Lines_to_Array() ; Read Lines to Array If $Show_Messages = "Yes" Then _ArrayDisplay($Array_of_Lines, "$Array_of_Lines") ; Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines ; =================================================================================================== ; Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars Global $Num_of_Vars _Count_Vars() ; Count Variables in Script to Obfuscate If $Show_Messages = "Yes" Then MsgBox(0, "$Num_of_Vars", $Num_of_Vars) Global $Array_of_Vars[$Num_of_Vars + 1] _Read_Vars_to_Array() ; Read Variables to Array If $Show_Messages = "Yes" Then _ArrayDisplay($Array_of_Vars, "$Array_of_Vars") _Sort_Array_of_Vars() ; Sort Array of Variables If $Show_Messages = "Yes" Then _ArrayDisplay($Array_of_Vars, "$Array_of_Vars") Global $Num_of_Unique_Vars _Count_Unique_Vars() ; Count Unique Variables If $Show_Messages = "Yes" Then MsgBox(0, "$Num_of_Unique_Vars", $Num_of_Unique_Vars) Global $Array_of_Unique_Vars[$Num_of_Unique_Vars + 1] _Read_Unique_Vars_to_Array() ; Read Unique Variables to Array If $Show_Messages = "Yes" Then _ArrayDisplay($Array_of_Unique_Vars, "$Array_of_Unique_Vars") _Write_Unique_Vars_to_File() ; Write Unique Variables to File ; Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars ; =================================================================================================== ; Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs Global $Num_of_Funcs _Count_Funcs() ; Count Functions in Script to Obfuscate If $Show_Messages = "Yes" Then MsgBox(0, "$Num_of_Funcs", $Num_of_Funcs) Global $Array_of_Funcs[$Num_of_Funcs + 1] _Read_Funcs_to_Array() ; Read Functions to Array If $Show_Messages = "Yes" Then _ArrayDisplay($Array_of_Funcs, "$Array_of_Funcs") _Sort_Array_of_Funcs() ; Sort Array of Functions If $Show_Messages = "Yes" Then _ArrayDisplay($Array_of_Funcs, "$Array_of_Funcs") ; Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs ; =================================================================================================== ; Random - Random - Random - Random - Random - Random - Random - Random - Random - Random - Random Global $Num_of_Random_Names _Find_Random_Name_Count() ; Find Random Name Count Global $Random_Name[$Num_of_Random_Names + 1] _Read_Random_Names_to_Array() ; Read Random Names to Array If $Show_Messages = "Yes" Then _ArrayDisplay($Random_Name, "$Random_Name") _Write_Random_Names_to_File() ; Write Random Names to File ; Random - Random - Random - Random - Random - Random - Random - Random - Random - Random - Random ; =================================================================================================== ; Replace - Replace - Replace - Replace - Replace - Replace - Replace - Replace - Replace - Replace Global $New_Array_of_Lines[$Num_of_Lines + 1] _Remove_Comments() ; Remove Comments _ArraySortDblDel($Array_of_Unique_Vars) _ArraySortDblDel($Array_of_Funcs) $vars_finished = False $func_finished = False $Script_Data = _ArrayToString($Array_of_Lines, @CRLF) For $iii = 0 To $Num_of_Lines For $jjj = UBound($Array_of_Unique_Vars) - 1 To 1 Step -1 If $vars_finished Then ExitLoop If $Array_of_Unique_Vars[$jjj] <> $Array_of_Unique_Vars[1] Then If $Array_of_Unique_Vars[$jjj] <> "_" And $Array_of_Unique_Vars[$jjj] <> "$'" And StringLower($Array_of_Unique_Vars[$jjj]) <> "$cmdline" Then If StringInStr($Array_of_Unique_Vars[$jjj], ".") Then $temp = StringSplit($Array_of_Unique_Vars[$jjj], ".") $Array_of_Unique_Vars[$jjj] = $temp[1] EndIf If StringRight($Array_of_Unique_Vars[$jjj], 1) = "&" Then $Array_of_Unique_Vars[$jjj] = StringTrimRight($Array_of_Unique_Vars[$jjj], 1) EndIf $Script_Data = StringReplace($Script_Data, $Array_of_Unique_Vars[$jjj], "$" & $Random_Name[$jjj]) ConsoleWrite($Array_of_Unique_Vars[$jjj] & ":$" & $Random_Name[$jjj] & @CRLF) EndIf Else If $Array_of_Unique_Vars[$jjj] <> "_" And $Array_of_Unique_Vars[$jjj] <> "$'" Then If StringInStr($Array_of_Unique_Vars[$jjj], ".") Then $temp = StringSplit($Array_of_Unique_Vars[$jjj], ".") $Array_of_Unique_Vars[$jjj] = $temp[1] EndIf If StringRight($Array_of_Unique_Vars[$jjj], 1) = "&" Then $Array_of_Unique_Vars[$jjj] = StringTrimRight($Array_of_Unique_Vars[$jjj], 1) EndIf $Script_Data = StringReplace($Script_Data, $Array_of_Unique_Vars[$jjj], "$" & $Random_Name[$jjj]) ConsoleWrite($Array_of_Unique_Vars[$jjj] & ":$" & $Random_Name[$jjj] & @CRLF) EndIf $vars_finished = True EndIf Next Next For $iii = 0 To $Num_of_Lines For $jjj = UBound($Array_of_Funcs) - 1 To 1 Step -1 ; If StringLeft($Array_of_Funcs[$jjj], 1) = "_" Then ContinueLoop If $func_finished Then ExitLoop If $Array_of_Funcs[$jjj] <> $Array_of_Funcs[1] Then If StringInStr($Array_of_Funcs[$jjj], "=") Then ContinueLoop ; Au3wrapper, not a function. $Script_Data = StringReplace($Script_Data, $Array_of_Funcs[$jjj], $Random_Name[$jjj]) ConsoleWrite($Array_of_Funcs[$jjj] & ":" & $Random_Name[$jjj] & @CRLF) Else If StringInStr($Array_of_Funcs[$jjj], "=") Then $func_finished = True ContinueLoop ; Au3wrapper, not a function. EndIf $Script_Data = StringReplace($Script_Data, $Array_of_Funcs[$jjj], $Random_Name[$jjj]) ConsoleWrite($Array_of_Funcs[$jjj] & ":" & $Random_Name[$jjj] & @CRLF) $func_finished = True EndIf Next Next If $Show_Messages = "Yes" Then _ArrayDisplay($Array_of_Lines, "$New_Array_of_Lines") ; Replace - Replace - Replace - Replace - Replace - Replace - Replace - Replace - Replace - Replace ; =================================================================================================== _Write_CryptoDragon_Obfuscated_File($Script_Data) ; Write CryptoDragon Obfuscated Script Exit Func _ArraySortDblDel(ByRef $ARRAY, $CASESENS=0, $iDESCENDING=0, $iDIM=0, $iSORT=0) Local $arTmp1D[1], $arTmp2D[1][2], $dbl = 0 $arTmp1D[0] = "" $arTmp2D[0][0] = "" If $iDIM = 0 Then $iDIM = 1 _ArraySort($ARRAY,$iDESCENDING,0,0,$iDIM,$iSORT) Switch $iDIM Case 1 ; 1D For $i = 0 To UBound($ARRAY)-1 $dbl = 0 For $k = 0 To UBound($arTmp1D)-1 Switch $CASESENS Case 0 If $arTmp1D[$k] = $ARRAY[$i] Then $dbl = 1 Case 1 If $arTmp1D[$k] == $ARRAY[$i] Then $dbl = 1 EndSwitch Next If $dbl = 0 Then If $arTmp1D[0] = "" Then $arTmp1D[0] = $ARRAY[$i] Else _ArrayAdd($arTmp1D, $ARRAY[$i]) EndIf Else $dbl = 0 EndIf Next $ARRAY = $arTmp1D Case 2 ; 2D For $i = 0 To UBound($ARRAY)-1 $dbl = 0 For $k = 0 To UBound($arTmp2D)-1 Switch $CASESENS Case 0 If ( $arTmp2D[$k][0] = $ARRAY[$i][0] ) And _ ( $arTmp2D[$k][1] = $ARRAY[$i][1] ) Then $dbl = 1 Case 1 If ( $arTmp2D[$k][0] == $ARRAY[$i][0] ) And _ ( $arTmp2D[$k][1] == $ARRAY[$i][1] ) Then $dbl = 1 EndSwitch Next If $dbl = 0 Then If $arTmp2D[0][0] = "" Then $arTmp2D[0][0] = $ARRAY[$i][0] $arTmp2D[0][1] = $ARRAY[$i][1] Else ReDim $arTmp2D[UBound($arTmp2D)+1][2] $arTmp2D[UBound($arTmp2D)-1][0] = $ARRAY[$i][0] $arTmp2D[UBound($arTmp2D)-1][1] = $ARRAY[$i][1] EndIf Else $dbl = 0 EndIf Next $ARRAY = $arTmp2D EndSwitch EndFunc ; ==>_ArraySortDblDel ; ################################################################################################### ; =================================================================================================== Func _Choose_Script_to_Obfuscate() ; Choose Script to Obfuscate $file_Script_to_Obfuscate = FileOpenDialog("Choose an AutoIt Script to Obfuscate:", @ScriptDir, "Scripts (*.au3)", 1 + 2) If @error Then Exit EndFunc ; ==> _Choose_Script_to_Obfuscate ; =================================================================================================== ; Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines Func _Count_Lines() ; Count Lines of Script to Obfuscate FileOpen($file_Script_to_Obfuscate, 0) ; Open File to Obfuscate $Num_of_Lines = 0 While 1 $Num_of_Lines = $Num_of_Lines + 1 FileReadLine($file_Script_to_Obfuscate, $Num_of_Lines) ; Read All Lines for Count If @error = -1 Then ExitLoop WEnd EndFunc ; ==> _Count_Lines ; =================================================================================================== Func _Read_Lines_to_Array() ; Read Lines to Array For $iii = 1 To $Num_of_Lines $Array_of_Lines[$iii] = FileReadLine($file_Script_to_Obfuscate, $iii) ; Read All Lines Next FileClose($file_Script_to_Obfuscate) ; Close File to Obfuscate EndFunc ; ==> _Read_Lines_to_Array ; Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines - Lines ; =================================================================================================== ; Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars Func _Count_Vars() ; Count Variables in Script to Obfuscate $Num_of_Vars = 0 For $iii = 1 To $Num_of_Lines Local $quote_on = "No" $Array_of_Lines[0] = $Array_of_Lines[$iii] Local $line_length = StringLen($Array_of_Lines[0]) For $jjj = 1 To $line_length Local $char = StringLeft($Array_of_Lines[0], 1) If $char = Chr(34) And $quote_on = "No" Then $quote_on = "Yes" ElseIf $char = Chr(34) And $quote_on = "Yes" Then $quote_on = "No" EndIf If $char = ";" And $quote_on = "No" Then ExitLoop If $char = "$" And $quote_on = "No" Then $Num_of_Vars = $Num_of_Vars + 1 $Array_of_Lines[0] = StringTrimLeft($Array_of_Lines[0], 1) Next Next EndFunc ; ==> _Count_Vars ; =================================================================================================== Func _Read_Vars_to_Array() ; Read Variables to Array Local $var_ct = 0 For $iii = 1 To $Num_of_Lines Local $quote_on = "No" $Array_of_Lines[0] = $Array_of_Lines[$iii] Local $line_length = StringLen($Array_of_Lines[0]) For $jjj = 1 To $line_length Local $char = StringLeft($Array_of_Lines[0], 1) If $char = Chr(34) And $quote_on = "No" Then $quote_on = "Yes" ElseIf $char = Chr(34) And $quote_on = "Yes" Then $quote_on = "No" EndIf If $char = ";" And $quote_on = "No" Then ExitLoop If $char = "$" And $quote_on = "No" Then ; Read One Variable $var_ct = $var_ct + 1 $Array_of_Vars[$var_ct] = "" For $kkk = 1 To 256 $char = StringLeft($Array_of_Lines[0], 1) If $char = " " Or _ $char = " " Or _ $char = "=" Or _ $char = "[" Or _ $char = "]" Or _ $char = "," Or _ $char = ")" Or _ $char = ";" Or _ $char = "+" Or _ $char = "-" Or _ $char = "*" Or _ $char = "/" Or _ $char = Chr(34) Then ExitLoop $Array_of_Vars[$var_ct] = $Array_of_Vars[$var_ct] & $char $Array_of_Lines[0] = StringTrimLeft($Array_of_Lines[0], 1) Next EndIf $Array_of_Lines[0] = StringTrimLeft($Array_of_Lines[0], 1) Next Next EndFunc ; ==> _Read_Vars_to_Array ; =================================================================================================== Func _Sort_Array_of_Vars() ; Sort Array of Variables _ArraySortDblDel($Array_of_Vars) EndFunc ; ==> _Sort_Array_of_Vars ; =================================================================================================== Func _Count_Unique_Vars() ; Count Unique Variables $Num_of_Unique_Vars = 0 For $iii = 1 To UBound($Array_of_Vars) - 1 If $Array_of_Vars[$iii] <> $Array_of_Vars[$iii - 1] Then If StringIsUpper(StringTrimLeft(StringReplace($Array_of_Vars[$iii], "_", ""), 1)) Then ContinueLoop ; Don't write any system variables that are all UPPERCASE, such as, $GUI_EVENT_CLOSE $Num_of_Unique_Vars = $Num_of_Unique_Vars + 1 EndIf Next EndFunc ; ==> _Count_Unique_Vars ; =================================================================================================== Func _Read_Unique_Vars_to_Array() ; Read Unique Variables to Array Local $var_unique_ct = 0 For $iii = 1 To UBound($Array_of_Vars) - 1 If $Array_of_Vars[$iii] <> $Array_of_Vars[$iii - 1] Then If StringIsUpper(StringTrimLeft(StringReplace($Array_of_Vars[$iii], "_", ""), 1)) Then ContinueLoop ; Don't read any System Variables that are all UPPERCASE, such as, $GUI_EVENT_CLOSE $var_unique_ct = $var_unique_ct + 1 $Array_of_Unique_Vars[$var_unique_ct] = $Array_of_Vars[$iii] EndIf Next EndFunc ; ==> _Read_Unique_Vars_to_Array ; =================================================================================================== Func _Write_Unique_Vars_to_File() ; Write Unique Variables to File Local $file_Unique_Vars = StringTrimRight($file_Script_to_Obfuscate, 4) & " - Vars to Obfuscate.txt" ; Create Unique Variables Filename FileOpen($file_Unique_Vars, 2) ; Open File to Write Unique Variables For $iii = 1 To $Num_of_Unique_Vars FileWrite($file_Unique_Vars, $Array_of_Unique_Vars[$iii] & @CRLF) Next FileClose($file_Unique_Vars) ; Close Unique Variables File EndFunc ; ==> _Write_Unique_Vars_to_File ; Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars - Vars ; =================================================================================================== ; Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs Func _Count_Funcs() ; Count Functions in Script to Obfuscate $Num_of_Funcs = 0 For $iii = 1 To $Num_of_Lines Local $quote_on = "No" Local $var_on = "No" Local $func_on = "No" $Array_of_Lines[0] = $Array_of_Lines[$iii] Local $line_length = StringLen($Array_of_Lines[0]) For $jjj = 1 To $line_length Local $char = StringLeft($Array_of_Lines[0], 1) If $char = "(" Or $char = " " Then $func_on = "No" If $char = "$" And $quote_on = "No" Then $var_on = "Yes" If $char = "@" And $quote_on = "No" Then $var_on = "Yes" If $char = "<" And $quote_on = "No" Then $var_on = "Yes" If $char = " " And $quote_on = "No" Then $var_on = "No" If $char = Chr(34) And $quote_on = "No" Then $quote_on = "Yes" ElseIf $char = Chr(34) And $quote_on = "Yes" Then $quote_on = "No" EndIf If $char = ";" And $quote_on = "No" Then ExitLoop If $quote_on = "No" And $func_on = "No" And $var_on = "No" Then $func_on = "Yes" $Num_of_Funcs = $Num_of_Funcs + 1 EndIf $Array_of_Lines[0] = StringTrimLeft($Array_of_Lines[0], 1) Next Next EndFunc ; ==> _Count_Funcs ; =================================================================================================== Func _Read_Funcs_to_Array() ; Read Functions to Array Local $func_ct = 0 For $iii = 1 To $Num_of_Lines Local $quote_on = "No" Local $var_on = "No" Local $func_on = "No" $Array_of_Lines[0] = $Array_of_Lines[$iii] Local $line_length = StringLen($Array_of_Lines[0]) For $jjj = 1 To $line_length Local $char = StringLeft($Array_of_Lines[0], 1) If $char = "(" Or $char = " " Then $func_on = "No" If $char = "$" And $quote_on = "No" Then $var_on = "Yes" If $char = "@" And $quote_on = "No" Then $var_on = "Yes" If $char = "<" And $quote_on = "No" Then $var_on = "Yes" If $char = " " And $quote_on = "No" Then $var_on = "No" If $char = Chr(34) And $quote_on = "No" Then $quote_on = "Yes" ElseIf $char = Chr(34) And $quote_on = "Yes" Then $quote_on = "No" EndIf If $char = ";" And $quote_on = "No" Then ExitLoop If $char = "_" And $quote_on = "No" And $func_on = "No" And $var_on = "No" Then ; Read One Function $func_ct = $func_ct + 1 $Array_of_Funcs[$func_ct] = "" For $kkk = 1 To 256 $char = StringLeft($Array_of_Lines[0], 1) If $char = " " Or $char = "(" Then ExitLoop $Array_of_Funcs[$func_ct] = $Array_of_Funcs[$func_ct] & $char $Array_of_Lines[0] = StringTrimLeft($Array_of_Lines[0], 1) Next ; Functions_NOT_to_obfuscate_section: ; Add functions to the following lines that start with an underscore "_" that you ; do NOT want to be obfuscated. Example: ; If $Array_of_Funcs[$func_ct] = "_ArraySortDblDel" Or _ If $Array_of_Funcs[$func_ct] = "_ArraySortDblDel" Or _ $Array_of_Funcs[$func_ct] = "_ArrayDisplay" Or _ $Array_of_Funcs[$func_ct] = "_ChooseColor" Or _ $Array_of_Funcs[$func_ct] = "_ChooseFont" Or _ $Array_of_Funcs[$func_ct] = "_ImageGetSize" Or _ $Array_of_Funcs[$func_ct] = "_IsPressed" Or _ $Array_of_Funcs[$func_ct] = "_StringEncrypt" Or _ $Array_of_Funcs[$func_ct] = "_" Then ; Do NOT Count Built-In Functions $func_ct = $func_ct - 1 EndIf EndIf $Array_of_Lines[0] = StringTrimLeft($Array_of_Lines[0], 1) Next Next EndFunc ; ==> _Read_Funcs_to_Array ; =================================================================================================== Func _Sort_Array_of_Funcs() ; Sort Array of Functions _ArraySortDblDel($Array_of_Funcs) EndFunc ; ==> _Sort_Array_of_Funcs ; =================================================================================================== ; Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs - Funcs ; =================================================================================================== Func _Find_Random_Name_Count() ; Find Random Name Count If $Num_of_Unique_Vars > $Num_of_Funcs Then $Num_of_Random_Names = $Num_of_Vars Else $Num_of_Random_Names = $Num_of_Funcs EndIf EndFunc ; ==> _Find_Random_Name_Count ; =================================================================================================== Func _Read_Random_Names_to_Array() ; Read Random Names to Array Local $random[16] For $iii = 1 To $Num_of_Random_Names $Random_Name[$iii] = "" For $jjj = 1 To Random(4, 15, 1) ; The number of random characters to use in each random name $random[$jjj] = Random(48, 122, 1) If $random[$jjj] > 64 And $random[$jjj] < 91 Or $random[$jjj] > 96 And $random[$jjj] < 123 Then $Random_Name[$iii] = $Random_Name[$iii] & Chr($random[$jjj]) Else $jjj = $jjj - 1 ContinueLoop EndIf Next Next Return $Random_Name EndFunc ; ==> _Read_Random_Names_to_Array ; =================================================================================================== Func _Write_Random_Names_to_File() ; Write Random Names to File Local $file_Random_Names = StringTrimRight($file_Script_to_Obfuscate, 4) & " - Random Names.txt" ; Create Random Names Filename FileOpen($file_Random_Names, 2) ; Open File to Write Random Names For $iii = 1 To $Num_of_Random_Names FileWrite($file_Random_Names, $Random_Name[$iii] & @CRLF) Next FileClose($file_Random_Names) ; Close Random Names File Return $Random_Name EndFunc ; ==> _Write_Random_Names_to_File ; Random - Random - Random - Random - Random - Random - Random - Random - Random - Random - Random ; =================================================================================================== ; Replace - Replace - Replace - Replace - Replace - Replace - Replace - Replace - Replace - Replace ; =================================================================================================== Func _Remove_Comments() ; Remove Comments For $iii = 1 To $Num_of_Lines Local $quote_on = "No" $Array_of_Lines[0] = $Array_of_Lines[$iii] Local $line_length = StringLen($Array_of_Lines[0]) $New_Array_of_Lines[$iii] = "" For $jjj = 1 To $line_length Local $char = StringLeft($Array_of_Lines[0], 1) If $char = Chr(34) And $quote_on = "No" Then $quote_on = "Yes" ElseIf $char = Chr(34) And $quote_on = "Yes" Then $quote_on = "No" EndIf If $char = ";" And $quote_on = "No" Then ExitLoop $New_Array_of_Lines[$iii] = $New_Array_of_Lines[$iii] & $char $Array_of_Lines[0] = StringTrimLeft($Array_of_Lines[0], 1) Next Next Return $New_Array_of_Lines EndFunc ; ==> _Remove_Comments ; Replace - Replace - Replace - Replace - Replace - Replace - Replace - Replace - Replace - Replace ; =================================================================================================== Func _StringBetween($S_STRING, $S_START, $S_END, $V_CASE = -1) Local $S_CASE = "" If $V_CASE = Default Or $V_CASE = -1 Then $S_CASE = "(?i)" Local $S_PATTERN_ESCAPE = "(\.|\||\*|\?|\+|\(|\)|\{|\}|\[|\]|\^|\$|\\)" $S_START = StringRegExpReplace($S_START, $S_PATTERN_ESCAPE, "\\$1") $S_END = StringRegExpReplace($S_END, $S_PATTERN_ESCAPE, "\\$1") If $S_START = "" Then $S_START = "\A" If $S_END = "" Then $S_END = "\z" Local $A_RET = StringRegExp($S_STRING, "(?s)" & $S_CASE & $S_START & "(.*?)" & $S_END, 3) If @error Then Return SetError(1, 0, 0) Return $A_RET EndFunc ;==>_STRINGBETWEEN Func _Add_Strings($aList, $AU3, $splitChar) Global $sPass = "" Dim $sRndChr[3] Local $Digits = Random(4, 15, 1) For $i = 1 To $Digits $sRndChr[0] = Chr(Random(65, 90, 1)) $sRndChr[1] = Chr(Random(97, 122, 1)) $sRndChr[2] = Chr(Random(48, 57, 1)) $sPass &= $sRndChr[Random(0, 2, 1)] Next Local $doneEncryption = False Local $newAU3 = $AU3 _ArraySortDblDel($aList) For $A = 0 To UBound($aList) - 1 If StringInStr($aList[$A], @CRLF) Then ContinueLoop ElseIf $aList[$A] <> "" And StringInStr($aList[$A], "_CryptoDragon_Crypt") = False And StringLeft($aList[$A], 1) <> "'" And StringRight($aList[$A], 1) <> "'" And StringLeft($aList[$A], 1) <> '"' And StringRight($aList[$A], 1) <> '"' And StringLen($aList[$A]) > 1 Then If StringInStr($aList[$A], "&") Then If StringRight($aList[$A], 1) = "&" Then $newAU3 = StringReplace($newAU3, $splitChar & StringTrimRight($aList[$A], 1) & $splitChar, " & _CryptoDragon_Crypt(BinaryToString('" & StringToBinary(_CryptoDragon_Crypt(StringTrimRight($aList[$A], 1), $sPass, StringLen(StringTrimRight($aList[$A], 1)))) & "'), BinaryToString('" & StringToBinary($sPass) & "'), " & String(StringLen($aList[$A]) - 1) & ")&") ConsoleWrite($splitChar & StringTrimRight($aList[$A], 1) & $splitChar & ":_CryptoDragon_Crypt(BinaryToString('" & StringToBinary(_CryptoDragon_Crypt(StringTrimRight($aList[$A], 1), $sPass, StringLen(StringTrimRight($aList[$A], 1)))) & "'), BinaryToString('" & StringToBinary($sPass) & "'), " & String(StringLen($aList[$A]) - 1) & ")&" & @CRLF) ElseIf StringRight($aList[$A], 2) = "& " Then $newAU3 = StringReplace($newAU3, $splitChar & StringTrimRight($aList[$A], 2) & $splitChar, "_CryptoDragon_Crypt(BinaryToString('" & StringToBinary(_CryptoDragon_Crypt(StringTrimRight($aList[$A], 2), $sPass, StringLen(String($aList[$A]) - 2))) & "'), BinaryToString('" & StringToBinary($sPass) & "'), " & String(StringLen($aList[$A]) - 2) & ") & ") ConsoleWrite($splitChar & StringTrimRight($aList[$A], 2) & $splitChar & ":_CryptoDragon_Crypt(BinaryToString('" & StringToBinary(_CryptoDragon_Crypt(StringTrimRight($aList[$A], 2), $sPass, StringLen(String($aList[$A]) - 2))) & "'), BinaryToString('" & StringToBinary($sPass) & "'), " & String(StringLen($aList[$A]) - 2) & ") &" & @CRLF) ElseIf StringLeft($aList[$A], 1) = "&" Then $newAU3 = StringReplace($newAU3, $splitChar & StringTrimLeft($aList[$A], 1) & $splitChar, "&_CryptoDragon_Crypt(BinaryToString('" & StringToBinary(_CryptoDragon_Crypt(StringTrimLeft($aList[$A], 2), $sPass, StringLen(String($aList[$A]) - 1))) & "'), BinaryToString('" & StringToBinary($sPass) & "'), " & String(StringLen($aList[$A]) - 1) & ")") ConsoleWrite($splitChar & StringTrimLeft($aList[$A], 1) & $splitChar & ":&_CryptoDragon_Crypt(BinaryToString('" & StringToBinary(_CryptoDragon_Crypt(StringTrimLeft($aList[$A], 1), $sPass, StringLen(String($aList[$A]) - 1))) & "'), BinaryToString('" & StringToBinary($sPass) & "'), " & String(StringLen($aList[$A]) - 1) & ")" & @CRLF) ElseIf StringLeft($aList[$A], 2) = " &" Then $newAU3 = StringReplace($newAU3, $splitChar & StringTrimLeft($aList[$A], 2) & $splitChar, " & _CryptoDragon_Crypt(BinaryToString('" & StringToBinary(_CryptoDragon_Crypt(StringTrimLeft($aList[$A], 2), $sPass, StringLen(String($aList[$A]) - 2))) & "'), BinaryToString('" & StringToBinary($sPass) & "'))") ConsoleWrite($splitChar & StringTrimLeft($aList[$A], 2) & $splitChar & ": & _CryptoDragon_Crypt(BinaryToString('" & StringToBinary(_CryptoDragon_Crypt(StringTrimLeft($aList[$A], 2), $sPass, StringLen(String($aList[$A]) - 2))) & "'), BinaryToString('" & StringToBinary($sPass) & "'), " & String(StringLen($aList[$A]) - 2) & ")" & @CRLF) Else $newAU3 = StringReplace($newAU3, $splitChar & $aList[$A] & $splitChar, "_CryptoDragon_Crypt(BinaryToString('" & StringToBinary(_CryptoDragon_Crypt($aList[$A], $sPass, StringLen($aList[$A]))) & "'), BinaryToString('" & StringToBinary($sPass) & "'), " & String(StringLen($aList[$A])) & ")") ConsoleWrite($splitChar & $aList[$A] & $splitChar & ":_CryptoDragon_Crypt(BinaryToString('" & StringToBinary(_CryptoDragon_Crypt($aList[$A], $sPass, StringLen($aList[$A]))) & "'), BinaryToString('" & StringToBinary($sPass) & "'), " & String(StringLen($aList[$A])) & ")" & @CRLF) EndIf Else $newAU3 = StringReplace($newAU3, $splitChar & $aList[$A] & $splitChar, "_CryptoDragon_Crypt(BinaryToString('" & StringToBinary(_CryptoDragon_Crypt($aList[$A], $sPass, StringLen($aList[$A]))) & "'), BinaryToString('" & StringToBinary($sPass) & "'), " & StringLen($aList[$A]) & ")") ConsoleWrite($splitChar & $aList[$A] & $splitChar & ":_CryptoDragon_Crypt(BinaryToString('" & StringToBinary(_CryptoDragon_Crypt($aList[$A], $sPass, StringLen($aList[$A]))) & "'), BinaryToString('" & StringToBinary($sPass) & "'), " & String(StringLen($aList[$A])) & ")" & @CRLF) EndIf EndIf Next Return $newAU3 EndFunc ;==>_ADD_STRINGS Func base64($vCode, $bEncode = True, $bUrl = False) Local $oDM = ObjCreate("Microsoft.XMLDOM") If Not IsObj($oDM) Then Return SetError(1, 0, 1) Local $oEL = $oDM.createElement("Tmp") $oEL.DataType = "bin.base64" If $bEncode then $oEL.NodeTypedValue = Binary($vCode) If Not $bUrl Then Return $oEL.Text Return StringReplace(StringReplace(StringReplace($oEL.Text, "+", "-"),"/", "_"), @LF, "") Else If $bUrl Then $vCode = StringReplace(StringReplace($vCode, "-", "+"), "_", "/") $oEL.Text = $vCode Return BinaryToString($oEL.NodeTypedValue, 4) EndIf EndFunc ;==>base64 Func _Encrypt_Strings($AU3, $file_Simple_Obfuscated) Local $sSTRINGS = _StringBetween($AU3, "'", "'") Local $newAU3 = _Add_Strings($sSTRINGS, $AU3, "'") Local $dSTRINGS = _StringBetween($newAU3, '"', '"') Local $epicAU3 = _Add_Strings($dSTRINGS, $newAU3, '"') Local $fileHandle = FileOpen($file_Simple_Obfuscated, 18) FileWrite($fileHandle, base64("RnVuYyBfQ3J5cHRvRHJhZ29uX0NyeXB0KCRzX1N0cmluZywgJHNfS2V5LCAkaUxlbiwgJHhvcksyID0gMHgxMiwgJHNfTGV2ZWwgPSAxLjMzNykKCUxvY2FsICRzX0VuY3J5cHRlZCA9ICIiLCAkZmluX0VuY3J5cHRlZCA9ICIiLCAkc19rYyA9IDEKCUlmIFN0cmluZ0xlbigkc19LZXkpID0gMCBPciAkc19MZXZlbCA8IDEgVGhlbiBSZXR1cm4gMAoJJHNfS2V5ID0gU3RyaW5nU3BsaXQoJHNfS2V5LCAnJykKCSRzX1N0cmluZyA9IFN0cmluZ1NwbGl0KCRzX1N0cmluZywgJycpCglGb3IgJHggPSAxIFRvICRzX1N0cmluZ1swXQoJCUlmICRzX2tjID4gJHNfS2V5WzBdIFRoZW4gJHNfa2MgPSAxCgkJJHNfRW5jcnlwdGVkID0gJHNfS2V5WyRzX2tjXQoJCSRzX0VuY3J5cHRlZCArPSBGbG9vcihBc2MoJHNfS2V5WyRzX2tjXSkgKiAkc19MZXZlbCk7CgkJJHNfRW5jcnlwdGVkID0gQml0Tk9UKCRzX0VuY3J5cHRlZCk7CgkJJHNfRW5jcnlwdGVkID0gQml0WE9SKCRzX0VuY3J5cHRlZCwgRmxvb3IoQXNjKCRzX0tleVskc19rY10pICogJHNfTGV2ZWwpKTsKCQkkc19FbmNyeXB0ZWQgKz0gRmxvb3IoQXNjKCRzX0tleVskc19rY10pICogJHNfTGV2ZWwpOwoJCSRzX0VuY3J5cHRlZCAtPSBGbG9vcihBc2MoJHNfS2V5WyRzX2tjXSkgKiAkc19MZXZlbCk7CgkJJHNfRW5jcnlwdGVkID0gQml0WE9SKCRzX0VuY3J5cHRlZCwgRmxvb3IoQXNjKCRzX0tleVskc19rY10pICogJHNfTGV2ZWwpKTsKCQkkc19FbmNyeXB0ZWQgPSAkc19FbmNyeXB0ZWQgLSAxOwoJCSRzX0VuY3J5cHRlZCA9IEJpdFhPUigkc19FbmNyeXB0ZWQsIEZsb29yKEFzYygkc19LZXlbJHNfa2NdKSAqICRzX0xldmVsKSk7CgkJJHNfRW5jcnlwdGVkID0gJHNfRW5jcnlwdGVkICsgMTsKCQkkc19FbmNyeXB0ZWQgKz0gRmxvb3IoQXNjKCRzX0tleVskc19rY10pICogJHNfTGV2ZWwpOwoJCSRzX0VuY3J5cHRlZCA9IEJpdFhPUigkc19FbmNyeXB0ZWQsICR4b3JLMik7CgkJJHNfRW5jcnlwdGVkID0gQml0Tk9UKCRzX0VuY3J5cHRlZCk7CgkJJHNfRW5jcnlwdGVkICs9IEZsb29yKEFzYygkc19LZXlbJHNfa2NdKSAqICRzX0xldmVsKTsKCQkkZmluX0VuY3J5cHRlZCAmPSBDaHIoQml0WE9SKEFzYygkc19TdHJpbmdbJHhdKSwgRmxvb3IoQXNjKCRzX0tleVskc19rY10pICogJHNfTGV2ZWwpKSkKCQkkc19rYyArPSAxCglOZXh0CglSZXR1cm4gU3RyaW5nTGVmdCgkZmluX0VuY3J5cHRlZCwgJGlMZW4pCkVuZEZ1bmMgICA7PT0+X0NyeXB0b0RyYWdvbl9DcnlwdA==", False)) FileWrite($fileHandle, $epicAU3) FileClose($fileHandle) EndFunc ;==>_ENCRYPT_STRINGS Func _Write_CryptoDragon_Obfuscated_File($AU3) ; Write CryptoDragon Obfuscated File Local $file_Simple_Obfuscated = StringTrimRight($file_Script_to_Obfuscate, 4) & " - CryptoDragon Obfuscated.au3" ; Create CryptoDragon Obfuscated Filename _Encrypt_Strings($AU3, $file_Simple_Obfuscated) EndFunc ; ==> _Write_CryptoDragon_Obfuscated_File ; ===================================================================================================1 point
-
Not quite, the answer comes from from @ProgAndy in "The problems of the other Scripts were the differencies between GDI32-HBITMAP and GDIPlus-HBITMAP." Image copy resolves that. If you don't do it, it will simply not work...1 point
-
Clipboard save and retrieve
pixelsearch reacted to FrancescoDiMuro for a topic
@Clear Maybe this could be helpful1 point -
Convert VBA Autocad to Autoit
user4157124 reacted to LarsJ for a topic
Credit for identifying the problem. AutoIt arrays are internally stored as safearrays of variants where the array type is VT_ARRAY + VT_VARIANT. If you create an AutoIt array of doubles this way Local $aDoubles = [ 5.0, 5.0, 0.0 ] then $aDoubles is stored as a safearray of 3 variants where each variant contains a double. This means that the type of the variant is VT_R8 which is the same as double, and the data of the variant is the value of the double. The type of the safearray is still VT_ARRAY + VT_VARIANT. But AddPoint method does not take a safearray of variants as input. It takes a safearray of doubles as input. That is a safearray of type VT_ARRAY + VT_R8. That's the reason for the invalid argument error. Although it is possible to create a safearray of doubles in AutoIt with Windows API functions, it's not possible to pass the array to the AddPoint method because of the internal COM conversions that only work for safearrays of variants. To avoid the internal COM conversions you can call AddPoint directly with DllCallAddress() through a pointer to the method. You can get this pointer in the VTABLE, and of course you also need a pointer directly to the VTABLE. Although you can find all the details in the link above, it's very tricky. It appears to be easier to use VBA code.1 point -
If you still need assistance, paste your code and I will modify.1 point
-
Or you can go the adlib route if your code is too complicated to be in a event loop or if you are extra lazy: AdlibRegister(ThreeMinuteExit, 60 * 3 * 1000) ; 3 minutes in milliseconds Func ThreeMinuteExit() MsgBox(0, "3 minutes", "Hey mate your time is up, now it is time to quit") Exit EndFunc @Xandy You used 3 seconds instead of the 3 minutes OP asked for by the way1 point
-
No commands working on window with CLASS #32770
FrancescoDiMuro reacted to jdelaney for a topic
I bet you may interact with the window and it's controls if you include: #RequireAdmin oops, there go my reading comprehension skills. Disregard. Try this instead: WinActivate returns a handle. Use that handle to the controlclick. You can also do a ConsoleOutput of that handle variable to make sure that you properly grabbed the window. A second note: you are looking for specific text in your first ControlClick function that doesn't exist in your window. A third note: when you use control click, the coordiantes only relate to INSIDE the control. If you click outside of the bounds of the control, no click will occur (that I'm aware of)...I can double check this in a bit...confirmed that doing a controlclick outside the bounds of the control will not actually click anything. So I would do this: #RequireAdmin $h = WinWait("Windows Security") ConsoleWrite("winwait handle=" & $h & @CRLF) $c = ControlGetHandle($h,"","Button1") ConsoleWrite("ControlGetHandle handle=" & $c & @CRLF) ControlClick($h,"",$c) Notice how I put in some error handling, so I can compare the handles against the spy tool to ensure that what I'm doing is working properly.1 point -
0x80070057 stands for E_INVALIDARG I searched the web for "HRESULT 0x80070057 autocad". Got a few hits but nothing seems to describe the problem. Then i searched the forum for the HRESULT. I think the following post (read the last few lines) describes what goes on. It seems to be an internal conversion problem with AutoIt and AutoCAD expecting a different format. Unfortunately what @LarsJ descibes is way over my head. Maybe he has a solution for this problem.1 point
-
Communication between 2 scripts
Mobius reacted to pixelsearch for a topic
@Mobius : You're right, I tested the 2 precedent scripts on "big" arrays, to find where the limit was : Local $aArray[555][4] For $row = 0 to 554 $aArray[$row][0] = $row & ":" & "0" $aArray[$row][1] = 528 $aArray[$row][2] = 31 $aArray[$row][3] = "HOSTNAME|1|02:45:47|abcdefgh|username|5" Next [555] rows are the limit in script 1, and $array2 will be ok in script 2 when [555] rows are populated like shown. But if you try [556] rows or more, an error will happen in script 2, _ArrayDisplay returning @error = 1 (not an array) So before the error happened, I copied the long variable $CmdLineRaw in a file, to test its length and analyze how it ends : FileWrite("c:\temp\test.txt", $CmdLineRaw) Results show that if its length is > 32Kb (that's 556 rows or more) then the error happens because it's an unterminated string. "AutoIt3 Limits/defaults" in help file shows a 32Kb limitation in these cases : MAX_ENVSIZE 32767 Maximum size for an ENV variable. WINTEXTBUFFER 32767 WM_GETTEXT randomly fails if > 32767 Good to know, sky isn't always the limit1 point -
Communication between 2 scripts
pixelsearch reacted to Mobius for a topic
The commandline idea is nice but while the OP's requirement of "1000 rows and 4 columns" might not exceed the maximum commandline length with some planning, the method would fail eventually with larger arrays including the element contents. DDE however is true IPC and would not entail the user having to be careful of exceeding a buffer length.1 point -
Get Desktop Shortcut Position and Set ToolTip?
GoogleDude reacted to faustf for a topic
remember for have help send code ... you have just look here? i dont know if .dat is flag for update , but you can use a txt , when download autoit .... write here a name and your script compare txt with name web grab by site (grab with _ie )1 point -
I would go this way: ;... Global $hLabel = GUICtrlCreateLabel("", 245, 245, 100, 20) ;... Local Const $sFormat = "hh:mm:ss tt" Local $iLenStr = StringLen($sFormat) + 1 ; Allocate enough memory with PAGE_EXECUTE_READWRITE for code to run $aCall = DllCall("kernel32.dll", "ptr", "VirtualAlloc", _ "ptr", 0, _ "dword", 2 * $iLenStr + 512, _ "dword", 4096, _ ; MEM_COMMIT "dword", 64) ; PAGE_EXECUTE_READWRITE If @error Or Not $aCall[0] Then Return SetError(6, 0, 0) EndIf Local $pRemoteCode = $aCall[0] ; Make structure in reserved space Local $CodeBuffer = DllStructCreate("byte[512]", $pRemoteCode) ; Arrange strings in reserved space Local $tSpace = DllStructCreate("wchar Format[" & $iLenStr & "];wchar Result[" & $iLenStr & "]", $pRemoteCode + 512) DllStructSetData($tSpace, "Format", $sFormat) ; Write assembly If @AutoItX64 Then DllStructSetData($CodeBuffer, 1, _ "0x" & _ "4883EC" & SwapEndian(72, 1) & _ "C7442428" & SwapEndian($iLenStr, 4) & _ "48BF" & SwapEndian(DllStructGetPtr($tSpace, "Result")) & _ "48897C2420" & _ "49B9" & SwapEndian(DllStructGetPtr($tSpace, "Format")) & _ "49C7C0" & SwapEndian(0, 4) & _ "BA" & SwapEndian(0, 4) & _ "B9" & SwapEndian(1033, 4) & _ "48B8" & SwapEndian($pGetTimeFormatW) & _ "FFD0" & _ "49B9" & SwapEndian(DllStructGetPtr($tSpace, "Result")) & _ "49C7C0" & SwapEndian(0, 4) & _ "BA" & SwapEndian(12, 4) & _ "48B9" & SwapEndian(GUICtrlGetHandle($hControl)) & _ "48B8" & SwapEndian($pSendMessageW) & _ "FFD0" & _ "B9" & SwapEndian(491, 4) & _ "48B8" & SwapEndian($pSleep) & _ "FFD0" & _ "4883C4" & SwapEndian(72, 1) & _ "E9" & SwapEndian(-136) & _ "C3" _ ) Else DllStructSetData($CodeBuffer, 1, _ "0x" & _ "68" & SwapEndian($iLenStr) & _ ; push output size "68" & SwapEndian(DllStructGetPtr($tSpace, "Result")) & _ ; push pointer to output container "68" & SwapEndian(DllStructGetPtr($tSpace, "Format")) & _ ; push pointer to format string "68" & SwapEndian(0) & _ ; push NULL "68" & SwapEndian(0) & _ ; push 0 "68" & SwapEndian(1033) & _ ; push en-us Locale "B8" & SwapEndian($pGetTimeFormatW) & _ ; mov eax, [$pGetTimeFormatW] "FFD0" & _ ; call eax "68" & SwapEndian(DllStructGetPtr($tSpace, "Result")) & _ ; push pointer to the result "68" & SwapEndian(0) & _ ; push wParam "68" & SwapEndian(12) & _ ; push WM_SETTEXT "68" & SwapEndian(GUICtrlGetHandle($hControl)) & _ ; push HANDLE "B8" & SwapEndian($pSendMessageW) & _ ; mov eax, [$pSendMessageW] "FFD0" & _ ; call eax "68" & SwapEndian(491) & _ ; push Milliseconds "B8" & SwapEndian($pSleep) & _ ; mov eax, [$pSleep] "FFD0" & _ ; call eax "E9" & SwapEndian(-81) & _ ; jump back 81 bytes (start address) "C3" _ ; Ret ) EndIf ;...1 point
-
1 point
-
Question on _GUIImageList usage
pixelsearch reacted to UEZ for a topic
I didn't know that _GUIImageList_Create() can handle an image this way using sub frames (nice to know). You can use WinAPI_RedrawWindow() to erase the gfx. #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <WinAPI.au3> #include <GDIPlus.au3> HotKeySet("{esc}", "Quit") Example() Func Example() Global $hImage, $hGUI, $hDC, $iX _GDIPlus_Startup() ; Load Image Local $hBitmap = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\muybridge12-hp-f.jpg") ; 12 frames a 67x54 px -> 804x54 px in sum -> this is a GDIPlus image Local $hGDIBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) ; convert GDIPlus bitmap to GDI format which is usable for _GUIImageList* functions _GDIPlus_BitmapDispose($hBitmap) ; release GDIPlus bitmap because not needed anymore $hImages = _GUIImageList_Create(67, 54) ; dimension of the single frame _GUIImageList_Add($hImages, $hGDIBitmap) ; add the whole strip to the ImageList ; Create the example GUI $hGUI = GUICreate("ImageList Draw", 400, 300) GUISetState(@SW_SHOW) $hDC = _WinAPI_GetDC($hGUI) ; Retrieves a handle of a display device context for the client area a window Do For $i = 0 To 11; loop all frames $iX += 10 $iX = Mod($iX, 410) _WinAPI_RedrawWindow($hGui) ;redraw means erase graphical content in the GUI _GUIImageList_Draw($hImages, $i, $hDC, $iX, 4) ; Draws an image list item in the specified device context Sleep(50) Next Until False EndFunc ;==>Example Func Quit() ; free memory _GDIPlus_Shutdown() _WinAPI_ReleaseDC($hGUI, $hDC) GUIDelete() Exit EndFunc ;==>Quit I added some more comments to the source. You can draw a retangle to erase also the background of the drawn images. Br, UEZ1 point -
U looked at an example not fitting your needs, this one fits better: #1 - Array based from #442099 #include <array.au3> $ddnumber = 0 $var = FileSelectFolder("Delete Empty directories from:", "", 7) If @error Then Exit $FileList = RecursiveFileSearch($var, "", "", 2, True) If @error = 1 Then MsgBox(0, "", "No Files\Folders Found.") Exit EndIf ;_ArrayDisplay($FileList) For $i = 1 To $FileList[0] If StringInStr(FileGetAttrib($FileList[$i]), "D") Then; If parent (empty) dir has already been deleted, FileGetAttrib returns Blank and further analysis is skiped. If DirGetSize($FileList[$i]) = 0 Then If DirRemove($FileList[$i]) Then ConsoleWrite("Dir removed: " & $FileList[$i] & @CRLF) $ddnumber += 1 Else ConsoleWrite("Could not remove (empty?) dir: " & $FileList[$i] & @CRLF) EndIf Else ConsoleWrite("Dir not removed (contains files): " & $FileList[$i] & @CRLF) EndIf EndIf Next If $ddnumber = 0 Then MsgBox(0, "No empty directories", "No empty directories found") Else MsgBox(0, "Results", $ddnumber & " empty directories removed") EndIf #cs ---------------------------------------------------------------------------- #1 - Array based from http://www.autoitscript.com/forum/index.php?showtopic=58558&view=findpost&p=442099 AutoIt Version: 3.2.10.0 Author: WeaponX Updated: 2/21/08 Script Function: Recursive file search 2/21/08 - Added pattern for folder matching, flag for return type 1/24/08 - Recursion is now optional Parameters: RFSstartdir: Path to starting folder RFSFilepattern: RegEx pattern to match "\.(mp3)" - Find all mp3 files - case sensitive (by default) "(?i)\.(mp3)" - Find all mp3 files - case insensitive "(?-i)\.(mp3|txt)" - Find all mp3 and txt files - case sensitive RFSFolderpattern: "(Music|Movies)" - Only match folders named Music or Movies - case sensitive (by default) "(?i)(Music|Movies)" - Only match folders named Music or Movies - case insensitive "(?!(Music|Movies)\b)\b.+" - Match folders NOT named Music or Movies - case sensitive (by default) RFSFlag: Specifies what is returned in the array 0 - Files and folders 1 - Files only 2 - Folders only RFSrecurse: TRUE = Recursive, FALSE = Non-recursive RFSdepth: Internal use only #ce ---------------------------------------------------------------------------- Func RecursiveFileSearch($RFSstartDir, $RFSFilepattern = ".", $RFSFolderpattern = ".", $RFSFlag = 0, $RFSrecurse = True, $RFSdepth = 0) ;Ensure starting folder has a trailing slash If StringRight($RFSstartDir, 1) <> "\" Then $RFSstartDir &= "\" If $RFSdepth = 0 Then ;Get count of all files in subfolders for initial array definition $RFSfilecount = DirGetSize($RFSstartDir, 1) ;File count + folder count (will be resized when the function returns) Global $RFSarray[$RFSfilecount[1] + $RFSfilecount[2] + 1] EndIf $RFSsearch = FileFindFirstFile($RFSstartDir & "*.*") If @error Then Return ;Search through all files and folders in directory While 1 $RFSnext = FileFindNextFile($RFSsearch) If @error Then ExitLoop ;If folder and recurse flag is set and regex matches If StringInStr(FileGetAttrib($RFSstartDir & $RFSnext), "D") Then If $RFSrecurse And StringRegExp($RFSnext, $RFSFolderpattern, 0) Then RecursiveFileSearch($RFSstartDir & $RFSnext, $RFSFilepattern, $RFSFolderpattern, $RFSFlag, $RFSrecurse, $RFSdepth + 1) If $RFSFlag <> 1 Then ;Append folder name to array $RFSarray[$RFSarray[0] + 1] = $RFSstartDir & $RFSnext $RFSarray[0] += 1 EndIf EndIf ElseIf StringRegExp($RFSnext, $RFSFilepattern, 0) And $RFSFlag <> 2 Then ;Append file name to array $RFSarray[$RFSarray[0] + 1] = $RFSstartDir & $RFSnext $RFSarray[0] += 1 EndIf WEnd FileClose($RFSsearch) If $RFSdepth = 0 Then ReDim $RFSarray[$RFSarray[0] + 1] Return $RFSarray EndIf EndFunc ;==>RecursiveFileSearch1 point