
sulfurious
Active Members-
Posts
257 -
Joined
-
Last visited
sulfurious's Achievements

Universalist (6/7)
0
Reputation
-
I tried it on a couple xpsp3 machines, it does the exact same thing. Run HT once, and it is fine. Otherwise, it does not get the data sent. Interestingly here is a post that describes what is happening, with a reply that just figures lol http://answers.microsoft.com/en-us/windows/forum/windows_7-hardware/initialize-serial-port/a9fa325b-fafc-44b1-b7c1-9501c1dca09b I've searched init/initializing com/serial ports, but found nothing. I have no idea what the issue might be really. Anyone?
- 116 replies
-
- COM portserial port
- RS-232
-
(and 4 more)
Tagged with:
-
I've got a question if someone might be able to help. I've built a small app to read an MSR for a cash register. It works with track2 of a gift card and the end result is to read the number, query a website and get a balance. Anyway, the MSR is an idtech idmb-3321 rs232 reader. It comes with a utility to modify settings within the MSR. The issue is that if I start the utility and connect to the MSR, my code gathers the output of a card swipe without issue. Depending on the settings of the MSR that might include STX/ETX or not, or whatever I want to format it as pre/post fix or terminations, etc. It works fine though, as long as I parse the text to my likings. However, if I don't start the config util, my app does not work. It is also interesting in that if I start hyperterminal, read the swipe, then shut hyperterminal down, my app will read it just fine. Its like there is a driver needed or a service, but I did not think rs232 needed a driver. This is on win7 ult x32, and the hyperterminal is missing from win7, so I used hyperterm .exe and .dll from winxp. I've looked at the idtech website, and they say there is no driver for rs232. Of course for usb2rs232 there are. I get no errors in the code. The handle is good. As a matter of fact, what is returned is DC3 (BE. After running hyperterm or the config utiity, it works perfectly. I tried raw mode in the MSR, but there is some decoding there that I don't understand, although the output is readable without running hyperterm or the config utility. The settings are: port 1 baud 9600 parity 0 stop bits 1 byte size 8 handshake XonXoff Any ideas?
- 116 replies
-
- COM portserial port
- RS-232
-
(and 4 more)
Tagged with:
-
ListView subitems edit in place (by double click)
sulfurious replied to rasim's topic in AutoIt Example Scripts
@M4n0x Nice little bit there. I was looking for such a feature yesterday and your posting brought this to my attention. Thanks. One thing, I like they way your method keeps the input box as a "cell" rather than a popup type overlay. And I like how the enter button commits the edits. However, I cannot seem to figure out how to convert it to use OnEvent. Things get wonky with the hotkey and enter, but works fine without that. Actually if you just convert it all to OnEvent, the end_editLV runs twice and the second time through clears the value out. Any ideas? -
Ah. That solves that then. My initial reason was to modify files that are created with another app I made, but is not text. The makeup of the files created have a certain structure to them so I could modify them rather than load them (and decide what would need changed) and recreate them (overwrite). Its not a big deal either way as what I have works, but it would be a good exercise to navigate to a specific offset, read a certain portion of the file, then use that data and perhaps modify it. Learning for the sake of curiosity I guess I was uncertain of the differences involved as I usually manipulate text files. I will work up a small sample and see if I have any issues. If it does what I need, then I have to decide if I want to pursue it to the point of modifying the file rather than recreating it, as opposed to just learning how to read a portion of it. Thanks for the info.
-
I'm at work now so I cannot look into any of these examples yet (thanks for the replies btw). The first question that comes to mind though after a quick look at this is, in order to use filesetpos and related functions, the file has to be opened first. What exactly happens when you use FileOpen (with any of the parameters), does the entire file get loaded into memory and then the handle is used to point subsequent functions like FileRead to the memory location? So SetFilePos would be used to point FileRead to a memory address? I ask because I was wanting to learn if its possible, and how to, not have to load an entire file into memory, but be able to read only a certain portion. Maybe it isn't possible, but that is why I am here. I will look at the rest of this tonight after work. Much of what I ask could be answered by just building a script and experimenting, but it never hurts to have others input either. Thanks again for the replies thus far.
-
Oh, maybe I should ask, as I assumed here. When you use a file open with a count parameter, does it only read that portion in the parameter into memory? I was under the impression it was this way, but perhaps not. Help file says the count, when read as binary (byte) will do this. So maybe that is all I need. Can anyone tell me, when I look at a file with a hex editor, each character, whether ascii or binary, is this a byte? For example, when you are seeing an ansi file in hex, you see 0D 00 0A 00. If it is unicode you have an extended set, so you might see 0A BC 10 DA. Is each of these hex values (which in text would represent a character) a byte? So there are 16 bytes per "row" in the hex editor? Not remembering all that like I used to. And to think I used to do a lot of conversion of registry values with autoit for every type. Must have been a long time ago now lol.
-
Thank you for the reply. That link you gave led me to being able to use ceiling and 16 to find the rows. Thats a good start. The use of FileSetPos as you indicate is a good method to start reading at a point, and by keeping track of what your point is, you can always read it from a new point (of course). However, I don't see how to limit what is read to only say 16 characters for example. And, unless I am mistaken, the FileRead function will open the entire contents of the file. Useful for most file that are small, but not for large files. So that helps, but the tricky part is how to find the total offset addresses (or whatever that would be called) in the file (as you have provided a good start for), then read only from offset 1 to offset F, do something in the script, then read from offset 10 to 1F, and so on, only ever actually "opening" a chunk of the file. Now maybe this is not possible, but I was looking at some C code and while I don't implicitly understand it, it seems it can be done. Of course since I don't know the terms exactly it makes it hard for me to communicate what I need or want. Any other suggestions?
-
Hello. Please do forgive my terminology, been awhile since I coded much and age has fogged things up lol. I've used search a good deal, but haven't found a good thread yet to help me. The goal is pretty simple I would think though, although I am not sure how to begin. What I want to do is take any file and open it raw, like how you would see the data if you opened it in a hex editor (although I only want to "read" a chunk of the file). Next, I would like to parse or step through a certain number of bits or bytes, or characters, however you want to look at it, and do something with these chunks of data. For example, in a hex editor you would start at offset 00 and end at offset 0F. The next "line" (although its not really a line) starts at off at 10 and ends at offset 1F, and so on until the end of the file. In the past I have opened text files raw, and stepped through them looking for characters like 0D 0A and then converting to and from different types. But what I am wanting to learn how to do is read a segment or chunk of a given file, store it or whatever, then continue from the next offset to another given offset, read that, do something with it, and keep going until the end of the file. Now I understand that I could use a file open and read binary or raw, but I anticipate that I might want to open a large file, lets say 200mb, and I don't want to actually open the whole thing into memory, but instead would want to read a portion, then another portion, so on and so on. What I am having a hard time understanding is just how I could do this. I assume I would need to find the last addressable offset somehow, then open the first chunk, record my position, then read the next chunk. I have thought about doing this many times in the past, and finally found a little extra time to learning something new. I don't expect any code to be handed to me. I know full well I need to do the work. But is there anybody who might want to either give me some good pointers on how to start understanding this, or does understand it (and what I am asking lol) and could explain a few things to me. I am confident that I can do this, but don't really understand what to look for in way of help. It may just be getting the terminology correct, as I've forgotten much from not using what I knew Thanks to any takers.
-
Hello. I have been attempting to get the integrity level of a process using OpenProcessToken and GetTokenInformation. Here is what I have been messing with thus far. #include <Security.au3> #include <Constants.au3> #include <securityconstants.au3> #Include <WinAPI.au3> #include <array.au3> Global Const $STANDARD_RIGHTS_REQUIRED = 0x000F0000 Global Const $TOKEN_ALL_ACCESS_P = BitOR($STANDARD_RIGHTS_REQUIRED, $TOKEN_ASSIGN_PRIMARY, $TOKEN_DUPLICATE, $TOKEN_IMPERSONATE, $TOKEN_QUERY, $TOKEN_QUERY_SOURCE, $TOKEN_ADJUST_PRIVILEGES, $TOKEN_ADJUST_GROUPS, $TOKEN_ADJUST_DEFAULT) Global Const $TOKEN_ALL_ACCESS = BitOR($TOKEN_ALL_ACCESS_P, $TOKEN_ADJUST_SESSIONID) $TOKEN_READ = 0x00020000+0x0008 ; STANDARD_RIGHTS_READ+TOKEN_QUERY $ProcessID = ProcessExists("calc.exe") ;. choose a process that is running $ProcessHandle = _WinAPI_OpenProcess($PROCESS_QUERY_INFORMATION, False, $ProcessID) ;. get handle to process ConsoleWrite($ProcessHandle & ' process handle' & @CRLF) $ProcessToken = _Security__OpenProcessToken($ProcessHandle, $TOKEN_ALL_ACCESS) ;. get token handle using correct access mask ;~ $ProcessToken = _Security__OpenProcessToken($ProcessHandle, $TOKEN_READ) ConsoleWrite($ProcessToken & ' process token' & @CRLF) $ProcessInfo = _Security__GetTokenInformationX($ProcessToken, $TOKENINTEGRITYLEVEL) ;. get information using correct class ConsoleWrite($ProcessInfo & ' process info' & @CRLF) _ArrayDisplay($ProcessInfo,'ProcessInfo array') If $ProcessToken Then _WinAPI_CloseHandle($ProcessToken) If $ProcessHandle Then _WinAPI_CloseHandle($ProcessHandle) ; #FUNCTION# ==================================================================================================================== ; Name...........: _Security__GetTokenInformation ; Description ...: Retrieves a specified type of information about an access token ; Syntax.........: _Security__GetTokenInformation($hToken, $iClass) ; Parameters ....: $hToken - A handle to an access token from which information is retrieved. If $iClass specifies ; +$sTokenSource, the handle must have $TOKEN_QUERY_SOURCE access. For all other $iClass values, the handle must ; +have $TOKEN_QUERY access. ; $iClass - Specifies a value to identify the type of information the function retrieves ; Return values .: Success - A byte structure filled with the requested information ; Failure - 0 ; Author ........: Paul Campbell (PaulIA) ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........: @@MsdnLink@@ GetTokenInformation ; Example .......: ; =============================================================================================================================== Func _Security__GetTokenInformationX($hToken, $iClass) Local $aResult = DllCall("advapi32.dll", "bool", "GetTokenInformation", "handle", $hToken, "int", $iClass, "ptr", 0, "dword", 0, "dword*", 0) If @error Then Return SetError(@error, @extended, 0) _ArrayDisplay($aResult,'GetTokenInformation pass 1') If Not $aResult[0] Then Return 0 Local $tBuffer = DllStructCreate("byte[" & $aResult[5] & "]") Local $pBuffer = DllStructGetPtr($tBuffer) $aResult = DllCall("advapi32.dll", "bool", "GetTokenInformation", "handle", $hToken, "int", $iClass, "ptr", $pBuffer, _ "dword", $aResult[5], "dword*", 0) If @error Then Return SetError(@error, @extended, 0) _ArrayDisplay($aResult,'GetTokenInformation pass 2') If Not $aResult[0] Then Return 0 Return $tBuffer EndFunc ;==>_Security__GetTokenInformation You can see I copied _Security_GetTokenInformation() and renamed it and placed it in this script so I could put an _arraydisplay() function in to see the returns. From what I gather (which is limited), when you you call OpenProcessToken, you must have the right access mask. You can see in my script that I am using $TOKEN_ALL_ACCESS and $TOKEN_READ, from what I have read should give me access to the token information. And during GetTokenInformation, the TokenInformationClass that I should be using is TokenIntegrityLevel, as noted in this example http://msdn.microsoft.com/en-us/library/bb625966.aspx If I read correctly, $aResult[0] should contain a True value on success. I don't understand exactly what is wrong with this, but I believe it is due to the TokenInformationLength parameter of the call? I see in the C example that this is the spot perhaps I a missing out on? pTIL = (PTOKEN_MANDATORY_LABEL)LocalAlloc(0, dwLengthNeeded); further, I am unfamiliar with this conversion as well dwIntegrityLevel = *GetSidSubAuthority(pTIL->Label.Sid, (DWORD)(UCHAR)(*GetSidSubAuthorityCount(pTIL->Label.Sid)-1)); I am wondering if there is anyone who can teach me what I am missing here. Sul.
-
SetWindowsHookEx vs _IsPressed
sulfurious replied to sulfurious's topic in AutoIt General Help and Support
Good thinking. I did something close to that. There are 4 parameters that a user would likely change: speed, acceleration, smoothing maximum and sensitivity. Changing them on-the-fly is very convenient to be sure. I allowed a combo box for each value to gather the rate of change, such as .01, .10, .50, etc. A simple button for each parameter allows a reset, increase or decrease by the rate of change. I used progress bars for each parameter. In this fashion I set a max/min and then show the progress bar and a numeric value on a change, either from button or scroll. I used to use the original SideWinder, and also have the newer wireless one. They are nice. My goal here is to be able to not have the software needed to control the DPI/speed. It is interesting that when you have a mouse with 3 stock dpi, and you set the speed of the driver, the dpi buttons still toggle the 3 dpi, but you can control the speed. So a DPI of say 2000 offers more "resolution", but now with this driver, across all programs, the speed remains constant according to the driver. It is also interesting that if you start a game, in some you set the mouse speed to 0 as the driver is low level even before direct input, so it provides a very nice feeling. I also implemented separate X and Y for times when I need it. Thanks for the reply. Sul. -
SetWindowsHookEx vs _IsPressed
sulfurious replied to sulfurious's topic in AutoIt General Help and Support
I think I figured this out. I used SetWindowsHookEx and used a boolean. The boolean gets set on $WM_KEYDOWN if the vkCode is one of my targets. Then, when $WM_KEYUP is checked, if the boolean is true, it processes to see if the vkCode is one of my targets and if so, it sets to boolean to false. This seems to keep the cpu cycles down much better than using _IsPressed(). I just had to find if $WM_KEYUP was already declared in an include (which it was), as I didn't see it in the example but MSDN referenced it. If anyone would be willing I would like to PM the code segment to see if there is a way to maximize efficiency, as I know it is likely to have performance issues especially while doing things like gaming where keys are constantly held down. Sul. -
Here is a question for people who know more than I do about this. I have a mouse driver that allows settings such as speed and acceleration to be changed via registry setting. The driver discovers the changes very quickly, so when you modify the reg value, it is prety much instant. Playing with RegWrite() shows that a script can easily write/read the values with good speed. This left me with the problem of changing the setting in a more convenient way that most drivers do. Many mice today have DPI buttons, which is nice, but when using something where you want high precision, it is nice to have a low speed and moderate acceleration, yet also be able to change this on-the-fly. So, I create a small GUI which shows the current value, and obviously lets you change it via buttons. No problem. But, I wanted to make it more efficient, so I made it monitor a keypress using _IsPressed() in a While/EndWhile loop. I used the MouseSetOnEvent UDF to set a scroll up event raise the value by X power, and the scroll down even lower the value by X power. Later, I started to mess with adding a callback using SetWindowsHookEx. I have made other scripts that use _IsPressed() in a While/EndWhile loop, but those were restricted to working only if a specific WinTitle was active. In this program I am working on, I want a LL hook to be gathered globally, so any program can be running and the callback will work. I ran into a problem though. It seems that if I use _IsPressed() in the While/EndWhile loop, things become a bit unresponsive. I assume it is because of the constant checking with _IsPressed(). Here is what the main loop looks like While 1 Sleep(100) If _IsPressed($hotkey_Speed) Then If $use_on_the_fly Then _MouseSetOnEvent($MOUSE_WHEELSCROLLUP_EVENT,'btnUpSpeedClick') _MouseSetOnEvent($MOUSE_WHEELSCROLLDOWN_EVENT, 'btnDownSpeedClick') While _IsPressed($hotkey_Speed) Sleep(10) WEnd _MouseSetOnEvent($MOUSE_WHEELSCROLLUP_EVENT) _MouseSetOnEvent($MOUSE_WHEELSCROLLDOWN_EVENT) ElseIf $use_configs Then _MouseSetOnEvent($MOUSE_WHEELSCROLLUP_EVENT,'ConfigUp') _MouseSetOnEvent($MOUSE_WHEELSCROLLDOWN_EVENT, 'ConfigDown') While _IsPressed($hotkey_Speed) Sleep(10) WEnd _MouseSetOnEvent($MOUSE_WHEELSCROLLUP_EVENT) _MouseSetOnEvent($MOUSE_WHEELSCROLLDOWN_EVENT) ElseIf $use_presets Then _MouseSetOnEvent($MOUSE_WHEELSCROLLUP_EVENT,'PresetUp') _MouseSetOnEvent($MOUSE_WHEELSCROLLDOWN_EVENT, 'PresetDown') While _IsPressed($hotkey_Speed) Sleep(10) WEnd _MouseSetOnEvent($MOUSE_WHEELSCROLLUP_EVENT) _MouseSetOnEvent($MOUSE_WHEELSCROLLDOWN_EVENT) EndIf ElseIf _IsPressed($hotkey_Accel) Then _MouseSetOnEvent($MOUSE_WHEELSCROLLUP_EVENT, "btnUpAccelClick") _MouseSetOnEvent($MOUSE_WHEELSCROLLDOWN_EVENT, "btnDownAccelClick") While _IsPressed($hotkey_Accel) Sleep(10) WEnd _MouseSetOnEvent($MOUSE_WHEELSCROLLUP_EVENT) _MouseSetOnEvent($MOUSE_WHEELSCROLLDOWN_EVENT) ElseIf _IsPressed($hotkey_Max) Then _MouseSetOnEvent($MOUSE_WHEELSCROLLUP_EVENT, "btnUpMaxClick") _MouseSetOnEvent($MOUSE_WHEELSCROLLDOWN_EVENT, "btnDownMaxClick") While _IsPressed($hotkey_Max) Sleep(10) WEnd _MouseSetOnEvent($MOUSE_WHEELSCROLLUP_EVENT) _MouseSetOnEvent($MOUSE_WHEELSCROLLDOWN_EVENT) ElseIf _IsPressed($hotkey_Sens) Then _MouseSetOnEvent($MOUSE_WHEELSCROLLUP_EVENT, "btnUpSensClick") _MouseSetOnEvent($MOUSE_WHEELSCROLLDOWN_EVENT, "btnDownSensClick") While _IsPressed($hotkey_Sens) Sleep(10) WEnd _MouseSetOnEvent($MOUSE_WHEELSCROLLUP_EVENT) _MouseSetOnEvent($MOUSE_WHEELSCROLLDOWN_EVENT) EndIf WEnd As you can see, every 100ms the script checks, and if it finds the key is pressed, and then "while" the key is pressed, the _MouseSetOnEvent() is called to one of the functions that modify the registry value. The While/EndWhile for sleeping 10ms is a dummy loop that simply ensures the mouse event is not removed until the button has been released. I notice though that if I start a game while this is running, that doing something like moving forward, where a button is constantly held down, causes a "lag" in mouse movement. Ceasing to press a button alleviates this issue. I know it is becuase of the 10ms pause, but I believe I must have a slight pause in there so the While _IsPressed() does not go off constnatly. Alternatively, I implemented SetWindowsHookEx and monitored for one of my keypresses that would engage the mouse. Unfortunately, it did not operate as I expected it would. Using the If $wParam = $WM_KEYDOWN allowed me to check a VKcode ok, but there was no down/up event, only down. So what happened was I could successfully trap the keypress like I wanted, and apply the _MouseSetOnEvent(), but before I physically release the key, the function returns and then repeats itself. I used the example from the help files for _WinAPI_SetWindowsHookEx, the only difference is what VKcode I was checking for. Can anyone give me some pointers on: 1. which implementation would be best suited for a low level keyboard hook 2. if my logic on implementing the _MouseSetOnEvent is proper, by implementing then releasing 3. if SetWindowsHookEx is better, how could I successfully trap and release on the physical press/release. I am happy to post more code if needed, I kept it short intially. Sul.
-
floating point conversions
sulfurious replied to sulfurious's topic in AutoIt General Help and Support
I apologize before-hand for improper references and terms. This is just a hobby for me, no formal schooling on the topics While I don't need to write the code now, as the API call works fine, I will share what I found for others who might be looking for floating point binary hexadecimal or properly Single precision floating-point format or just IEEE 754-1985 I found infos at the link you provided PsaltyDS and also here http://en.wikipedia.org/wiki/Single_precision_floating-point_format and a good read at these forums here Using the example from wikipedia, it breaks down like this for the beginner A single precision floating point uses 32 bits, broken down like into 3 parts: the sign, the exponent and the mantissa/significand The sign is the left most bit and is 1 bit long. A value of 0 indicates a positive and 1 indicates negative. The exponent is 8 bits long and is used strangely for someone who has never done this before. The mantissa/significand is 23 bits long and while strange, is pretty easy to get. The precision of the conversion is limited to these 23 bits. Lets take a number like wikipedia uses 12.375 First break the whole from the fraction 12 is the whole and .375 is the fraction The goal is to get a binary32 value from these and then convert that to hex. We first break 12 into binary. Remember binary is 4 bits with the values from left to right 8,4,2,1. Larger numbers require 8 bits with values from left to right 128,64,32,16 8,4,2,1 So 12 fits into the first 4 bits easily, using the 8 and 4 and ignoring the 2 and 1, like this 1100. For the fractal, you multiply by 2, until the result is even. If the result has a fractal, then you multiply that fractal by 2 until you either see a repeating pattern or you get a whole number result. Remember that this binary representation of the fraction part of the number is going into the mantissa/significan, so you only have 23 bits to work with. The fraction is .375 .375 x 2 = 0.750 There is no whole number, so the first piece of the binary conversion is 0 The result is not whole, but still a fraction, so we take the fraction and repeat. .750 x 2 = 1.50 There is a whole number in the return value, so the second piece of the binary conversion is 1 The result is still not whole, sw we take the fraction and repeat. It might be helpful to imagine that we take the whole number of the return value, whether a 0 or a 1, and remove it, placing it in the binary conversion, therefore we never carry over a whole to the repeated sequence. .50 x 2 = 1.00 Here we have another whole number, so the next piece of the binary conversion would be 1 Here we also see that we have finally produced a whole number with no fraction left over, so we end our conversion. It might be that the multiplication sequence starts to repeat itself into a pattern over and over. When we see this, we can simply fill that pattern out to 23 binary digits if we want to stop. So lets give 2 examples. The first example, as described above, is done. We end up with a 0, a 1 and a 1. This is binary, so it is 011. Since our .375 ended up with an even return, we only have to use 3 binary digits. But, suppose your fractal number was .3 .3 x 2 = .6 -> a binary 0 and repeat .6 x 2 = 1.2 -> a binary 1 and repeat .2 x 2 = .4 -> a binary 0 and repeat .4 x 2 = .8 -> a binary 0 and repeat .8 x 2 = 1.6 -> a binary 1 and repeat .6 x 2 = 1.2 -> a binary 1 and repeat .2 x 2 = .4 -> a binary 0 and repeat .4 x 2 = .8 -> a binary 0 and repeat .8 x 2 = 1.6 -> a binary 1 and repeat .6 x 2 = 1.2 -> a binary 1 and repeat You can see how the pattern is going to be never ending. Since we know the mantissa/significand only holds 23 binary digits, we can just fill it out with the patter, like this 01001100110011001100110 Back to our example using 12.375 then. Our first conversion resulted in 12 = 1100 and .375 = 011 we put them together keeping the decimal point like this 1100.011 Here is where it gets interesting. There is a piece of the binary32 data format called the exponent, it is 8 binary digits long. But now we use another exponent as well. You must remember to know which exponent you are referring to! The first thing that has to be done is to get our 1100.011 into I believe what is called a "biased" format. All you do is shift the decimal place to the left in our case until you have a 1 on the left of the decimal. Only a 1 may exist there. We must shift 3 places. 1100.011 = 1.100011 The number of places we shifted the decimal is now our "exponent". We are done with the mantissa/significand. For all purposes, we are going to forget the leading 1 and decimal, and only save what remains so 1.100011 is really going to be used as 100011 later. Next we need to take our "exponent" that represents how many places we moved our decimal, and build the "exponent" portion of the binary32 form. It is strange, but you essentially take the "decimal exponent" and add it to the value 127. So 127 + 3 = 130. Now you must create that value, 130, in an 8 bit binary format. Remember those 8 bits, from left to right, are 128 64 32 16 8 4 2 1 to make 130, it would be 1 0 0 0 0 0 1 0 or 10000010 finally, we must have a sign, which is the left most bit of the binary32 form. Since this is a positive value, the sign will be 0. To look at the whole binary32 form of the value 12.375 then, it looks like this 0-10000010-100011 Noting that the sign is positive, so the first binary digit is 0 Noting the exponent = 130 so it is 10000010 Noting the mantissa/significand we calculated as 1.100011, but we dismiss the decimal and the 1, so 100011 Bearing our end structure, without the hyphens to distinguish the 3 different components of the binary32 format 010000010100011 Now we can make a hexadecimal conversion. Split this form into 4's 0100 0001 0100 0110 You may notice that the end value 0110 I padded with a 0. Because a hex value will have 8 digits, you simply pad it with 0s, like this actaully. 0100 0001 0100 0110 0000 0000 0000 0000 and convert to hex ; DECIMAL 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ; HEX 0 1 2 3 4 5 6 7 8 9 A B C D E F 10 ; BINARY 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 10000 0100 0001 0100 0110 0000 0000 0000 0000 4 1 4 6 0 0 0 0 or 0x41460000 I needed a registry value in this format, rather than the usual Hex() return value. I don't plan on creating code for it since I don't want to reinvent the wheel and there is a nice function already available. But, I did want to learn why, and hopefully someone else one day will stumble upon this in a web search and can benefit from it. Sul. -
floating point conversions
sulfurious replied to sulfurious's topic in AutoIt General Help and Support
Or it seems you could also use this _WinAPI_FloatToInt($float) but wouldn't that be too easy lol? Sul. -
floating point conversions
sulfurious replied to sulfurious's topic in AutoIt General Help and Support
lol, did you know the answer? It took me some time, but after opening a dozen different web pages concerning floating point binary (signed 32) calculations, I finally got the point of how to convert to binary, find the exponent and mantissa, how they structure and shift it, which finally leads to being able to convert to hex the final binary notation. Quite complicated really Tommorrow I will create some code for it if I haven't forgot it, and post it back here for other inquisitive souls. BTW, that link you provided is a great one, but it took a lot of other "basic" info before I was able to put the pieces it was showing me together. Sul.