dv8

(RESOLVED) How to find the error by the line number returned from the compiled EXE?

61 posts in this topic

#1 ·  Posted (edited)

Hi guys,

please bare with me for a moment here...

My goal: To be able to take the error line number returned by the EXE file and locate the actual line in the source.

I believe most of the AutoIt users are coming to this issue at some point.

I realize the final source, before the compilation is done, is the combined source of all the include files and the main script etc. So I figured if I have a way to get this combined source, that would give me a solution to this problem. And I spent the last couple of days (more than 10 hours a day) searching in the forum and asking some questions in different threads. And with the help of few people, I found a way (using the Obfuscator) to get this source and the line numbers were actually MATCHING!

However this solution introduced a WHOLE LOT of other problems for me and broke some of the functionality in my script since it has a lot of Call() and ObjEvent() functions. My code turned out to be un-obfuscatable. And for the record, I do not need any obfuscation done at all, nor I need the unused included functions stripped down (even though it made my EXE a 30% smaller). I needed the Obfuscator just to get this final piece of code to be able to achieve My goal.

So all this got me thinking... Please correct me if I'm wrong, because I don not have any knowledge of the internals of a compiler.

Since Aut2exe is the one that combines all the code together and then working it's magic to create the EXE, there should be a pint in this process where that code is available in its final form. Then why isn't there a command line option to dump the final combined source in a file just before it is compiled?

Once again, I do not know the internals of the compiler but my logic dictates that this would be the most reasonable and straightforward solution.

Please share your thoughts and also, if any of you knows a way to achieve my goal without using the Obfuscator, I would LOVE to here it!

EDIT: And here is the solution: ( I've tried to explain it as simply as I can, so even the beginners can understand it.)

With the huge help from Jos, the goal in this post is now achieved, by using the (version 1.0.29.8 and above) and the /MergeOnly (or /MO) option.

So, if you want to be able to find the errors reported by your compiled (EXE) scripts easily, you will need to add this line:

#Obfuscator_Parameters=/mergeonly

at the beginning of your script and run it through the Obfuscator (version 1.0.29.8 and above).

The option in the line above will not do any obfuscation to your code. It will only merge all the included files into just one, called YourScriptInitialName_Obfuscated.au3.

Now if you compile the obfuscated file, the error line numbers reported by your EXE file should match the lines in this obfuscated file. And once you find the right line of code, it should be a piece of cake to locate this line in your original source code. So make sure you keep this file somewhere for future error reference. :)

IMPORTANT NOTE: You should pay attention to the messages that Obfuscator gives, or check the Obfuscator.log file after the process is completed for any messages like this one:

-Line: 2. Encountered a continuationline which would be longer than 4095 when merge into 1 line, so spliting this continuation line into multiple lines..

If there is a similar line displayed, the line numbers from the error report and the obfuscated source will NOT match. In order to match them, you will need to merge any lines broken into smaller lines with the continuation character ("_") in the obfuscated source. But you will have to do that AFTER you have compiled your EXE file from that obfuscated script.

Here is how the process works:

1. Add #Obfuscator_Parameters=/mergeonly at the beginning of your AU3 script

2. Obfuscate your AU3 script using the Obfuscator.exe (version 1.0.29.8 and above)

3. Compile the obfuscated script.

4. Check the Obfuscator.log file (it is in the same folder where the Obfuscator.exe is installed) for a line similar to the bulded one in the above text.

5. If no similar lines are found - you are good to go and the line numbers should match.

6. If there are similar lines, you will need to merge the lines splitted with the continuation ("_") character in order for your line numbers to match the number in the error report.

If you come to the 6th point in the above list, you can either search for these lines manually, or you can use the following script to do the changes for you:

If $CmdLine[0]=1 AND FileExists($CmdLine[1]) Then
   $SourceFileName=$CmdLine[1]
Else
    $SourceFileName = FileOpenDialog("Specify the file to be processed", @ScriptDir, "AutoIt3 Script (*.au3)", 3)
   If @error Then Exit
EndIf

$ScriptData = Fileread($SourceFileName)
;Merge Continuation line into one line
$ScriptData = StringRegExpReplace($ScriptData, "( _rn)", "")
$TargetFileName = StringReplace($SourceFileName,".","_N.",-1)
FileDelete($TargetFileName)
FileWrite($TargetFileName, $ScriptData)

Edited by dv8
1 person likes this

Share this post


Link to post
Share on other sites



All it does is read out any include files and simply copy-paste them in your script. If you do this manually, it will take you 5 minutes. If you write a program to do this, it will take you 10 minutes.

Good luck.

Share this post


Link to post
Share on other sites

Thank you. Is this the way you do it? If it is, why don't you share your program?

I will sure try to do that and I may solve my problem this way. However this will not do much good to the next user who bumps into this problem.

And may I ask, what good is that line number for, if this line number does not exists anywhere in the scripts for reference?

The fact that this number is there suggests that there should be a way to get to it, right?

I'll do some programming after my lunch and post the solution here if I manage to get satisfactory results.

Share this post


Link to post
Share on other sites

This is a trivial problem. Anyone can solve it in 10 minutes. I don't have the code to do it or I would have shared it with you. Who do you think I am? Some kind of person who doesn't share his code... No. There is probably a configuration for obfuscator to do this as well. Fortunately for you, obfuscator is well documented.

I say again: Good luck.

This is such a trivial thing to do that it's not worth annoying me or anyone about. Starting thinking before doing and you'll do just fine.

Share this post


