Jump to content

How to BitConverter in autoit


HMJ7
 Share

Recommended Posts

Hello guys.

I'm new to AutoIt world. I'm trying to convert my c# code to auto it. 

How can I do it in AutoIt I didn't see any function similar to 'BitConverter'

 

            byte[] data = new byte[10];
            byte[] fourBytes = BitConverter.GetBytes(data.Length);
            Console.WriteLine(fourBytes.Length); // 4

            int getLength = BitConverter.ToInt32(fourBytes, 0);
            Console.WriteLine(getLength); // 10

 

 

Link to comment
Share on other sites

Hex is quite close, you just need to convert it to array after, if needed...

#include <Constants.au3>

MsgBox ($MB_SYSTEMMODAL,"Bool",Hex(True,2))
MsgBox ($MB_SYSTEMMODAL,"Char",Hex(AscW("*"),4))
MsgBox ($MB_SYSTEMMODAL,"Word",Hex (11111,4))
MsgBox ($MB_SYSTEMMODAL,"Int",Hex (1111111111))
MsgBox ($MB_SYSTEMMODAL,"Long",Hex(1111111111111111111))
MsgBox ($MB_SYSTEMMODAL,"Float",Hex(0.111111111111111))

 

Link to comment
Share on other sites

;create struct
$struct =dllstructcreate("int;float[4];dword")

;fill struct with data
dllstructsetdata($struct,1,123456);int
dllstructsetdata($struct,2,4.80114160043301e+030,1);float
dllstructsetdata($struct,2,3.68584191575527e+024,2);float
dllstructsetdata($struct,2,7.71403089381636e+031,3);float
dllstructsetdata($struct,2,8.24605444209785e-019,4);float
dllstructsetdata($struct,3,0xDEADBEEF);dword

;read some data from struct at offset 4
$struct2=dllstructcreate("char[16]",dllstructgetptr($struct)+4)
msgbox(0,":o)",dllstructgetdata($struct2,1))

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...