nitekram Posted August 3, 2006 Share Posted August 3, 2006 I wrote some code to open a file and wanted to make sure I had the right path in the exe, so I used this application and what was 6 k turned into 62 k - I then looked at the code and found a lot of things that were not mine. I think I have the answer, but want to make sure - all calls to external functions are added to the exe file and therefore when it is brought back into a au3 file it comes with it. Is this right? 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 3, 2006 Moderators Share Posted August 3, 2006 You'll see where it says Start Include/String.au3 and End Include/String.au3 as an example when decompiled. But the Entire include file is included, not just the functions you are using. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
nitekram Posted August 4, 2006 Author Share Posted August 4, 2006 You'll see where it says Start Include/String.au3 and End Include/String.au3 as an example when decompiled. But the Entire include file is included, not just the functions you are using.I get it now. Thanks. 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
MHz Posted August 4, 2006 Share Posted August 4, 2006 (edited) Here is a cleanup script I made some time ago to cleanup decompiled scripts for something to do. It will backup your script by FileMove. Worked ok when last tested. expandcollapse popupGlobal Const $IDYES = 6 If $CMDLINE[0] = 1 Then ; Use Commandline selection $file_source = $CMDLINE[1] If StringInStr($file_source, '\') Then $split = StringSplit($file_source, '\') If Not @error Then $path = StringReplace($file_source, '\' & $split[$split[0]], '') If @extended And FileExists($path) Then FileChangeDir($path) EndIf EndIf EndIf Else ; Use FileOpenDialog selection While True $file_source = FileOpenDialog('Choose a decompiled Au3 file to process', @WorkingDir, 'AutoIt files (*.au3)') If @error Then If MsgBox(0x40024, @ScriptName, 'Do you want to quit') = $IDYES Then Exit EndIf Else ExitLoop EndIf WEnd EndIf ; Check that file does indeed exist, else exit If Not FileExists($file_source) Then Exit ; Read whole file at once $file_read = FileRead($file_source, FileGetSize($file_source)) If Not @error And $file_read Then ; Split the file into an array $line = StringSplit($file_read, @CRLF, 1) $file_read = '' If Not @error And IsArray($line) Then Global $contents_script, $contents_include ; Loop to process each element of the array For $i = 1 To $line[0] Select Case _StringLeft($line[$i], '; <AUT2EXE VERSION') ; Skip 1st few lines While Not _StringLeft($line[$i], '; <AUT2EXE INCLUDE-START:') ; Increase element index $i += 1 WEnd ContinueLoop Case _StringLeft($line[$i], '; -----------------') ; Skip separator lines ContinueLoop Case _StringLeft($line[$i], '; <AUT2EXE INCLUDE-START:') ; Change Include code section start into #include <...> If StringInStr($line[$i], '\') Then $split = StringSplit($line[$i], '\') If Not @error Then $contents_script = '#include <' & $split[$split[0]] $file_include = StringTrimRight($split[$split[0]], 1) EndIf Else $contents_script = StringReplace($line[$i], '; <AUT2EXE INCLUDE-START: ', '#include <') EndIf ; Increase element index $i += 1 ; Process Include code section While Not _StringLeft($line[$i], '; <AUT2EXE INCLUDE-END:') If _StringLeft($line[$i], '; <AUT2EXE INCLUDE-START:') Then ; Decrease element index, Clear Include variable and restart the For loop $i -= 1 $contents_include = '' ContinueLoop 2 EndIf ; Concatenate Include lines $contents_include &= @CRLF & $line[$i] ; Increase element index $i += 1 WEnd ; Write Include file, clear Include variable and restart the For loop If Not FileExists($file_include) Then FileWrite($file_include, $contents_include) EndIf $contents_include = '' ContinueLoop Case _StringLeft($line[$i], '; <AUT2EXE INCLUDE-END:') ; Skip Include-end lines ContinueLoop EndSelect ; Concatenate Script lines $contents_script &= @CRLF & $line[$i] Next EndIf EndIf ;~ ConsoleWrite(StringStripCR($contents_script) & @LF) ;~ ConsoleWrite(StringStripCR($contents_include) & @LF) If FileMove($file_source, StringTrimRight($file_source, 4) & '.bak.au3') Then FileWrite($file_source, $contents_script) EndIf Exit Func _StringLeft(ByRef $string, $substring) Local $substring_length = StringLen($substring) If $substring_length Then Return StringLeft($string, $substring_length) = $substring EndIf EndFunc Compile it and drop a script on it. It perhaps could be improved more. Edit: Removed the last line in the code as it should have been outside the [ codetag ] Edited August 4, 2006 by MHz Link to comment Share on other sites More sharing options...
nitekram Posted August 4, 2006 Author Share Posted August 4, 2006 That is F#$ing amazing. I wish I could understand it, maybe in time. I think if I could understand it - I would add a status to it. Thanks for the great tool - I luv autoIT and all the great people on this forum that give their time so freely. Wish the rest of the world would be so kind! 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 4, 2006 Moderators Share Posted August 4, 2006 Following your example MHz, I took a stab at it:expandcollapse popupIf $CMDLINE[0] = 1 Then $hFile_Source = $CMDLINE[1] If StringInStr($hFile_Source, '\') Then $aSplit = StringSplit($hFile_Source, '\') If Not @error Then $sPath = StringReplace($hFile_Source, '\' & $aSplit[$aSplit[0]], '') If @extended And FileExists($sPath) Then FileChangeDir($sPath) EndIf EndIf EndIf Else While True $hFile_Source = FileOpenDialog('Choose a decompiled Au3 file to process', @WorkingDir, 'AutoIt files (*.au3)') If @error Then If MsgBox(0x40024, @ScriptName, 'Do you want to quit') = 6 Then Exit EndIf Else ExitLoop EndIf WEnd EndIf Global $hRead = FileRead($hFile_Source) If @error Or Not $hRead Then Exit Global $sAUTStart = "; <AUT2EXE INCLUDE-START: ", $sAUTEnd = "; <AUT2EXE INCLUDE-END: " Global $sSeperator = "; ----------------------------------------------------------------------------" $aIncStrings = _SRE_Between($hRead, $sAUTStart, ">") If Not IsArray($aIncStrings) Then Exit Global $aStringIncSE[UBound($aIncStrings)][3], $sHoldString, $nCount = 6 For $iCount = 1 To UBound($aIncStrings) - 2 $aStringIncSE[$iCount][0] = $sAUTStart & $aIncStrings[$iCount] & '>' $aStringIncSE[$iCount][1] = $sAUTEnd & $aIncStrings[$iCount] & '>' $aStringIncSE[$iCount][2] = '#include ' & '"' & $aIncStrings[$iCount] & '"' Next $hRead = StringSplit($hRead, @LF, 1) Global $xCount = 7, $iFound While $xCount < ($hRead[0] - 5) If StringInStr($hRead[$xCount], $sAUTStart) Then For $iCount = 1 To UBound($aStringIncSE, 1) - 1 If StringLeft($hRead[$xCount], StringLen($aStringIncSE[$iCount][0])) = $aStringIncSE[$iCount][0] Then $sHoldString &= $aStringIncSE[$iCount][2] & @LF $xCount += 1 $iFound = Not $iFound ExitLoop EndIf Next If $iFound Then While 1 If StringLeft($hRead[$xCount], StringLen($sAUTEnd)) = $sAUTEnd Then $xCount += 3 $iFound = Not $iFound ExitLoop EndIf $xCount += 1 WEnd EndIf ElseIf StringLeft($hRead[$xCount], StringLen($sSeperator)) = $sSeperator Then $xCount += 1 Else $sHoldString &= $hRead[$xCount] & @LF $xCount += 1 EndIf WEnd If FileMove($hFile_Source, StringTrimRight($hFile_Source, 4) & '.bak.au3') Then FileWrite($hFile_Source, StringTrimRight(StringTrimLeft($sHoldString, 2), 2)) EndIf Exit Func _SRE_Between($s_String, $s_Start, $s_End) $a_Array = StringRegExp($s_String, '(?:' & $s_Start & ')(.*?)(?:' & $s_End & ')', 3) If IsArray($a_Array) Then Return $a_Array EndFunc Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
MHz Posted August 4, 2006 Share Posted August 4, 2006 $hRead = StringSplit($hRead, @LF, 1)Nice, only thing that I could see as a weakness was StringSplit() with error check and @LF is only 1 character so the 3rd parameter seems unnecessary. But a nice recode. Just need a Gui like Exe2Aut now to top it off. Link to comment Share on other sites More sharing options...
nitekram Posted August 4, 2006 Author Share Posted August 4, 2006 I must say - I will have to compare these two scripts to see why SmOke_n's is so much faster. And I like both ways of opening the file - the second way seems to be user friendly. 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
nitekram Posted August 4, 2006 Author Share Posted August 4, 2006 Nice, only thing that I could see as a weakness was StringSplit() with error check and @LF is only 1 character so the 3rd parameter seems unnecessary. But a nice recode. Just need a Gui like Exe2Aut now to top it off. I think we should just add the code to the Exe2Aut - with a check box, checked you get your code only and unchecked you get all the code - if that is possible? 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
MHz Posted August 4, 2006 Share Posted August 4, 2006 I think we should just add the code to the Exe2Aut - with a check box, checked you get your code only and unchecked you get all the code - if that is possible?Perhaps, but no great need for it. 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