Link to post
Share on other sites

As I mentioned above I spent the A LOT of time reading through the Obfuscator documentation and testing different configuration options. And again as I stated above it only brought more problems on the table instead of solving this "trivial" one for me.

And maybe because it is so "trivial", there is no solution to it offered by anyone yet.

I say again: Thank you!

Believe me, I do A LOT of thinking and reading, then testing, before doing and I do just fine.

Please do not annoy yourself any more with this issue. I would really like to see what other people think about this. Thank you.

Share this post


Link to post
Share on other sites

All it does is read out any include files and simply copy-paste them in your script. ...

OK,

here is what I did, following Manadar's suggestion:

;Au3CodeAppender.au3
;Written by dv8 on Feb. 24 2012
;Any suggestions and improvements are welcome!

#Include <string.au3>

If $CmdLine[0]=1 AND FileExists($CmdLine[1]) Then
   $SourceFile=$CmdLine[1]
Else
    ConsoleWrite("ERROR: The input file does not exist!"&@CRLF)
   Exit
EndIf

ConsoleWrite(StringTrimRight(@ScriptFullPath,4)&".ini"&@CRLF)
GLOBAL $IncludeLibrariesPath=INIRead(StringTrimRight(@ScriptFullPath,4)&".ini","General","IncludeLibrariesPath","")
If $IncludeLibrariesPath<>"" AND StringRight($IncludeLibrariesPath,1)<>'\' Then $IncludeLibrariesPath&='\'
If Not FileExists($IncludeLibrariesPath) Then
   ConsoleWrite("ERROR: The IncludeLibrariesPath ("&$IncludeLibrariesPath&") does not exist. Please set it in the INI file."&@CRLF)
    Exit
EndIf
GLOBAL $IncludedFiles=""                                        ;This is to keep track of the included files so they do not get included twice.
GLOBAL $NewContent=""

RecursiveAddFile($SourceFile)

$DestFile=FileOpen(StringTrimRight($SourceFile,4)&"_Merged.au3",2)
FileWrite($DestFile,$NewContent)
FileClose($DestFile)

Func RecursiveAddFile($File)
ConsoleWrite("Currently adding: "&$File&@CRLF)
   $tmp=StringSplit($File,"\")
    $SourceFileName=$tmp[$tmp[0]]
    $SourceFilePath=$tmp[1]&'\'
    For $i=2 To $tmp[0]-1
       $SourceFilePath&=$tmp[$i]&'\'
    Next
    $F=FileOpen($File,0)
    While 1
        $Line=FileReadLine($F)
        If @error<>0 Then ExitLoop
        If StringLower(StringLeft(StringStripWS($Line,1),13))="#include-once" Then
            ContinueLoop
        ElseIf StringLower(StringLeft(StringStripWS($Line,1),8))="#include" Then
            $TrimmedLine=StringStripWS(StringTrimLeft($Line,8),3)
ConsoleWrite("Found #include "&$TrimmedLine&@CRLF)
            If StringInStr($TrimmedLine,'<') AND StringInStr($TrimmedLine,'>') Then
            $aName=_StringBetween($TrimmedLine,"<",">")
                $FileN=StringStripWS($aName[0],3)
                $FileToAdd=$IncludeLibrariesPath&$FileN
                If Not StringInStr($IncludedFiles,$FileToAdd) Then
             $IncludedFiles&=$FileToAdd&"|"
             RecursiveAddFile($FileToAdd)
                Else
ConsoleWrite("Skipping: "&$FileToAdd&" (Already added)"&@CRLF)
                EndIf
            ElseIf StringInStr($TrimmedLine,'"') AND StringInStr($TrimmedLine,'"') Then
                $aName=_StringBetween($TrimmedLine,'"','"')
            $FileN=StringStripWS($aName[0],3)
                $FileToAdd=$SourceFilePath&$FileN
                If Not StringInStr($IncludedFiles,$FileToAdd) Then
             $IncludedFiles&=$FileToAdd&"|"
             RecursiveAddFile($FileToAdd)
                Else
ConsoleWrite("Skipping: "&$FileToAdd&" (Already added)"&@CRLF)
                EndIf
            ElseIf StringInStr($TrimmedLine,"'") AND StringInStr($TrimmedLine,"'") Then
                $aName=_StringBetween($TrimmedLine,"'","'")
            $FileN=StringStripWS($aName[0],3)
                $FileToAdd=$SourceFilePath&$FileN
                If Not StringInStr($IncludedFiles,$FileToAdd) Then
             $IncludedFiles&=$FileToAdd&"|"
             RecursiveAddFile($FileToAdd)
                Else
ConsoleWrite("Skipping: "&$FileToAdd&" (Already added)"&@CRLF)
                EndIf
            Else
                ConsoleWrite("ERROR: Unrecognized #Include line ("&$Line&")"&@CRLF)
            FileClose($F)
                Exit
            EndIf
        Else
         $NewContent&=$Line&@CRLF
        EndIf
    Wend
    FileClose($F)
EndFunc

It also needs an INI file with the same name to read the path to the AutoIt "Include" library:

;Au3CodeAppender.ini
[General]
IncludeLibrariesPath=D:\Tools\AutoIt\Include\

This program generates a new YourScriptName_Merged.au3 script with no #include directives, wich contains all the include files that were reffered in the main script.

However, when I tested it with an intentionally added error line in my script, the reported line was 35427 and the line in the source is actually 75549.

So apparently this approach is not working. So any suggestions, anyone?

Share this post


Link to post
Share on other sites

Why not use the parameters of Obfuscator e.g. /StripOnly?


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

Please read my first post carefully! I already stated there that the Obfuscator "...broke some of the functionality in my script since it has a lot of Call() and ObjEvent() functions."

Share this post


Link to post
Share on other sites

Did you remove the #include lines from the modified script? Sounds like it might be adding them twice.


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 Gude
How 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

Share this post


Link to post
Share on other sites

I did but saying you used Obfuscator doesn't really tell much. Oh well.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

Guys, do you read the posts at all? ;) This is frustrating. :)

