RISHKARI Posted March 12, 2016 Share Posted March 12, 2016 Hi, New to the forums and I hope I explain myself clearly enough. I am needing help with reading certain data and making a table with it, Basically the data is in a file which is a table already just no software to open it. I am not entirely sure where to start and still fairly new to Autoit. I thought maybe reading it in hex and then sorting it out to a table. If I read the file in say HexWorkshop I will get Quote 03 00 00 00 06 00 00 00 02 00 00 00 02 00 00 00 04 00 00 00 00 00 00 00 00 03 01 00 00 00 00 03 02 00 00 00 00 03 03 00 00 00 00 03 I have been able to understand what and how it works. First 4 bytes " 03 00 00 00 " is how many Columns, Next 4 " 06 00 00 00 " is Datatype (int32) for column 1, next 4 " 02 00 00 00 " is datatype(Byte) for column 2, next 4 " 02 00 00 00 " is datatype(Byte) for column 3 and then " 04 00 00 00 " is rows. From all that the rest is the data I want to be able to see in a table. There is 4 rows of data. 00 00 00 00 - 00 - 03 < 0 | 0 | 3 01 00 00 00 - 00 - 03 < 1 | 0 | 3 02 00 00 00 - 00 - 03 < 2 | 0 | 3 03 00 00 00 - 00 - 03 < 3 | 0 | 3 Any help would be really good! I have been stuck on this for a bout a week now trying to find anything to that will help. Thanks, Chris. Link to comment Share on other sites More sharing options...
RISHKARI Posted March 12, 2016 Author Share Posted March 12, 2016 No I don't but I can quickly make such a basic script and you can use that for a base. I'll just make it turn on LED on pin 13. Link to comment Share on other sites More sharing options...
AutoBert Posted March 12, 2016 Share Posted March 12, 2016 4 hours ago, RISHKARI said: I am needing help with reading certain data and making a table with it, Basically the data is in a file which is a table already just no software to open it. Please attach a datafile. 1 hour ago, RISHKARI said: No I don't but I can quickly make such a basic script and you can use that for a base. I'll just make it turn on LED on pin 13. I can't find sence or relation to thread. Link to comment Share on other sites More sharing options...
RISHKARI Posted March 12, 2016 Author Share Posted March 12, 2016 1 minute ago, AutoBert said: Please attach a datafile. I can't find sence or relation to thread. My second post was a complete mistake, I was replying to a guy on another thread and I posted it on this on. I can't figure out how to delete it or even edit it. Sorry for the confusion. Link to comment Share on other sites More sharing options...
Jfish Posted March 12, 2016 Share Posted March 12, 2016 6 hours ago, AutoBert said: Please attach a datafile. Agree that a sample data file would be a good start ... Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt Link to comment Share on other sites More sharing options...
RISHKARI Posted March 13, 2016 Author Share Posted March 13, 2016 10 hours ago, Jfish said: Agree that a sample data file would be a good start ... I've attached the the following Data file I speak of here. control.tbl Link to comment Share on other sites More sharing options...
Jfish Posted March 13, 2016 Share Posted March 13, 2016 On 3/11/2016 at 4:01 AM, RISHKARI said: Basically the data is in a file which is a table already just no software to open it I don't think that is accurate. I think you need some software to appropriately view the contents of this file. Some small research shows that they are mostly used in mods. What do you use to view the contents of this file? What does it open in? Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt Link to comment Share on other sites More sharing options...
tarretarretarre Posted March 13, 2016 Share Posted March 13, 2016 I would not recommend doing this in AutoIt since it can be done easier in other languages. First off you should use 010 editor to parse unkown files by bytes, its really convenient, I have used it multiple times with great success But if you really want to do it in AutoIt, you should take a look at this: Use FileOpen with this parameter $FO_READ (0) + $FO_BINARY (16) = Force binary mode (See Remarks). Here is more functions you might find useful for your quest BitAND, BitNOT, BitOR, BitRotate, BitShift, BitXOR, Hex Socket-IO - An event-driven TCP UDF (Realtime chat example) AutoIt-API-WS - An expressive HTTP server you can use to build your own API with (Screenshots) Link to comment Share on other sites More sharing options...
LarsJ Posted March 14, 2016 Share Posted March 14, 2016 It's pretty easy: $hFile = FileOpen( "control.tbl", 16 ) ; 16 = binary mode $sBinData = FileRead( $hFile ) $iBytes = @extended FileClose( $hFile ) ConsoleWrite( "Bytes: " & $iBytes & @CRLF ) $tBytes = DllStructCreate( "byte[" & $iBytes & "]" ) DllStructSetData( $tBytes, 1, $sBinData ) $pBytes = DllStructGetPtr( $tBytes ) $tHeader = DllStructCreate( "int[5]", $pBytes ) ConsoleWrite( "Header:" ) ConsoleWrite( " " & DllStructGetData( $tHeader, 1, 1 ) ) ConsoleWrite( " " & DllStructGetData( $tHeader, 1, 2 ) ) ConsoleWrite( " " & DllStructGetData( $tHeader, 1, 3 ) ) ConsoleWrite( " " & DllStructGetData( $tHeader, 1, 4 ) ) ConsoleWrite( " " & DllStructGetData( $tHeader, 1, 5 ) & @CRLF ) $pBytes += 20 $tagRow = "int;byte;byte" For $i = 1 To 4 $tRow = DllStructCreate( $tagRow, $pBytes ) ConsoleWrite( "Row " & $i & ":" ) ConsoleWrite( " " & DllStructGetData( $tRow, 1 ) ) ConsoleWrite( " " & DllStructGetData( $tRow, 2 ) ) ConsoleWrite( " " & DllStructGetData( $tRow, 3 ) & @CRLF ) $pBytes += 6 Next tarretarretarre 1 Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
RISHKARI Posted March 14, 2016 Author Share Posted March 14, 2016 23 hours ago, tarretarretarre said: I would not recommend doing this in AutoIt since it can be done easier in other languages. First off you should use 010 editor to parse unkown files by bytes, its really convenient, I have used it multiple times with great success But if you really want to do it in AutoIt, you should take a look at this: Use FileOpen with this parameter $FO_READ (0) + $FO_BINARY (16) = Force binary mode (See Remarks). Here is more functions you might find useful for your quest BitAND, BitNOT, BitOR, BitRotate, BitShift, BitXOR, Hex I was playing with FileOpen() however I couldn't manage to make it work. Autoit had to be able to read the data inside to finish up with a project I was working on. This really does help with storing data locally aswell. 5 hours ago, LarsJ said: It's pretty easy: $hFile = FileOpen( "control.tbl", 16 ) ; 16 = binary mode $sBinData = FileRead( $hFile ) $iBytes = @extended FileClose( $hFile ) ConsoleWrite( "Bytes: " & $iBytes & @CRLF ) $tBytes = DllStructCreate( "byte[" & $iBytes & "]" ) DllStructSetData( $tBytes, 1, $sBinData ) $pBytes = DllStructGetPtr( $tBytes ) $tHeader = DllStructCreate( "int[5]", $pBytes ) ConsoleWrite( "Header:" ) ConsoleWrite( " " & DllStructGetData( $tHeader, 1, 1 ) ) ConsoleWrite( " " & DllStructGetData( $tHeader, 1, 2 ) ) ConsoleWrite( " " & DllStructGetData( $tHeader, 1, 3 ) ) ConsoleWrite( " " & DllStructGetData( $tHeader, 1, 4 ) ) ConsoleWrite( " " & DllStructGetData( $tHeader, 1, 5 ) & @CRLF ) $pBytes += 20 $tagRow = "int;byte;byte" For $i = 1 To 4 $tRow = DllStructCreate( $tagRow, $pBytes ) ConsoleWrite( "Row " & $i & ":" ) ConsoleWrite( " " & DllStructGetData( $tRow, 1 ) ) ConsoleWrite( " " & DllStructGetData( $tRow, 2 ) ) ConsoleWrite( " " & DllStructGetData( $tRow, 3 ) & @CRLF ) $pBytes += 6 Next Mate, this is just perfect. I honestly expected it to be a lot bigger than what it is. I was wondering how I might go about reading a column that is string? The column it self can change in size but right before it starts it has 4 bytes saying how long the text is. I appreciate for help! Chris. tarretarretarre 1 Link to comment Share on other sites More sharing options...
LarsJ Posted March 14, 2016 Share Posted March 14, 2016 You do it in the same way: $tLength = DllStructCreate( "int", $pBytes ) $iLength = DllStructGetData( $tLength, 1 ) $pBytes += 4 $tString = DllStructCreate( "char[" & $iLength & "]", $pBytes ) ; ASCII ;$tString = DllStructCreate( "wchar[" & $iLength & "]", $pBytes ) ; UNICODE ConsoleWrite( DllStructGetData( $tString, 1 ) & @CRLF ) $pBytes += $iLength ; ASCII ;$pBytes += 2*$iLength ; UNICODE If you want an example you have to add a new data file. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
RISHKARI Posted March 14, 2016 Author Share Posted March 14, 2016 11 minutes ago, LarsJ said: You do it in the same way: $tLength = DllStructCreate( "int", $pBytes ) $iLength = DllStructGetData( $tLength, 1 ) $pBytes += 4 $tString = DllStructCreate( "char[" & $iLength & "]", $pBytes ) ; ASCII ;$tString = DllStructCreate( "wchar[" & $iLength & "]", $pBytes ) ; UNICODE ConsoleWrite( DllStructGetData( $tString, 1 ) & @CRLF ) $pBytes += $iLength ; ASCII ;$pBytes += 2*$iLength ; UNICODE If you want an example you have to add a new data file. Thank you for taking the time to help. I will give this a go in a moment, till then I have uploaded what I mean there for it is better explained. Thanks, Chris. control.tbl rights.tbl user_store.tbl Link to comment Share on other sites More sharing options...
LarsJ Posted March 15, 2016 Share Posted March 15, 2016 You can use this code for user_store.tbl: $hFile = FileOpen( "user_store.tbl", 16 ) ; 16 = binary mode $sBinData = FileRead( $hFile ) $iBytes = @extended FileClose( $hFile ) ConsoleWrite( "Bytes: " & $iBytes & @CRLF ) $tBytes = DllStructCreate( "byte[" & $iBytes & "]" ) DllStructSetData( $tBytes, 1, $sBinData ) $pBytes = DllStructGetPtr( $tBytes ) $tHeader = DllStructCreate( "int[4]", $pBytes ) ConsoleWrite( "Header:" ) ConsoleWrite( " " & DllStructGetData( $tHeader, 1, 1 ) ) ConsoleWrite( " " & DllStructGetData( $tHeader, 1, 2 ) ) ConsoleWrite( " " & DllStructGetData( $tHeader, 1, 3 ) ) ConsoleWrite( " " & DllStructGetData( $tHeader, 1, 4 ) & @CRLF ) $pBytes += 16 $tagRow = "int;int" For $i = 1 To 4 $tRow = DllStructCreate( $tagRow, $pBytes ) $iLength = DllStructGetData( $tRow, 2 ) $pBytes += 8 $tString = DllStructCreate( "char[" & $iLength & "]", $pBytes ) ConsoleWrite( "Row " & $i & ":" ) ConsoleWrite( " " & DllStructGetData( $tRow, 1 ) ) ConsoleWrite( " " & $iLength ) ConsoleWrite( " " & DllStructGetData( $tString, 1 ) & @CRLF ) $pBytes += $iLength Next For rights.tbl more information about the structure of the records is needed. In the same way as in post 1. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions 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