Jump to content

Search the Community

Showing results for tags 'hex'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office


  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start



Member Title




Found 17 results

  1. Hi AutoIt programmers, excuse me for bothering you with multiple topics. In AutoIt we can use Number() function to convert Hex string to number but it's output is different of C# output & and i wanna make it's output like AutoIt code. For e.g I use this in AutoIt: Local $dBinary = Binary("Hello") ; Create binary data from a string. Local $dExtract = Number(BinaryMid($dBinary, 1, 5)) ConsoleWrite($dExtract & @CRLF) And i use this for C#: using System; using System.Text; //NameSpace Is Use of Project Name namespace TEST { class Program { public static void Main(string[] args) { //declaring a variable and assigning hex value string dd = ToHex("Hello", Encoding.ASCII); decimal d = Int64.Parse(dd, System.Globalization.NumberStyles.HexNumber); Console.WriteLine("Result: " + d); //hit ENTER to exit Console.ReadLine(); } public static string ToHex(string sInput, Encoding oEncoding, bool b0x_Prefix = false) { byte[] a_binaryOutput = oEncoding.GetBytes(sInput); string sOutput = BitConverter.ToString(a_binaryOutput).Replace("-", ""); if (b0x_Prefix == false) { return sOutput; } else { return "0x" + sOutput; } } } } I say once again that excuse me for creating new topic, in fact i'm making a library for GAuthOTP from a topic in AutoIt.
  2. For some reason, I can't convert to Hex a Decimal color that has been calculated. For example, this works: Local $iColor = 3310546 ConsoleWrite("$iColor (dec): " & $iColor & ", $iColor (hex): " & Hex($iColor, 6) & @CRLF) giving the expected output: $iColor (dec): 3310546, $iColor (hex): 3283D2 But if I want to take an average of several colors, I have a problem. For example this doesn't work: $iColor = (3310546 + 3310546) / 2 ConsoleWrite("$iColor (dec): " & $iColor & ", $iColor (hex): " & Hex($iColor, 6) & @CRLF) giving the wrong output: $iColor (dec): 3310546, $iColor (hex): 000000 I observe this behavior after any processing of a decimal color. Is this a bug?
  3. Hey, all. I've been looking for a way to change cursor colour but not the cursor itself. I've been looking for a couple hours now and can't find anything. I also don't even know where to start, if anyone has any tips or examples please comment them. Thanks
  4. Hi lads, I'm trying to figure out a method to translate one or multiple USHORT values into one large bitfield and i am slowly getting a headache figuring out an effective way to perform this. In general The bitfield tells my routine which columns entities are *not* present in a record in the database structure i am reading (The so-called NULL values). This also means that the byte-block beloging to that field, is not present within that file. This is a very simple form of low-level database compression technique. I have several different database files, and they contain different amounts of columns with various mixed data-type forms. The logic of the bit-range is that for each group of columns, one bitfield is stuffed into a USHORT, once the boundaries of the lower logic are reached, the bitfield continues in a next set of a USHORT value. The USHORT blocks are stored in low to high order order inside the file and have to be swapped to get the correct binary representation. Below snippet displays the details of the structure, starting with the (in this case) three USHORT bitfields. The next range of figures is the binary representation of these bitfields *when* shifted (i have done this all manually) and combined in the proper order. Some of the bitranges are between parentheses: when a column represents a char range, the database structure has two types of bit definitions:odd (01) for numeric fields and even (10) for char fields. bit1 bit2 bit3 bit-range representation of bitfields 3-1 Col-Title column-type 0100 0000 0000 00000000000000000000000000000000000000000001 Column1 (DWORD) 0800 0000 0000 (00000000000000000000000000000000000000001000)Column2 (CHAR) 2000 0000 0000 (00000000000000000000000000000000000000100000)Column3 (CHAR) 8000 0000 0000 (00000000000000000000000000000000000010000000)Column4 (CHAR) 0002 0000 0000 (00000000000000000000000000000000001000000000)Column5 (CHAR) 0004 0000 0000 00000000000000000000000000000000010000000000 Column6 (DWORD) 0010 0000 0000 00000000000000000000000000000001000000000000 Column7 (DWORD) 0040 0000 0000 00000000000000000000000000000100000000000000 Column8 (DWORD) 0000 0100 0000 00000000000000000000000000010000000000000000 Column9 (DWORD) 0000 0400 0000 00000000000000000000000001000000000000000000 Columna (DWORD) 0000 1000 0000 00000000000000000000000100000000000000000000 Columnb (BOOLEAN) 0000 4000 0000 00000000000000000000010000000000000000000000 Columnc (BOOLEAN) 0000 0001 0000 00000000000000000001000000000000000000000000 Columnd (BOOLEAN) 0000 0004 0000 00000000000000000100000000000000000000000000 Columne (BOOLEAN) 0000 0010 0000 00000000000000010000000000000000000000000000 Columnf (BOOLEAN) 0000 0040 0000 00000000000001000000000000000000000000000000 Column10 (DWORD) 0000 0000 0100 00000000000100000000000000000000000000000000 Column11 (DWORD) 0000 0000 0800 (00000000100000000000000000000000000000000000)Column12 (CHAR) 0000 0000 1000 00000001000000000000000000000000000000000000 Column13 (DWORD) 0000 0000 8000 (00001000000000000000000000000000000000000000)Column14 (CHAR) 0000 0000 0002 00100000000000000000000000000000000000000000 Column15 (CHAR) Each database does have a fixed column definition setting, but the order and field-types (char/numeric) within that table can vary per database file. So figuring out which field is or isnĀ“t present without necessarily knowing it is a char/type or numeric i am using a BitAND() construction with bit pairs of "11" which are in the order of 0x03, 0x0c, 0x30, 0xc0, 0x300, 0xc00, etc. Regardless of the field type, i would get in that case always a difference if this field is marked as "nul" My issue I do know my way around reading 16-bit binaries and getting past the "no-consecutive 32-bit datablocks" issue when using WINAPI_ReadFile() but regarding how to transform multiple USHORT values into one large bitfield using bitshifting methods: I could use some crash course here since depending on the column number i have to construct either a USHORT, ULONG or even a 64/bit hex value... I know WINAPI_ReadFile() performs the endian correction for the USHORT value, but when i have multiple of these pairs, i need to perform some multiplications (with risk of crashing the program by exceeding a variable's type value limitation) to add these numbers up and i have the feeling that using bitshifting, works faster and more effective but.... What is the most effective way to combine these USHORT values into one ULONG/SYSTEMLong value?
  5. I need help to read one file in a HEX mode and go to one offset and than read the value. THX
  6. Hi all: I nedd to convert a word hex number to an integer 16 Ex: 0xFFE9 convert to -23 I would appreciate if they had any idea how I can get it
  7. I was just working on a project that involved decoding a stream of binary data from a serial port in AutoIt. It took me a few hours to figure out how to process the data efficiently in AutoIt and I did not find any helpful examples on how to do so, so I thought I would share my core example and maybe save someone else some time. There may be a more efficient way to do this, but this works well for me. #cs Author: ToasterKing This is an example of a way to parse streaming binary data that follows a strict format with a header and footer. In this example, each frame is 5 bytes with a 2-byte header of 0xD5AA and a 1-byte footer of 0xAD. The _BinaryParse() function accumulates incoming data in a buffer. Once a footer is found, it searches backward for the header, and if it is in the right position, it extracts the remaining 2 bytes in the middle, then moves on to looking for the next frame. #ce ; The data source might be something asynchronous like serial or TCP, but since this is just an example, I'm just putting the data in a variable. Local $fSomeData $fSomeData = Binary("0xD5AA24B1") ; Binary data constituting almost a complete frame. _BinaryParse($fSomeData) ; Call the function with the received data. It isn't a complete frame, so it is just stored in the buffer until more data is received. $fSomeData = Binary("0xAD62D5AA92E7AD") ; Remainder of the previous frame, one garbage byte (0x62) which should be skipped, and a complete additional frame. _BinaryParse($fSomeData) ; The function should be able to parse both frames now. Func _BinaryParse($fNewData) Local Static $fBinaryReceived = Binary("") ; Buffer for received data ConsoleWrite("Hey, the function is called!" & @CRLF) ; Add new data to the buffer. ; This ridiculous monstrosity is the only way I could find to append binary data to binary data in AutoIt. It must be converted to strings first. ; Both, one, or no substrings will begin with "0x" depending on whether they contained binary data. To be converted back to binary properly, only one instance ; of "0x" must exist at the beginning of the string. $fBinaryReceived = Binary("0x" & StringReplace(String($fBinaryReceived) & String($fNewData),"0x","")) ConsoleWrite("Data in the buffer: " & String($fBinaryReceived) & @CRLF) Local $iLength = BinaryLen($fBinaryReceived) ; Count the bytes in the data If $iLength > 0 Then Local $fBinaryReceivedTemp = $fBinaryReceived ; Create temporary copy to work on Local $fByte1,$fByte2 For $i = 1 To $iLength If BinaryMid($fBinaryReceivedTemp,$i,1) = 0xAD Then ; If the 1-byte footer found ConsoleWrite("Footer found at end of " & $i & " of " & $iLength & " bytes!" & @CRLF) If BinaryMid($fBinaryReceivedTemp,$i - 4,1) = 0xD5 And BinaryMid($fBinaryReceivedTemp,$i - 3,1) = 0xAA Then ; and the 2-byte header is found 4 bytes before that ConsoleWrite("Header found before the footer!" & @CRLF) $fByte1 = BinaryMid($fBinaryReceivedTemp,$i - 2,1) ; Get 1st byte in the body (between header and footer) $fByte2 = BinaryMid($fBinaryReceivedTemp,$i - 1,1) ; Get 2nd byte in the body (between header and footer) ConsoleWrite("Here is the critical data: " & String($fByte1) & " " & String($fByte2) & @CRLF) ; Just display the 2 bytes for demonstration purposes. Normally, you'd do something more useful with it here. EndIf $fBinaryReceived = BinaryMid($fBinaryReceivedTemp,$i + 1) ; Truncate the original data to remove all of the bytes just processed, then continue processing $fBinaryReceivedTemp EndIf Next EndIf EndFunc
  8. Hello Guys! I want to convert the binary hash returned by _Crypt_Hash* function to string. Thanks in Advance! TD
  9. i have an external hex editor in which i can edit something in the hex of a file. is it possible do edit the hex of a file with autoit? if this is possible how this can be done? Thanks in advance.
  10. I want to replace this value with autoit, usually I do that with HxD editor and replace selection utility. I'm able to find the exact value but I do not understand how to replace it, can someone explain me how to do it? Thx. My code #include <String.au3> #include <Array.au3> $file = "myfile" $read = FileRead($file) $filhex = _StringToHex($read) $split = StringRegExp($filhex, "(?s).{1,2}", 3) $kb = 0 $sp = "" $val = "" $row = 0 For $i = 0 To UBound($split) - 1 $kb += 1 If $kb < 16 Then $sp = " " $val &= $split[$i] & $sp ElseIf $kb = 16 Then $sp = @CRLF $val &= $split[$i] & $sp $kb = 0 $row += 1 EndIf Next ConsoleWrite($split[53]&@LF)
  11. Hey, Just needed for some projects a side by side control, on the left the binary data on the rigth the string. Nothing more to say here, take a look for yourself. HexControl UDF is licensed under a Creative Commons Attribution 4.0 International License. http://creativecommons.org/licenses/by/4.0/ Greetz, Spider Hex Control.zip
  12. I'm using InetRead to access a machine's ID on the amazon ec2 service. to access the string containing the machine's ID I'm using the line: $instanceID = InetRead("",4) ConsoleWrite($instanceID) ConsoleWrite(@CRLF) $instanceID = StringLeft($instanceID,10) ; use the first ten characters ConsoleWrite($instanceID) ConsoleWrite(@CRLF) I think the "4" option in the InetRead function call should force ASCII format, but it must be struggling. The first ConsoleWrite returns: i-aa0fa69e (which is the properly formatted machine ID) and the second ConsoleWrite returns: 0x692D6161 which appears to be the hex equivalent of the original string. Does any body know how I can force the $instanceID variable to be an ASCII string? This one is really confusing me
  13. wanted to know if theres a way to create a blank image of specific color code using au3 only, for example, wanted to make blank jpg pic of hex code 004488 using au3 only, how can it be done? and second question is, how to place a transparent png over another picture and save it as jpg (or any other format)? + = 3rd, how to convert png to jpg? Regards, Akshay
  14. Hi everyone I have 2 basic question about hex editing - I have several texts with a common problem, in stead of having CRLF (carriage return+line feed) only had 0x0A (LF), how do I add 0D behind every 0x0A? - Its possible to edit only the beginning of a file (speaking in large files that should't be loaded in memory) and save the changes?
  15. Hello Everybody, This is my first official post even though I have been scouring the forums for a couple weeks now. I am a new program Hobbyist...just began learning Autoit/any language no earlier than the beginning of June. I am currently trying to figure out how to use the find Color under mouse and apply it from a pop up screen to a main GUI. I did find the main part of this code on one of these pages but I can't find where I originally started from...So thank you to whomever that was! Issues I am facing: When it does work it only works onceCan't seem to get the value of the Hex properly (tried different variations and my brain hurts now)The main GUI doesn't refresh properly#include <WindowsConstants.au3> #include <StaticConstants.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> Global $pos = MouseGetPos() Global $pixel_hex = Hex(PixelGetColor($pos[0],$pos[1]), 6) Global $pixel_last Global $Popcolor, $ColorUpdate, $lblF8, $lblF9, $lblF10, $lblF11, $HexTopFirst, $HexTopSecond, $HexTopThird, $HexTopFourth, _ $HexBotFirst, $HexBotSecond, $HexBotThird, $HexBotFourth, $lblName1, $lblName2, $lblName3, $lblName4, $FirstColor, _ $SecondColor, $ThirdColor, $FourthColor HotKeySet("{F8}","clip8") HotKeySet("{f9}","clip9") HotKeySet("{F10}","clip10") HotKeySet("{f11}","clip11") HotKeySet("{ESC}","endme") ;-----------------MAIN GUI--------------- $MainColor = GUICreate ("Main Color Find", 340,140) $ColorUpdate = GUICtrlCreateButton("Find Colors",110,105,120,25) ;........NAME Labels............ $lblMainName1= GUICtrlCreateLabel("One", 30, 68, 50, 13) $lblMainName2= GUICtrlCreateLabel("Two", 108, 68, 45, 13) $lblMainName3= GUICtrlCreateLabel("Three", 195, 68, 100, 13) $lblMainName4= GUICtrlCreateLabel("Four", 280, 68, 30, 13) ;........Graphics........ $FirstMain = GUICtrlCreateGraphic(35, 48, 18, 18, BitOR($GUI_SS_DEFAULT_GRAPHIC,$SS_BLACKFRAME,$SS_SUNKEN)) $SecondMain = GUICtrlCreateGraphic(112, 48, 18, 18, BitOR($GUI_SS_DEFAULT_GRAPHIC,$SS_BLACKFRAME,$SS_SUNKEN)) $ThirdMain = GUICtrlCreateGraphic(200, 48, 18, 18, BitOR($GUI_SS_DEFAULT_GRAPHIC,$SS_BLACKFRAME,$SS_SUNKEN)) $FourthMain = GUICtrlCreateGraphic(282, 48, 18, 18, BitOR($GUI_SS_DEFAULT_GRAPHIC,$SS_BLACKFRAME,$SS_SUNKEN)) GUISetState(@SW_SHOW) ;----------Main Loop--------------------- While 1 $nMsg = GUIGetMsg(1) Switch $nMsg[1] Case $MainColor Switch $nMsg[0] Case $GUI_EVENT_CLOSE Exit Case $ColorUpdate PopColor() EndSwitch Case $PopColor Sleep(100) Call("grab") Switch $nMsg[0] Case $GUI_EVENT_CLOSE GUIDelete($PopColor) Sleep(10) GUICtrlSetState($ColorUpdate, $GUI_Enable) Case $ColorUpdate GUICtrlSetBkColor($FirstMain,$FirstColor) GUICtrlSetBKColor($SecondMain,$SecondColor) GUICtrlSetBKColor($ThirdMain,$ThirdColor) GUISetBkColor($FourthMain,$FourthColor) EndSwitch EndSwitch WEnd Func PopColor() $PopColor = GUICreate("Color Find Pop", 340,140) $ColorUpdate = GUICtrlCreateButton("Update Main",110,105,120,25) ;........F9 - F12 Labels....... $lblF8= GUICtrlCreateLabel("F8", 35, 7, 30, 20) $lblF9= GUICtrlCreateLabel("F9", 112, 7, 45, 20) $lblF10 = GUICtrlCreateLabel("F10", 200, 7, 50, 20) $lblF11 = GUICtrlCreateLabel("F11", 282, 7, 42, 20) ;........Top HEX Labels....... $HexTopFirst= GUICtrlCreateLabel("", 22, 32, 60, 13) $HexTopSecond= GUICtrlCreateLabel("", 102, 32, 60, 13) $HexTopThird = GUICtrlCreateLabel("", 188, 32, 60, 13) $HexTopFourth = GUICtrlCreateLabel("", 271, 32, 60, 13) ;........BOTTOM HEX Labels....... $HexBotFirst= GUICtrlCreateLabel("", 22, 85, 60, 13) $HexBoTSecond= GUICtrlCreateLabel("", 102, 85, 60, 13) $HexBoTThird = GUICtrlCreateLabel("", 188, 85, 60, 13) $HexBoTFourth = GUICtrlCreateLabel("", 271, 85, 60, 13) ;........NAME Labels............ $lblName1= GUICtrlCreateLabel("One", 30, 68, 50, 13) $lblName2= GUICtrlCreateLabel("Two", 108, 68, 45, 13) $lblName3= GUICtrlCreateLabel("Three", 195, 68, 100, 13) $lblName4= GUICtrlCreateLabel("Four", 280, 68, 30, 13) ;........Graphics........ $FirstColor = GUICtrlCreateGraphic(35, 48, 18, 18, BitOR($GUI_SS_DEFAULT_GRAPHIC,$SS_BLACKFRAME,$SS_SUNKEN)) $SecondColor = GUICtrlCreateGraphic(112, 48, 18, 18, BitOR($GUI_SS_DEFAULT_GRAPHIC,$SS_BLACKFRAME,$SS_SUNKEN)) $ThirdColor = GUICtrlCreateGraphic(200, 48, 18, 18, BitOR($GUI_SS_DEFAULT_GRAPHIC,$SS_BLACKFRAME,$SS_SUNKEN)) $FourthColor = GUICtrlCreateGraphic(282, 48, 18, 18, BitOR($GUI_SS_DEFAULT_GRAPHIC,$SS_BLACKFRAME,$SS_SUNKEN)) GUISetState(@SW_Show) EndFunc func grab() $pos = MouseGetPos() $pixel_hex = Hex(PixelGetColor($pos[0],$pos[1]), 6) If $pixel_last <> $pixel_hex Then GUICtrlSetData($HexTopFirst, $pixel_hex) GUICtrlSetData($HexTopSecond, $pixel_hex) GUICtrlSetData($HexTopThird, $pixel_hex) GUICtrlSetData($HexTopFourth, $pixel_hex) EndIf $pixel_last = $pixel_hex EndFunc Func clip8() Local $color = "0x" & $pixel_last GUICtrlSetBkColor($FirstColor, $color) GUICtrlSetColor($HexBotFirst,"0x"&$Pixel_Last) GUICtrlSetData($HexBotFirst, $Pixel_Last) EndFunc Func clip9() Local $color = "0x" & $pixel_last GUICtrlSetBkColor($SecondColor, $color) GUICtrlSetColor($HexBotSecond,"0x"&$Pixel_Last) GUICtrlSetData($HexBotSecond, $Pixel_Last) EndFunc Func clip10() Local $color = "0x" & $pixel_last GUICtrlSetBkColor($ThirdColor, $color) GUICtrlSetColor($HexBotThird,"0x"&$Pixel_Last) GUICtrlSetData($HexBotThird, $Pixel_Last) EndFunc Func clip11() Local $color = "0x" & $pixel_last GUICtrlSetBkColor($FourthColor, $color) GUICtrlSetColor($HexBotFourth,"0x"&$Pixel_Last) GUICtrlSetData($HexBotFourth, $Pixel_Last) EndFunc Func endme() Exit EndFunc Questions: Can my purpose be served better by applying read and write ini file? Would it be possible to have the main GUI already have a saved HEX color if using ini that can be overwritting from pop up menu?Would OnEvent be better?Any help would be appreciated...been stressing out over this coding for the last few days!
  16. I would like to programmatically check to see if a given tracker has information on the torrent I specify. This requires that the SHA-1 Info Hash of a torrent be encoded to make valid requests. I read from: http://nakkaya.com/2009/12/03/bittorrent-tracker-protocol/ If you don't pay attention to the spec and send this directly to tracker you will get an error this should be in URL Encoded form. Padding every two chars with % sign also doesn't work, been there done that don't waste your time. Any hex in the hash that corresponds to a unreserved character should be replaced, a-z A-Z 0-9 -_.~ Partition the hex in to chunks of two and check if the hex corresponds to any of these values, if they do replace them with the unreserved char. So that a hash such as, 123456789abcdef123456789abcdef123456789a becomes, %124Vx%9a%bc%de%f1%23Eg%89%ab%cd%ef%124Vx%9a notice that hex 34 became 4 which is what it is in ASCII. You can test the correctness of your hashes using the tracker url but don't request from announce request from file, http://some.tracker.com/file?info_hash=hash If you get a torrent back that means you have the correct hash. I have tried the above and failed. Here's my code: $testStr = "123456789abcdef123456789abcdef123456789a" ConsoleWrite(_EncodeHash($testStr) & @CRLF) Func _EncodeHash($sString) If (Not IsString($sString)) Or $sString = "" Then Return SetError(1, 0, 0) Local $aArray = StringRegExp($sString, "(?s).{1," & 2 & "}", 3), $sEncodedHash For $i = 0 To UBound($aArray) -1 If StringInStr($sString, Chr(Dec($aArray[$i]))) Then $sEncodedHash &= Chr(Dec($aArray[$i])) Else $sEncodedHash &= "%" & $aArray[$i] EndIf Next Return $sEncodedHash EndFuncIf you follow the first link in my post there is an example but I'm unfamiliar with the language being used. Thanks for any help.
  17. I ran into a strange issue today while updating one of my scripts. When I tried to do some simple division on a variable and then convert it to hex, I do not get the expected value returned. An example: $Size = 128*2 ConsoleWrite('128*2 = '&$Size&@CRLF) ConsoleWrite('Hex() returns: '&hex($Size)&@CRLF) $Size = 256 ConsoleWrite('256 = '&$Size&@CRLF) ConsoleWrite('Hex() returns: '&hex($Size)&@CRLF) $Size = 512/2 ConsoleWrite('512/2 = '&$Size&@CRLF) ConsoleWrite('Hex() returns: '&hex($Size)&@CRLF) Returns 128*2 = 256 Hex() returns: 00000100 256 = 256 Hex() returns: 00000100 512/2 = 256 Hex() returns: 4070000000000000 I am running version: While I can work around this issue in the script, I would like to understand better what is going on. Thank you, Kerros
  • Create New...