I said: "This program generates a new YourScriptName_Merged.au3 script with no #include directives, which contains all the include files that were referred in the main script."

You are also welcome to try it and give any suggestions...

1 person likes this

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Now strip empty lines and comments. Then you're done. I don't think compiler directives are removed. Maybe #cs is removed, but I'm pretty sure that #include-once isn't.

I just stripped string.au3 by hand to remove all comments and empty lines and it had 216 lines. My script: #include<string.au3> Kek() fails on line 217.

Edited by Manadar

Share this post


Link to post
Share on other sites

I tried your script just now, it doesn't have any way of including any UDFs that aren't in the include folder that I can see. Not to mention, it includes the entire file that you're including even functions you're not using.


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 Gude
How 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

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Not to mention, it includes the entire file that you're including even functions you're not using.

That's what AutoIt does as well. Edited by Manadar

Share this post


Link to post
Share on other sites

BrewManNH - It does include the #Include "filename.au3" files. Check again...

Manadar - we are getting closer. I stripped the empty lines and left the #include-once directives. The reported line number was 35427 and the actual line is now 39207. Only about 3800 lines more to get rid of. :)

Here is the new version.

;Au3CodeAppender.au3
;Written by dv8 on Feb. 24 2012
;Any suggestions and improvements are welcome!

#Include <string.au3>

If $CmdLine[0]=1 AND FileExists($CmdLine[1]) Then
   $SourceFile=$CmdLine[1]
Else
    ConsoleWrite("ERROR: The input file does not exist!"&@CRLF)
   Exit
EndIf

ConsoleWrite(StringTrimRight(@ScriptFullPath,4)&".ini"&@CRLF)
GLOBAL $IncludeLibrariesPath=INIRead(StringTrimRight(@ScriptFullPath,4)&".ini","General","IncludeLibrariesPath","")
If $IncludeLibrariesPath<>"" AND StringRight($IncludeLibrariesPath,1)<>'' Then $IncludeLibrariesPath&=''
If Not FileExists($IncludeLibrariesPath) Then
   ConsoleWrite("ERROR: The IncludeLibrariesPath ("&$IncludeLibrariesPath&") does not exist. Please set it in the INI file."&@CRLF)
    Exit
EndIf
GLOBAL $IncludedFiles=""                                        ;This is to keep track of the included files so they do not get included twice.
GLOBAL $NewContent=""

RecursiveAddFile($SourceFile)

$DestFile=FileOpen(StringTrimRight($SourceFile,4)&"_Merged.au3",2)
FileWrite($DestFile,$NewContent)
FileClose($DestFile)

Func RecursiveAddFile($File)
ConsoleWrite("Currently adding: "&$File&@CRLF)
   $tmp=StringSplit($File,"")
    $SourceFileName=$tmp[$tmp[0]]
    $SourceFilePath=$tmp[1]&''
    For $i=2 To $tmp[0]-1
       $SourceFilePath&=$tmp[$i]&''
    Next
    $F=FileOpen($File,0)
    While 1
        $Line=FileReadLine($F)
        If @error<>0 Then ExitLoop
        If StringStripWS($Line,8)="" Then
            ContinueLoop
        ElseIf StringLeft(StringStripWS($Line,1),1)=';' Then
         ContinueLoop
        ElseIf StringLower(StringLeft(StringStripWS($Line,1),8))="#include" AND StringLower(StringLeft(StringStripWS($Line,1),13))<>"#include-once"Then
            $TrimmedLine=StringStripWS(StringTrimLeft($Line,8),3)
ConsoleWrite("Found #include "&$TrimmedLine&@CRLF)
            If StringInStr($TrimmedLine,'<') AND StringInStr($TrimmedLine,'>') Then
            $aName=_StringBetween($TrimmedLine,"<",">")
                $FileN=StringStripWS($aName[0],3)
                $FileToAdd=$IncludeLibrariesPath&$FileN
                If Not StringInStr($IncludedFiles,$FileToAdd) Then
             $IncludedFiles&=$FileToAdd&"|"
             RecursiveAddFile($FileToAdd)
                Else
ConsoleWrite("Skipping: "&$FileToAdd&" (Already added)"&@CRLF)
                EndIf
            ElseIf StringInStr($TrimmedLine,'"') AND StringInStr($TrimmedLine,'"') Then
                $aName=_StringBetween($TrimmedLine,'"','"')
            $FileN=StringStripWS($aName[0],3)
                $FileToAdd=$SourceFilePath&$FileN
                If Not StringInStr($IncludedFiles,$FileToAdd) Then
             $IncludedFiles&=$FileToAdd&"|"
             RecursiveAddFile($FileToAdd)
                Else
