Kip Posted June 5, 2009 Share Posted June 5, 2009 (edited) Hi, I found a dll on this forum to create structs by calling a dll. It was posted a long time ago, before structures were included in AutoIt. It's called DllMem.dll. You don't need it for my problem though. I have a piece of code (not in AutoIt, but that doesn't matter either) $ReadInt = new DLL("DllMem.dll", "ReadInt", INT, INT+INT); // just loading the function nothing special $ReadByte = new DLL("DllMem.dll", "ReadByte", INT, INT+INT); // same story $ret = $ReadInt( $POINT, 4 ); // Returns 757 (byte 0-3) $ReadByte( $POINT, 0 ); // Returns 67 (byte 0) $ReadByte( $POINT, 1 ); // Returns 1 (byte 1) $ReadByte( $POINT, 2 ); // Returns 0 (byte 2) $ReadByte( $POINT, 3 ); // Returns 0 (byte 3) Now, what if I don't know 757. What do I have to do with 67, 1, 0 and 0 to get to 757? Thanks, Kip. Edited June 5, 2009 by Kip MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
Squirrely1 Posted June 5, 2009 Share Posted June 5, 2009 ...I have a piece of code (not in AutoIt, but that doesn't matter either)...Netherlands - You know you really probably should write your code in the selfsame language from beginning to end - "Not AutoIt" is probably a language that does not use "$" to designate a variable - what language are you trying to use? Das Häschen benutzt Radar Link to comment Share on other sites More sharing options...
martin Posted June 5, 2009 Share Posted June 5, 2009 Hi, I found a dll on this forum to create structs by calling a dll. It was posted a long time ago, before structures were included in AutoIt. It's called DllMem.dll. You don't need it for my problem though. I have a piece of code (not in AutoIt, but that doesn't matter either) $ReadInt = new DLL("DllMem.dll", "ReadInt", INT, INT+INT); // just loading the function nothing special $ReadByte = new DLL("DllMem.dll", "ReadByte", INT, INT+INT); // same story $ret = $ReadInt( $POINT, 4 ); // Returns 757 (byte 0-3) $ReadByte( $POINT, 0 ); // Returns 67 (byte 0) $ReadByte( $POINT, 1 ); // Returns 1 (byte 1) $ReadByte( $POINT, 2 ); // Returns 0 (byte 2) $ReadByte( $POINT, 3 ); // Returns 0 (byte 3) Now, what if I don't know 757. What do I have to do with 67, 1, 0 and 0 to get to 757? Thanks, Kip. Have you got any more example values? I don't see the link between 67,1 and 757. Are you sure the dll function is returning data from the same struct for RedByte and ReadInt? Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Kip Posted June 5, 2009 Author Share Posted June 5, 2009 (edited) Oh damn, there was a bug in my script. I'm starting to see a connection now, wait just give me a minute.Edit:ok eerm:If ReadInt is below 128 then the first ReadByte = the same value as ReadInt.When ReadInt is above 128 but below 256, ReadInt = 128+(128+ReadByte), and ReadByte is a negative numberafter that the second ReadByte begins counting, and so on.Edit2: I just read it again and I can understand if you don't get it There must be some kind of Bit function for this...examples:ReadInt = 70 ; it's under 128, so the first ReadByte is the same.Byte1 = 70Byte2 = 0Byte3 = 0Byte4 = 0 = ReadInt = 175 ; It's above 128 and below 256, so the first ReadByte = 128+(128+-81)Byte1 = -81 ; 128+(128+-81) = 175Byte2 = 0Byte3 = 0Byte4 = 0ReadInt = 260Byte1 = 4Byte2 = 1Byte3 = 0Byte4 = 0ReadInt = 390Byte1 = -122Byte2 = 1Byte3 = 0Byte4 = 0256 is the maximal number of different values one byte can hold. So... it makes sense (somewhere) Edited June 5, 2009 by Kip MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
trancexx Posted June 5, 2009 Share Posted June 5, 2009 It's this: $iExample1 = 0x00000070 $iExample2 = 0x000000AF $iExample3 = 0x00000104 $iExample4 = 0x00000186 Read bytes. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Kip Posted June 5, 2009 Author Share Posted June 5, 2009 (edited) I'm sorry, I don't understand what you're trying to say. Edit: Ooh, wait... Edited June 5, 2009 by Kip MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
martin Posted June 5, 2009 Share Posted June 5, 2009 I'm sorry, I don't understand what you're trying to say. Edit: Ooh, wait... $s1 = dllstructcreate("int") $s2 = dllstructcreate("ubyte[4]",dllstructgetptr($s1)) Dllstructsetdata($s1,1,260) ConsoleWrite(dllstructgetdata($s2,1,1) & @CRLF) ConsoleWrite(dllstructgetdata($s2,1,2) & @CRLF) ConsoleWrite(dllstructgetdata($s2,1,3) & @CRLF) ConsoleWrite(dllstructgetdata($s2,1,4) & @CRLF) Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Kip Posted June 5, 2009 Author Share Posted June 5, 2009 So, in AutoIt, it would be: $b1 = -122 $b2 = 1 $b3 = 0 $b4 = 0 $sHex = Hex($b4,2) & Hex($b3,2) & Hex($b2,2) & Hex($b1,2) MsgBox(0,"sds", "Hex: 0x"& $sHex &@CRLF& "Dec: "&Dec($sHex) ) MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
trancexx Posted June 5, 2009 Share Posted June 5, 2009 $s1 = dllstructcreate("int") $s2 = dllstructcreate("ubyte[4]",dllstructgetptr($s1)) Dllstructsetdata($s1,1,260) ConsoleWrite(dllstructgetdata($s2,1,1) & @CRLF) ConsoleWrite(dllstructgetdata($s2,1,2) & @CRLF) ConsoleWrite(dllstructgetdata($s2,1,3) & @CRLF) ConsoleWrite(dllstructgetdata($s2,1,4) & @CRLF)You're fast ♡♡♡ . eMyvnE 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