• ### Similar Content

• Func _Binary(\$Int) ;Uncomment To Only Accept Integers #cs If IsInt(\$Int) = 0 Then Return 0 EndIf #ce If \$Int < 0 Then ;Negative Numbers Will Break The Function Return 0000 EndIf Local \$Integer = \$Int Dim \$Bin[1] = [Mod(\$Integer, 2)] Local \$Counter = 1 Do \$Integer = Floor(\$Integer / 2) _ArrayAdd(\$Bin, Mod(\$Integer, 2)) Until \$Integer = 0 _ArrayReverse(\$Bin) ;Reverses The Array Because As Is, The Product Is Backwards ;A Loop To Remove Any Preceding 0's or Add 0's To Keep At Least Four Digits Select Case \$Int <= 1 \$Integer = "00" & _ArrayToString(\$Bin, "") Case \$Int = 2 Or \$Int = 3 \$Integer = "0" & _ArrayToString(\$Bin, "") Case \$Int >= 8 \$Integer = StringTrimLeft(_ArrayToString(\$Bin, ""), 1) Case Else \$Integer = _ArrayToString(\$Bin, "") EndSelect ;You Can Comment It Out Without Anything Else Having A Problem Return \$Integer EndFunc I made this because I was writing something that I could use to play with Bitwise Operations and using Binary() by itself wasn't helping.
It's very basic and will only take positive integers because that's all I needed but I'm sure with a little tweaking you could make it fit with negative and float types.
It returns a string essentially but doesn't pose a problem when just changing numbers into binary digits.
Example: If you were to do _Binary(5) you would get "0101" and _Binary(8) would return "1000"
Between this last sentence and here I've changed this about a half dozen times to refine it a bit because without it checking if your number is < 0 it would break if a negative number was inserted and it wouldn't even have a problem if you put in Float Values, Regular or Special Characters but that negative value will do the trick lol.
Anyway, I hope someone finds some use of this and thank you for reading!
-Pick

• 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.

• Hi AutoIt Programmers, i wanna figure out how to use Binary functions in C# like:

BinaryMid
BinaryLen
IsBinary and other basic ones were too ez, but those two were hard to noob like me.

am trying to work with CreateWindowEx api, i created the window with it controls, also i setup the call back function
i'am using WinMSGLoop to focus with the keyboard.
here i have a problem, i hope that you can help me.
on the controls i used the UDF that comme with the autoit, such as _GUIButton_Create, _GUIListBox_Create....
but i can't find a STATIC control UDF, for that i used this

local \$h_ssrvlbl = _WinAPI_CreateWindowEx(0, "STATIC", "الخادم", BitOr(\$WS_VISIBLE, \$WS_CHILD, \$WS_CLIPSIBLINGS, \$WS_CLIPCHILDREN), 250, 10, 100, 20, \$hWnd)
as you can see here, there is an arabic text, so here is the problem, the arabic text isn't show normally, what is the problem here?
also i have  an other question about keyboard focus, when i used WinMSGLoop, it worked, but if i press alt+tab to switch windows or focus an other window and return back to my window, the focus of control is kill.
can any one help me to solve that please?
my code will be as file here with the include files
i hope can any one help me here

speed Test win.zip
• By jmor
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?
×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...