ConsoleWrite("Skipping: "&$FileToAdd&" (Already added)"&@CRLF)
                EndIf
            ElseIf StringInStr($TrimmedLine,"'") AND StringInStr($TrimmedLine,"'") Then
                $aName=_StringBetween($TrimmedLine,"'","'")
            $FileN=StringStripWS($aName[0],3)
                $FileToAdd=$SourceFilePath&$FileN
                If Not StringInStr($IncludedFiles,$FileToAdd) Then
             $IncludedFiles&=$FileToAdd&"|"
             RecursiveAddFile($FileToAdd)
                Else
ConsoleWrite("Skipping: "&$FileToAdd&" (Already added)"&@CRLF)
                EndIf
            Else
                ConsoleWrite("ERROR: Unrecognized #Include line ("&$Line&")"&@CRLF)
            FileClose($F)
                Exit
            EndIf
        Else
         $NewContent&=$Line&@CRLF
        EndIf
    Wend
    FileClose($F)
EndFunc

Share this post


Link to post
Share on other sites

That's what AutoIt does as well.

But with Obfuscator you can strip them out.

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 Gude
How 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

Share this post


Link to post
Share on other sites

BrewManNH - It does include the #Include "filename.au3" files. Check again...

No actually it doesn't. I used it on a small script that has #include lines in that point to files that are in the same folder as the script, this script doesn't include them when it's run on my script. I used the include directive #include <myincludefile.au3> which points to a file in the script folder, even though I'm not using the quotes to tell the script that it's in the same folder, AutoIt will find and include them, you script ignores them and doesn't tell me it can't find them.

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 Gude
How 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

Share this post


Link to post
Share on other sites

:) Manadar,

I hope you see now that this is not exactly a 10 minutes process and it involves A LOT of guessing what exactly Aut2Exe does. And imagine that we manage to guess it right and make this program match the line numbers, then the next version of Aut2Exe is changed due to a bug fix, then what? Start the guessing game again?

And since Aut2Exe already does what we are trying to do here, I don't see why we can't use this in our advantage. I believe it won't be too much of a trouble for the developer to add some kind of command line switch (/DumpSource for example) and once the Aut2Exe gets to the point where the whole source is prepared for compilation, it checks for that switch and dumps the source into InputFilename_Dump.au3 for example.

So I would like to put this a feature request. I believe it is reasonable and will make finding bugs in the compiled scripts a lot easier.

Share this post


Link to post
Share on other sites

I was not aware that you can use the #include <myincludefile.au3> directive to include files from the script folder. I thought only #include "myincludefile.au3" is used for local includes.

OK, I'll account for this in the next modification... Thanks for letting me know.

Share this post


Link to post
Share on other sites

Compile the file that you create from your script. The line numbers almost match. (Try to get rid of all the directives.)

