wakummaci Posted November 17, 2009 Posted November 17, 2009 Hi guys, having some problem here and I can't figure it out what matters . So the thing is my source file (test.txt) looks kinda like this: 00ECF5F5 0 0 00EBF3F5 0 1 00EAF3F5 0 2 00E9F4F6 0 3 00E9F4F8 0 4 00E8F4FA 0 5 . . . . So what I would like my program to do is to read in the first line, a hexa code, and store it and later work with it, but not even this simple step is going to be done and I don't know the reason of it.. I also tried $szin = FileRead($file,8) instead of $szin = FileReadline($file,$i) but didn't work either... any help appreciated . My code is here: expandcollapse popupGlobal $Paused HotKeySet("{PAUSE}", "TogglePause") Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) WEnd EndFunc $file = FileOpen("test.txt", 1) $i=1 $j=2 $k=3 While 1 $szin = FileReadline($file,$i) $x = FileReadline($file,$j) $y = FileReadline($file,$k) Send ($i) send ("!e") send ("{enter}") send ("!d") $coord = PixelSearch( 843, 879, 1086, 494, $szin ) If @error Then Msgbox(0,"Problem","Problem here") Else Mouseclick ("left",$coord[0],$coord[1],0) Mouseclick ("left",646,581,0) Mouseclick ("left",$x,$y,0) Endif $i=$i+3 $j=$j+3 $k=$k+3 Wend FileClose($file)
omikron48 Posted November 17, 2009 Posted November 17, 2009 (edited) Hex values in Autoit are prefixed with '0x'. e.g. 0xFFFF Also, FileRead outputs a string, not a number. Edited November 17, 2009 by omikron48
Authenticity Posted November 17, 2009 Posted November 17, 2009 expandcollapse popupGlobal $Paused HotKeySet("{PAUSE}", "TogglePause") Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) WEnd EndFunc $file = FileOpen("test.txt", 0) ; 0 for reading, 1 for writing. Unless you're using AutoIt version greater than 3.3.0.0 which may work different. $i=1 $j=2 $k=3 While 1 $szin = FileReadline($file,$i) $x = FileReadline($file,$j) $y = FileReadline($file,$k) Send ($i) send ("!e") send ("{enter}") send ("!d") $coord = PixelSearch( 843, 879, 1086, 494, Dec($szin) ) ; or "0x" & $szin If @error Then Msgbox(0,"Problem","Problem here") Else Mouseclick ("left",$coord[0],$coord[1],0) Mouseclick ("left",646,581,0) Mouseclick ("left",$x,$y,0) Endif $i=$i+3 $j=$j+3 $k=$k+3 Wend FileClose($file)
wakummaci Posted November 18, 2009 Author Posted November 18, 2009 (edited) Still getting error whichever method I use. I also tried to change the txt to: 15529461 0 0 15463413 0 1 15397877 0 2 15332598 0 3 . . . so basically just decimal colour numbers but not working.. Edited November 18, 2009 by wakummaci
wakummaci Posted November 18, 2009 Author Posted November 18, 2009 update: with hex it's working but the problem is that my txt file has got a '00' before the hex values... any ideas how to read the hex value only? this is the code that makes my output: $file = FileOpen("test.txt", 1) For $i = 0 to 100 step 1 For $j = 0 to 100 step 1; $colour = PixelGetColor( $i, $j ) FileWrite($file, hex ($colour)) FileWrite($file, "" & @CRLF) FileWrite($file, "" &$i) FileWrite($file, "" & @CRLF) FileWrite($file, "" &$j) FileWrite($file, "" & @CRLF) Next Next FileClose($file)
GEOSoft Posted November 18, 2009 Posted November 18, 2009 (edited) Here is a starting point for you using an array instead. FileReadLine() is very slow anyway. $aFile = _CreateArray(FileRead("Test.txt")) If NOT @Error Then For $i = 0 To UBound($aFile) -1 Step 3 MsgBox(0, "Result", "Color = " & $aFile[$i] & @CRLF & $aFile[$i +1] & @CRLF & $aFile[$i +2]) Next EndIf Func _CreateArray($s_Str) If NOT $s_Str Then Return SetError(1) $s_Str = StringRegExpReplace($s_Str, "(?i)(?m:^)([[:xdigit:]]\S+)", "0x$1") Local $sSRE = "(?i)(?m:^)([a-f\d]\S*)" $aSRE = StringRegExp($s_Str, $sSRE, 3) If NOT @Error Then Return $aSRE EndIf Return SetError(1) EndFunc EDIT: I should have pointed out that test.txt contained this. Quote 00ECF5F5 0 0 00EBF3F5 0 1 00EAF3F5 0 2 00E9F4F6 0 3 00E9F4F8 0 4 00E8F4FA 0 5 EDIT 2: Code cleanup for speed Edited November 18, 2009 by GEOSoft George Reveal hidden contents Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
Negat1ve Posted November 18, 2009 Posted November 18, 2009 (edited) Try out this Msgbox(0,"color",0x & filereadline("test.txt",1)) Edited November 18, 2009 by Negat1ve
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