zeroZshadow Posted February 23, 2005 Share Posted February 23, 2005 Hi guys, i'm making a function to convert a file to hex so you can use the au3xtra.dll to send it. (sned the hex and convert it to a file again) Opt("TrayIconDebug",1) _Transfer() Global $trans[6000000] Func _Transfer() $file = FileOpenDialog("Send File","","Zip files (*.zip)") FileCopy($file,@scriptdir&"\file.txt") $getfile = FileOpen(@ScriptDir&"\file.txt",0) MsgBox(0,"test",$getfile) While Not @error = -1 $line = 1 $trans[$line] = FileReadLine($getfile,$line) MsgBox(0,"test",$trans[$line]) $line = $line + 1 Wend $type = "Zip" EndFunc but the damn thing won't work PLEASS help me *If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip... Link to comment Share on other sites More sharing options...
ZeDMIN Posted February 23, 2005 Share Posted February 23, 2005 (edited) I can see the error now, you too? Opt ("TrayIconDebug", 1) _Transfer() Global $trans[6000000] Func _Transfer() $file = FileOpenDialog("Send File", "", "Zip files (*.zip)") FileCopy($file, @ScriptDir & "\file.txt") $getfile = FileOpen(@ScriptDir & "\file.txt", 0) MsgBox(0, "test", $getfile) While Not @error = -1 $line = 1 $trans[$line] = FileReadLine($getfile, $line) MsgBox(0, "test", $trans[$line]) $line = $line + 1 WEnd $type = "Zip" EndFunc ;==>_Transfer The $line=1 has to be outside the while-loop or else it will read line 1 over and over again. BTW: I suggest taking FileRead for binary files instead of FileReadLine. Because you don't know how long "lines" will get in binary files. Edited February 23, 2005 by ZeDMIN Link to comment Share on other sites More sharing options...
zcoacoaz Posted February 23, 2005 Share Posted February 23, 2005 how do you get how many bytes are in a file? [font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font] Link to comment Share on other sites More sharing options...
SlimShady Posted February 23, 2005 Share Posted February 23, 2005 @Xenogis: FileGetSize() Link to comment Share on other sites More sharing options...
zeroZshadow Posted February 25, 2005 Author Share Posted February 25, 2005 (edited) oke, i really changed the script now, but it still has problems with counting lines. #include <string.au3> #include <file.au3> _filetohex() Func _filetohex() $getfile = FileOpenDialog("Open","","All files (*.*)") $string = stringsplit ( $getfile, "." ) $file = $string[1] & ".txt" filecopy ( $getfile, $file ) Global $countline = _FileCountLines($file) if $countline = 0 Then MsgBox(0,"Error","File could not be read") Else MsgBox(0,"Error",$countline) Global $lineread[$countline+1] Global $linehex[$countline+1] For $line = 1 to $countline $lineread[$line] = Filereadline($getfile,$line) $linehex[$line] = _StringToHex($lineread[$line]) ConsoleWrite($linehex[$line]&@lf) Next EndIf FileDelete($file) EndFunc YOU NEED SCITE FOR THIS ONE, OR A THING THAT READS CONSOLEWRITE o ya.......thanks for helping EDIT: text based files are going fine, but need to have it work with zip and exe and ....... Edited February 25, 2005 by zeroZshadow *If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip... Link to comment Share on other sites More sharing options...
upnorth Posted February 26, 2005 Share Posted February 26, 2005 (edited) expandcollapse popup_FileToHexFile(FileOpenDialog("Open","","All files (*.*)")) _HexFileToFile(FileOpenDialog("Open","","All files (*.*)")) Func _FileToHexFile($getfile) Local $file = $getfile & " - in hex.txt", _ $null = FileCopy ( $getfile, $file, 1), _ $file_content = FileRead ( $file, FileGetSize($file)), _ $file_handle = FileOpen ( $file , 2) FileWrite( $file_handle, _StringToHex( $file_content)) FileClose( $file_handle) EndFunc Func _HexFileToFile($getfile) Local $file = StringReplace($getfile , " - in hex.txt" , ""), _ $null = FileCopy ( $getfile, $file, 1), _ $file_content = FileRead ( $file, FileGetSize($file)), _ $file_handle = FileOpen ( $file , 2) FileWrite( $file_handle, _HexToString( $file_content)) FileClose( $file_handle) EndFunc Func _HexToString($strHex) Local $strChar, $iOne, $aryHex = StringSplit($strHex, "") For $i = 1 To $aryHex[0] $iOne = $aryHex[$i] $i = $i + 1 $strChar = $strChar & Chr(Dec($iOne & $aryHex[$i])) Next If $strChar = "" Then SetError(1) Return -1 Else Return $strChar EndIf EndFunc Func _StringToHex($strChar) Local $strHex, $aryChar = StringSplit($strChar, "") For $i = 1 To $aryChar[0] $strHex = $strHex & Hex(Asc($aryChar[$i]), 2) Next If $strHex = "" Then SetError(1) Return -1 Else Return $strHex EndIf EndFuncEDIT:Or Should i sayexpandcollapse popup5F46696C65546F48657846696C652846696C654F70656E4469616C6F6728224F70656E222C22222C22416C6C2066696C6573 20282A2E2A292229290D0A5F48657846696C65546F46696C652846696C654F70656E4469616C6F6728224F70656E222C2222 2C22416C6C2066696C657320282A2E2A292229290D0A0D0A46756E63205F46696C65546F48657846696C6528246765746669 6C65290D0A094C6F63616C202466696C65203D202467657466696C6520262022202D20696E206865782E747874222C205F0D 0A09246E756C6C203D2046696C65436F70792028202467657466696C652C202466696C652C2031292C205F0D0A092466696C 655F636F6E74656E74203D2046696C65526561642028202466696C652C2046696C6547657453697A65282466696C6529292C 205F0D0A092466696C655F68616E646C65203D2046696C654F70656E2028202466696C65202C203229090D0A0946696C6557 7269746528202466696C655F68616E646C652C205F537472696E67546F48657828202466696C655F636F6E74656E7429290D 0A0946696C65436C6F736528202466696C655F68616E646C65290D0A456E6446756E630D0A0D0A0D0A46756E63205F486578 46696C65546F46696C65282467657466696C65290D0A094C6F63616C202466696C65203D20537472696E675265706C616365 282467657466696C65202C2022202D20696E206865782E74787422202C202222292C205F0D0A09246E756C6C203D2046696C 65436F70792028202467657466696C652C202466696C652C2031292C205F0D0A092466696C655F636F6E74656E74203D2046 696C65526561642028202466696C652C2046696C6547657453697A65282466696C6529292C205F0D0A092466696C655F6861 6E646C65203D2046696C654F70656E2028202466696C65202C203229090D0A0946696C65577269746528202466696C655F68 616E646C652C205F486578546F537472696E6728202466696C655F636F6E74656E7429290D0A0946696C65436C6F73652820 2466696C655F68616E646C65290D0A456E6446756E630D0A0D0A0D0A0D0A0D0A0D0A46756E63205F486578546F537472696E 672824737472486578290D0A094C6F63616C2024737472436861722C2024694F6E652C2024617279486578203D2053747269 6E6753706C697428247374724865782C202222290D0A09466F72202469203D203120546F20246172794865785B305D0D0A09 0924694F6E65203D20246172794865785B24695D0D0A09092469203D202469202B20310D0A09092473747243686172203D20 2473747243686172202620436872284465632824694F6E65202620246172794865785B24695D29290D0A094E6578740D0A09 4966202473747243686172203D202222205468656E0D0A09095365744572726F722831290D0A090952657475726E202D310D 0A09456C73650D0A090952657475726E2024737472436861720D0A09456E6449660D0A456E6446756E630D0A0D0A46756E63 205F537472696E67546F486578282473747243686172290D0A094C6F63616C20247374724865782C20246172794368617220 3D20537472696E6753706C69742824737472436861722C202222290D0A09466F72202469203D203120546F20246172794368 61725B305D0D0A090924737472486578203D2024737472486578202620486578284173632824617279436861725B24695D29 2C2032290D0A094E6578740D0A0949662024737472486578203D202222205468656E0D0A09095365744572726F722831290D 0A090952657475726E202D310D0A09456C73650D0A090952657475726E20247374724865780D0A09456E6449660D0A456E64 46756E63 Edited February 26, 2005 by UP NORTH Link to comment Share on other sites More sharing options...
steveR Posted February 26, 2005 Share Posted February 26, 2005 Cool I needed this yesterday but didn't have a clue how to do it. Thanks. I haven't tried it yet though AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass. Link to comment Share on other sites More sharing options...
zeroZshadow Posted February 26, 2005 Author Share Posted February 26, 2005 @UP NORTH doesn't work well. if i try to convert a wma it returns just a little piece of the text. this also happens with other, NOT TEXT BASED, files. and thats what i just need, the hex code is needed to send a file to another pc, that will deconvert it again to use it *If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip... Link to comment Share on other sites More sharing options...
upnorth Posted February 26, 2005 Share Posted February 26, 2005 I forgot FileRead () returns what it has so far when it hits a null When is jon going to fix this? Link to comment Share on other sites More sharing options...
zeroZshadow Posted February 27, 2005 Author Share Posted February 27, 2005 common guys, is there ANY way to read a WHOLE file in a array that i can loop to lines of hex?? *If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip... Link to comment Share on other sites More sharing options...
Insolence Posted February 28, 2005 Share Posted February 28, 2005 Have you tried: _FileReadToArray($sFilePath, ByRef $aArray) "I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar. Link to comment Share on other sites More sharing options...
zeroZshadow Posted February 28, 2005 Author Share Posted February 28, 2005 nop doesn't work it'll stop ate the ☻ thingy. but the strange thing is that the wininfo tool can see the WHOLE text. then why doesn't the damn filetoarray and others do that??? i think where gonna need to ask this to jon or another smart guy (i ment that possitive) *If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip... 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