It's actually not such a big deal to do this, considering the alternatives. My initial 10 minute script observation was based on the old compiler. It has obviously changed. But it's still not a big deal at all. (Again: considering the alternative).

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Similar Content

    • ur
      By ur
      I have an exe with name "erwin Data Modeler r9.7 (32-bit)_2332.exe"
       
      THe lat 4 digits 2332 may vary and also the version number r9.7 also might vary.
      So, how to write a generic expression so that the exe can be picked from the current directory {with any version (9.7 or anything) and any build number (2332 or anything)}
       
      Thanks in Advance
    • knuxfighter
      By knuxfighter
      Hello. I've been working with Imagesearch library lately and it did a good work, although I moved to a new PC and didn't copy the old files with me so I downloaded the Imagesearch from the following post
       hoping that it will work. It doesn't though. First time I when I use (run as subscript to my code) the Imagesearch.au3, Scite finds errors (missing spaces). Ctrl+T (scite tidy) fixes these missing spaces but the script returns the following error on every run after:
      _ImageSearch('search.bmp', 0, $x, $y, 0) outputs
       
      "C:\Users\Knuckles\Desktop\AutoIt\include\ImageSearch.au3" (44) : ==> Subscript used on non-accessible variable.: If $result[0] = "0" Then Return 0 If $result^ ERROR no matter if I put the searched bmp in the script folder or folder img in the script directory. Also, it doesn't matter if the searched image on screen or not, it returns the same.

      Can you provide me any help please? I remember having these problems 2 years ago when I first met the imagesearch library also (I fixed it somehow though in that time). Seems nothing changed.

      Using this version posted in the following post gives the same error:
      Also I run windows 10 64bit and I have no shell options for script editing, running as x86 or whatever as I used to have on windows xp/7. I went through some steps like deleting a key in registry and I even reinstalled autoit and scite but that only resulted to au3 as unrecognized file format and not in getting back the menus and the icon on au3 files. Any thoughts on this?

      Edit: Installing 64-bit AutoIt and using 64bit ImageSearch is no change.
      code.au3

      FOUND WORKING: http://www.codebot.de/index.php/Thread/12713-Imagesearch-au3-funktioniert-nicht/
       but why is this one working and the original aren't? :(
    • BJJ
      By BJJ
      Hello everyone,
      I have huge problem with "Recurison level has been exceeded - AutoIt will quit to prevent stack overflow" in my own Bot.
      I have no idea how rebuild my loops for eliminate this type of error.
       
      Here is my code 
       
      #Region #AutoIt3Wrapper_Icon=C:\Users\barbosa\Desktop\autoIt\produkcja\angelica.ico #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_Res_Fileversion=1.0 #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y #AutoIt3Wrapper_Run_Obfuscator=y #EndRegion #Region ; GUI generated by GUIBuilderNxt Prototype 1.0 #include <Constants.au3> #include <GUIConstantsEx.au3> #include <Misc.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <StaticConstants.au3> ;#include <nomad.au3> HotKeySet("{end}","stop") ;end for app kill Local Const $sFont = "Open Sans" ;font variable Local $sFile = "angelica.ico" ;icon variable Global $MainStyle = BitOR($WS_OVERLAPPED, $WS_CAPTION, $WS_SYSMENU, $WS_VISIBLE, $WS_CLIPSIBLINGS, $WS_MINIMIZEBOX, $FW_SEMIBOLD = 600) Global $info_task = "[ Waiting for calibration ]",$info_battlelist = "None",$info_empty = "None",$info_hotkeys = "INACTIVE",$info_100 = "None",$info_mana = "None",$info_food = "None",$info_blank = "None",$info_drop = "None",$info_hand = "None" Global $hMain = GuiCreate("Auto_Angela_Beta_1.0", 330, 559, -1, -1, $MainStyle) GUISetIcon($sFile) $label_100 = GuiCtrlCreateLabel("[F4] Mana Point "&" "&$info_100, 20, 40, 170, 20,-1) $label_mana = GuiCtrlCreateLabel("[F5] Mana Bar "&" "&$info_mana, 20, 60, 170, 20,-1) $label_empty = GuiCtrlCreateLabel("[F6] Nothing "&" "&$info_empty, 20, 80, 170, 20,-1) $label_battlelist = GuiCtrlCreateLabel("[F7] Battle List "&" "&$info_battlelist, 20, 100, 170, 20,-1) $label_food = GuiCtrlCreateLabel("[F8] Food "&" "&$info_food, 20, 120, 170, 20,-1) $label_blank = GuiCtrlCreateLabel("[F9] Blank "&" "&$info_blank, 20, 140, 170, 20,-1) $label_drop = GuiCtrlCreateLabel("[F10] Drop "&" "&$info_drop, 20, 160, 170, 20,-1) $label_hand = GuiCtrlCreateLabel("[F11] Hand "&" "&$info_hand, 20, 180, 170, 20,-1) $Group_11 = GuiCtrlCreateGroup("Configuration", 10, 10, 190, 220,-1) $Group_12 = GuiCtrlCreateGroup("Setup", 210, 10, 110, 220,-1) $btn_setting = GuiCtrlCreateButton("Setup", 220, 40, 70, 30,-1) $btn_load = GuiCtrlCreateButton("Load", 220, 100, 70, 30,-1) $btn_save = GuiCtrlCreateButton("Save", 220, 140, 70, 30,-1) $label_hotkeys = GuiCtrlCreateLabel("Status: "&$info_hotkeys, 220, 190, 90, 20,-1) $input_spell = GuiCtrlCreateInput("Adura Vita", 20, 270, 120, 20,-1) $box_house_mode = GuiCtrlCreateCheckbox("House mode", 20, 300, 90, 20,-1) $box_pk_mode = GuiCtrlCreateCheckbox("Anty PK", 20, 330, 90, 20,-1) $Checkbox_20 = GuiCtrlCreateCheckbox("Alarms", 20, 360, 90, 20,-1) $Checkbox_21 = GuiCtrlCreateCheckbox("Anty Idle", 20, 390, 90, 20,-1) $btn_auto = GuiCtrlCreateButton("Start", 200, 360, 70, 30,-1) $btn_refiler = GuiCtrlCreateButton("Rune thrower", 200, 400, 70, 20,-1);$btn_manual = GuiCtrlCreateButton("Start", 200, 360, 70, 30,-1) $Input_22 = GuiCtrlCreateInput("down", 140, 300, 60, 20,-1) $Input_23 = GuiCtrlCreateInput("up", 210, 300, 60, 20,-1) $Group_24 = GuiCtrlCreateGroup("Mode", 10, 250, 310, 180,-1) GUISetFont(9, $FW_SEMIBOLD) ;white color and bigger font ;$label_task = GuiCtrlCreateLabel($info_task, 10, 450, 370, 24,-1) GUICtrlSetColor($label_task, 0xffffff) GUISetFont(9, $FW_MEDIUM) $Label_28 = GuiCtrlCreateLabel("Auto_Angela_Beta 1.1 @ Medivia 2016", 60, 530, 370, 20,-1) Global $way_one Global $way_one Global $food_pos_x,$food_pos_y Global $hand_pos_x,$hand_pos_y Global $drop_pos_x,$drop_pos_y Global $blank_pos_x, $blank_pos_y Global $RunOrNot Global $pid Global $hotkeys = 0 ;By default hotkeys are disabled Global $mana_color, $battle_color Global $mana_100_x,$mana_100_y Global $mana_pixel_x, $mana_pixel_y Global $empty_pixel_x = 000, $empty_pixel_y = 000 Global $battle_pixel_x, $battle_pixel_y Global $is_break ;Global $MapClickEscape_x, $MapClickEscape_y ;GUICtrlSetDefColor(0xFF0000) GUISetBkColor(0x788190) ; will change background color ;GUICtrlSetBkColor($label_hand, 0xF0F4F9) GuiSetState(@SW_SHOWNORMAL) Do Switch GuiGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $btn_setting _EnableDisable() ;function which make hotkeys enable/disable Case $btn_auto IF $info_food <> "None" OR $info_blank <> "None" OR $info_drop <> "None" OR $info_hand <> "None" OR $info_100 <> "None" OR $info_mana <> "None" Then ;simple validation data in possitions variables check_mana() ;Function is first in chain for making runes Else MsgBox(0, "Error", "You must setup coordinations") EndIf Case $btn_load load_from_file() ;load data from text file Case $btn_save save_to_file() ;dave data in text file Case $btn_refiler refiler() ;for fast refile EndSwitch Until False #EndRegion ;Func uher() ;x,y postaci = F10 DROP ;x,y uha w plecaku = F9 Blank ;kolor uha pobrany przy ustawieniu ;kolor plecaka = F6 BP Color ;odpowienio przygotowane staki plecakow ;co 400ms sprawdza czy jest dosc hp na uha ;jesli trzeba sie uchnac to sprawdza czy w miejscu na uha jest niebieska runa ;jesli nie ma to sprawdza czy jest yellow bp jesli nie ma to sygnal dzwiekowy bledu i kill uhera ;jesli jest to otwiera plecak i sprawdza czy jest niebieska runa jak nie ma to error i kill uhera ;jesli jest to ja przeciaga na postac bardzo szybko ;EndFunc Func refiler() local $i = 20 While $i > 0 MouseClickDrag($MOUSE_CLICK_LEFT, $blank_pos_x, $blank_pos_y, $drop_pos_x, $drop_pos_y, 1) $i = $i - 1 WEnd EndFunc Func save_to_file() $file = FileOpen("angela_memory.txt", 1) If $file = -1 Then MsgBox(0, "Error", "Unable to save data.") Else FileWrite($file, $mana_100_x & @CRLF) FileWrite($file, $mana_100_y & @CRLF) FileWrite($file, $mana_pixel_x & @CRLF) FileWrite($file, $mana_pixel_y & @CRLF) FileWrite($file, $empty_pixel_x & @CRLF) FileWrite($file, $empty_pixel_y & @CRLF) FileWrite($file, $battle_pixel_x & @CRLF) FileWrite($file, $battle_pixel_y & @CRLF) FileWrite($file, $food_pos_x & @CRLF) FileWrite($file, $food_pos_y & @CRLF) FileWrite($file, $blank_pos_x & @CRLF) FileWrite($file, $blank_pos_y & @CRLF) FileWrite($file, $drop_pos_x & @CRLF) FileWrite($file, $drop_pos_y & @CRLF) FileWrite($file, $hand_pos_x & @CRLF) FileWrite($file, $hand_pos_y & @CRLF) MsgBox(0, "Done", "Settings saved.") EndIf EndFunc Func load_from_file() $file = FileOpen("angela_memory.txt", $FO_READ) If $file = -1 Then MsgBox(0, "Error", "Unable to load data.") Else ;wczytywanie segmentow $mana_100_x = FileReadLine($file, 1) $mana_100_y = FileReadLine($file, 2) $info_100 = "X: "&$mana_100_x&" "&"Y: "&$mana_100_y GUICtrlSetData($label_100, "[F4] Mana point "&" "&$info_100) ;;;; $mana_pixel_x = FileReadLine($file, 3) $mana_pixel_y = FileReadLine($file, 4) $info_mana = "X: "&$mana_pixel_x&" "&"Y: "&$mana_pixel_y GUICtrlSetData($label_mana, "[F5] Mana Bar "&" "&$info_mana) ;;;; $empty_pixel_x = FileReadLine($file, 5) $empty_pixel_y = FileReadLine($file, 6) $info_empty = "X: "&$empty_pixel_x&" "&"Y: "&$empty_pixel_y GUICtrlSetData($label_empty, "[F6] Nothing "&" "&$info_empty) ;;;; $battle_pixel_x = FileReadLine($file, 7) $battle_pixel_y = FileReadLine($file, 8) $info_battlelist = "X: "&$battle_pixel_x&" "&"Y: "&$battle_pixel_y GUICtrlSetData($label_battlelist, "[F7] Battle List "&" "&$info_battlelist) ;;;; $food_pos_x = FileReadLine($file, 9) $food_pos_y = FileReadLine($file, 10) $info_food = "X: "&$food_pos_x&" "&"Y: "&$food_pos_y GUICtrlSetData($label_food, "[F8] Food "&" "&$info_food) ;;;; $blank_pos_x = FileReadLine($file, 11) $blank_pos_y = FileReadLine($file, 12) $info_blank = "X: "&$blank_pos_x&" "&"Y: "&$blank_pos_y GUICtrlSetData($label_blank, "[F9] Blank "&" "&$info_blank) ;;;; $drop_pos_x = FileReadLine($file, 13) $drop_pos_y = FileReadLine($file, 14) $info_drop = "X: "&$drop_pos_x&" "&"Y: "&$drop_pos_y GUICtrlSetData($label_drop, "[F10] Drop "&" "&$info_drop) ;;;; $hand_pos_x = FileReadLine($file, 15) $hand_pos_y = FileReadLine($file, 16) $info_hand = "X: "&$hand_pos_x&" "&"Y: "&$hand_pos_y GUICtrlSetData($label_hand, "[F11] Hand "&" "&$info_hand) ;;;; FileClose($file) MsgBox(0, "Done", "Settings loaded") EndIf EndFunc Func stop() Exit EndFunc Func kill() Exit 0 EndFunc ;functions checking if checkbox checked Func _IsChecked_pk_mode($box_pk_mode) Return BitAND(GUICtrlRead($box_pk_mode), $GUI_CHECKED) = $GUI_CHECKED EndFunc ;==>_IsChecked Func _IsChecked_house_mode($box_house_mode) Return BitAND(GUICtrlRead($box_house_mode), $GUI_CHECKED) = $GUI_CHECKED EndFunc ;==>_IsChecked Func floor_maker() ;GUICtrlSetData($label_task, "[ Burning rune.. ]") $spell_name = GUICtrlRead($input_spell) $way_one = GUICtrlRead($Input_22) $way_two = GUICtrlRead($Input_23) If _IsChecked_house_mode($box_house_mode) Then ControlSend("Medivia","","", "{" & $way_one & "}" ) EndIf Sleep(1000) MouseClickDrag($MOUSE_CLICK_LEFT, $blank_pos_x, $blank_pos_y, $hand_pos_x, $hand_pos_y, 2) ControlSend("Medivia","","",$spell_name) ControlSend("Medivia","","","{enter}") MouseClickDrag($MOUSE_CLICK_LEFT, $hand_pos_x, $hand_pos_y, $drop_pos_x, $drop_pos_y, 2) Sleep(300) MouseClick($MOUSE_CLICK_RIGHT, $food_pos_x, $food_pos_y, 4, 10) Sleep(400) MouseClick($MOUSE_CLICK_RIGHT, $food_pos_x, $food_pos_y, 4, 10) Sleep(300) If _IsChecked_house_mode($box_house_mode) Then ControlSend("Medivia","","", "{" & $way_two & "}" ) EndIf Beep(1000, 150) check_mana() EndFunc Func _EnableDisable() If $hotkeys = 0 Then HotKeySet("{F4}", "mana_100") HotKeySet("{F5}", "mana_get_color") ;HotKeySet("{F6}", "MapClickEscape") HotKeySet("{F7}", "battle_get_color");Pobiera kolor do zmiennej $battle_color HotKeySet("{F8}", "mouse_pos_food") HotKeySet("{F9}", "mouse_pos_blank") HotKeySet("{F10}", "mouse_pos_drop") HotKeySet("{F11}", "mouse_pos_hand") $hotkeys = 1 $info_hotkeys = "ACTIVE" GUICtrlSetData($label_hotkeys, "Status: "&" "&$info_hotkeys) GUICtrlSetData($label_task, "[ Calibration in progress ]") Else HotKeySet("{F4}") HotKeySet("{F5}") HotKeySet("{F6}") HotKeySet("{F7}") HotKeySet("{F8}") HotKeySet("{F9}") HotKeySet("{F10}") HotKeySet("{F11}") $hotkeys = 0 $info_hotkeys = "INACTIVE" GUICtrlSetData($label_hotkeys, "Status: "&" "&$info_hotkeys) GUICtrlSetData($label_task, "[ End of calibration ]") EndIf EndFunc Func check_mana() ;sleep(700) ;IsSafty() $current_color = PixelGetColor($mana_100_x,$mana_100_y) ;Taking current color from defined mana break point on maan bar $BattleListColor = PixelGetColor($battle_pixel_x, $battle_pixel_y) ;Taking current color from defined posiotion on battle list If _IsChecked_pk_mode($box_pk_mode) Then ;only if pk_mode checkbox is checked If $BattleListColor = $battle_color Then ;If collor on battle list point didnt change, means nothing (player/monster) enter on out screen $RunOrNot = True Else $RunOrNot = False EndIf EndIf If Not ($RunOrNot = False) Then ;If variable RunOrNot are not false it mean is true = is safe If $mana_color = $current_color Then ;If mana color flood mana bar break point floor_maker() ;rune making function Else ;GUICtrlSetData($label_task, "[ Waiting for mana.. ]") Sleep(1000) check_mana() ;Mana arnt ready so back to mana checking EndIf Else ;If not safty then run escape function runforestrun() EndIf EndFunc Func runforestrun() $way_one = GUICtrlRead($Input_22) $way_two = GUICtrlRead($Input_23) ControlSend("Medivia","","", "{" & $way_one & "}" ) Sleep(5000) Do ;GUICtrlSetData($label_task, "[ Not safty outside!! ]") Beep(700,300) Beep(200,500) Sleep(5000) ;IsSafty() $BattleListColor = PixelGetColor($battle_pixel_x, $battle_pixel_y) If $BattleListColor = $battle_color Then $RunOrNot = True Else $RunOrNot = False EndIf Until $RunOrNot = True MouseClick($MOUSE_CLICK_RIGHT, $food_pos_x, $food_pos_y, 4) Sleep(1000) ControlSend("Medivia","","", "{" & $way_two & "}" ) Sleep(2000) check_mana() EndFunc Func mana_100() $pos = MouseGetPos() $mana_100_x = $pos[0] $mana_100_y = $pos[1] $info_100 = "X: "&$mana_100_x&" "&"Y: "&$mana_100_y GUICtrlSetData($label_100, "[F4] Mana point "&" "&$info_100) EndFunc Func mana_get_color() $pos = MouseGetPos() $mana_pixel_x = $pos[0] $mana_pixel_y = $pos[1] $mana_color = PixelGetColor($mana_pixel_x, $mana_pixel_y) $info_mana = "X: "&$mana_pixel_x&" "&"Y: "&$mana_pixel_y GUICtrlSetData($label_mana, "[F5] Mana Bar "&" "&$info_mana) EndFunc Func battle_get_color() $pos = MouseGetPos() $battle_pixel_x = $pos[0] $battle_pixel_y = $pos[1] $battle_color = PixelGetColor($battle_pixel_x, $battle_pixel_y) $info_battlelist = "X: "&$battle_pixel_x&" "&"Y: "&$battle_pixel_y GUICtrlSetData($label_battlelist, "[F7] Battle List "&" "&$info_battlelist) EndFunc Func mouse_pos_food() $pos = MouseGetPos() $food_pos_x = $pos[0] $food_pos_y = $pos[1] $info_food = "X: "&$food_pos_x&" "&"Y: "&$food_pos_y GUICtrlSetData($label_food, "[F8] Food "&" "&$info_food) EndFunc Func mouse_pos_hand() $pos = MouseGetPos() $hand_pos_x = $pos[0] $hand_pos_y = $pos[1] $info_hand = "X: "&$hand_pos_x&" "&"Y: "&$hand_pos_y GUICtrlSetData($label_hand, "[F11] Hand "&" "&$info_hand) EndFunc Func mouse_pos_drop() $pos = MouseGetPos() $drop_pos_x = $pos[0] $drop_pos_y = $pos[1] $info_drop = "X: "&$drop_pos_x&" "&"Y: "&$drop_pos_y GUICtrlSetData($label_drop, "[F10] Drop "&" "&$info_drop) EndFunc Func mouse_pos_blank() $pos = MouseGetPos() $blank_pos_x = $pos[0] $blank_pos_y = $pos[1] $info_blank = "X: "&$blank_pos_x&" "&"Y: "&$blank_pos_y GUICtrlSetData($label_blank, "[F9] Blank "&" "&$info_blank) EndFunc Func afk() ControlSend("Medivia","","","{ctrldown}{down}{ctrlup}") Sleep(350) ControlSend("Medivia","","","{ctrldown}{up}{ctrlup}") EndFunc  
    • jonson1986
      By jonson1986
      Hey I searched code on autoit forum and modify it according to my needs and try to translate text from Russian to English in return I'm getting error such as "Error 411 (Length Required)!!1"
      Both my autoit codes and error I got are given below, please help me to solve this issue, Thanks
      Autoit codes to translate text form Russian to English;
      #include <urlencode.au3> $File1 = @ScriptDir & "\russian_text.txt" $txt = FileRead($File1) ; Try to convert line breaks with .....so final URL looks simpler $txt = StringReplace($txt, @CRLF, '...........') $txt = StringReplace($txt, @LF, '.............') $txt = StringReplace($txt, @CR, '.............') FileWrite (@scriptdir & '\russian_text2.txt', $txt) $openfile = @ScriptDir & "\russian_text2.txt" $mytext = FileRead ($openfile) $encoding = urlencode ($mytext) FileWrite (@scriptdir & '\enooding.txt', $encoding) $from = "ru" $to = "en" $url = "https://translate.googleapis.com/translate_a/single?client=gtx" $url &= "&sl=" & $from & "&tl=" & $to & "&dt=t&q=" & $encoding $oHTTP = ObjCreate("Microsoft.XMLHTTP") $oHTTP.Open("POST", $url, False) $oHTTP.Send() $sData = $oHTTP.ResponseText $sData = StringRegExpReplace($sData, '.*?\["(.*?)(?<!\\)"[^\[]*', "$1" & @crlf) FileWrite (@scriptdir & '\errorcode.txt', $sData) Msgbox(0,"", $sData) In response of above codes, I'm getting below error;
       
      <!DOCTYPE html> <html lang=en> <meta charset=utf-8> <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width"> <title>Error 411 (Length Required)!!1</title> <style> *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px} </style> <a href=//www.google.com/><span id=logo aria-label=Google></span></a> <p><b>411.</b> <ins>That’s an error.</ins> <p>POST requests require a <code>Content-length</code> header. <ins>That’s all we know.</ins>  
    • Masum
      By Masum
      Hi all,
      I'm facing a random error, whereby the ExcelRangeRead function is storing the first letter of a string as a lowercase rather than the uppercase it is stored in Excel. This happens about 10% of the times. And only with one of the ExcelRangeRead functions below, Global $RTERuleName = _Excel_RangeRead($oWorkbook, 'CHFT Pools & RTE Rules', 'I' & $Row)
      Func ExtractDCWData() Global $PoolName = _Excel_RangeRead($oWorkbook, 'CHFT Pools & RTE Rules', 'G' & $Row) Global $PoolDescription = _Excel_RangeRead($oWorkbook, 'CHFT Pools & RTE Rules', 'H' & $Row) Global $RTERuleName = _Excel_RangeRead($oWorkbook, 'CHFT Pools & RTE Rules', 'I' & $Row) Global $FirstName = _Excel_RangeRead($oWorkbook, 'CHFT Pools & RTE Rules', 'F' & $Row) Global $LastName = _Excel_RangeRead($oWorkbook, 'CHFT Pools & RTE Rules', 'E' & $Row) Global $Notes = _Excel_RangeRead($oWorkbook, 'CHFT Pools & RTE Rules', 'L' & $Row) Sleep(200) EndFunc ;==>ExtractDCWData The excel column looks like this.

      The script that writes the data out is as follows.
      Func AddRTERule() MouseClick('Primary', 69, 657, 1) ;Click Rules... Sleep(200) MouseClick('Primary', 363, 228, 1) ;Click Type Sleep(200) MouseClick('Primary', 363, 266, 1) ;Click RTE Sleep(200) MouseClick('Primary', 363, 545, 1) ;Click New Rule Sleep(200) Send($RTERuleName) ;Enter Mnemonic Sleep(200) Send('{TAB}') ;Enter Description Sleep(100) ;Theres more lines of code in this function... EndFunc ;==>AddRTERule Any ideas?