Sign in to follow this  
Followers 0
CodyBarrett

Binary Tutoring\Converter

5 posts in this topic

#1 ·  Posted (edited)

This i made cause i was bored. lol.

Features:

*RealTime converstion

*Ascii Values Per Character

*Ascii -> Binary Formula

*Binary Value

*Binary message converted from What User has Typed.

please tell me if i need to change anything... like if my formula is wrong, or if i could simplify it.

#include <GUICONSTANTS.AU3>
#include <WINDOWSCONSTANTS.AU3>
#include <STATICCONSTANTS.AU3>
#include <EDITCONSTANTS.AU3>
#include <MISC.AU3>
#Include <GuiEdit.au3>
Opt ('GUIoneventmode', 1)
$lastdata = ''
$GUIX = 730
$lStyle = BitOR ($SS_CENTER, $SS_CENTERIMAGE)
$EditStyle = BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_TABSTOP,$WS_VSCROLL)
$EditStyleEx = BitOR($EditStyle, $ES_READONLY)
$GUI = GUICreate ('Binary Tutor', $GUIX, 700, -1, -1, -2138570616)
GUISetBkColor (0x0,$GUI)
GUISetOnEvent ($GUI_EVENT_CLOSE, '_Exit', $GUI)

        GUICtrlCreateLabel ('',0,0,$GUIX,15)
            GUICtrlSetBkColor (-1, 0x1c3fca)
            GUICtrlSetState (-1,$GUI_DISABLE)
        
        GUICtrlCreateLabel ('',0,15,$GUIX,15)
            GUICtrlSetBkColor (-1,0x15319d)
            GUICtrlSetState (-1,$GUI_DISABLE)
        
        GUICtrlCreateLabel ('x',0,0,30,30,$lStyle)
            GUICtrlSetColor (-1,0xFFFFFF)
            GUICtrlSetFont (-1,10,900,'','Tahoma')
            GUICtrlSetCursor (-1,0)
            GUICtrlSetOnEvent (-1,'_Exit')
            GUICtrlSetBkColor (-1,$GUI_BKCOLOR_TRANSPARENT)
        GUICtrlCreateLabel ('_',30,0,30,30,$lStyle)
            GUICtrlSetColor (-1,0xFFFFFF)
            GUICtrlSetFont (-1,10,900,'','Tahoma')
            GUICtrlSetCursor (-1,0)
            GUICtrlSetOnEvent (-1, '_Mini')
            GUICtrlSetBkColor (-1,$GUI_BKCOLOR_TRANSPARENT)
        
        GUICtrlCreateLabel (WinGetTitle ($GUI,''),60,0,$GUIX - 120,30,$lStyle,$GUI_WS_EX_PARENTDRAG)
            GUICtrlSetColor (-1,0xFFFFFF)
            GUICtrlSetFont (-1,10,900,'','Tahoma')
            GUICtrlSetBkColor (-1,$GUI_BKCOLOR_TRANSPARENT)
        
        GUICtrlCreateLabel ('',$GUIX - 40,0,60,30)
            GUICtrlSetBkColor (-1,$GUI_BKCOLOR_TRANSPARENT)
            GUICtrlSetState (-1,$GUI_DISABLE)



GUICtrlCreateLabel ('Type In Here... And Will Automatically Be Converted.',10,35,$GUIX - 20,20,$lStyle)
    GUICtrlSetColor (-1,0xFFFFFF)
    GUICtrlSetFont (-1,10,900,'','Tahoma')
    GUICtrlSetBkColor (-1,$GUI_BKCOLOR_TRANSPARENT)
$eText = GUICtrlCreateEdit ('',10, 60, $GUIX - 20,100,$EditStyle)
    GUICtrlSetColor (-1,0xFFFFFF)
    GUICtrlSetFont (-1,20,900,'','Tahoma')
    GUICtrlSetBkColor (-1,0x15319d)
    GUICtrlSetLimit (-1,90)


GUICtrlCreateLabel ('The Formulas To Convert ASCII Characters To BINARY',10,165,$GUIX - 20,20,$lStyle)
    GUICtrlSetColor (-1,0xFFFFFF)
    GUICtrlSetFont (-1,10,900,'','Tahoma')
    GUICtrlSetBkColor (-1,$GUI_BKCOLOR_TRANSPARENT)
$eConsole = GUICtrlCreateEdit ('',10, 190, $GUIX - 20,370,$EditStyleEx)
    GUICtrlSetColor (-1,0xFFFFFF)
    GUICtrlSetFont (-1,11,900,'','Tahoma')
    GUICtrlSetBkColor (-1,0x15319d)


GUICtrlCreateLabel ('The Converted BINARY Values ( "/ 00100000 /" Separates Words)',10,560,$GUIX - 20,20,$lStyle)
    GUICtrlSetColor (-1,0xFFFFFF)
    GUICtrlSetFont (-1,10,900,'','Tahoma')
    GUICtrlSetBkColor (-1,$GUI_BKCOLOR_TRANSPARENT)
$eBinary = GUICtrlCreateEdit ('',10, 585, $GUIX - 20,100,$EditStyleEx)
    GUICtrlSetColor (-1,0xFFFFFF)
    GUICtrlSetFont (-1,12,900,'','Tahoma')
    GUICtrlSetBkColor (-1,0x15319d)


        


GUISetState ()
While 1
    If $lastdata <> GUICtrlRead ($eText) Then _Convert (GUICtrlRead ($eText))
    Sleep (100)
WEnd
Func _Convert ($Data)
    Local $tData, $iData, $1, $hWnd, $bin
    GUICtrlSetData ($eConsole,'')
    $tData = StringSplit ($Data,'')
    $hWnd = ControlGetHandle ($GUI,'','Edit2')
    $bin = ''
    For $1 = 1 To StringLen ($Data)
        $iData = 'Chr = "' & $tData[$1] & '"' & @CRLF & _
                'Ascii = ' & Asc ($tData[$1]) & @CRLF & _
                'Formula :' &@CRLF & _Math($tData[$1]) & @CRLF & _
                'Binary = ' & _ChrtoBin ($tData[$1]) & @CRLF & _
                '—————————————————————————————————————————————————————'  & @CRLF
        _GUICtrlEdit_AppendText ($hWnd,$iData)
        
        $bin &= _ChrtoBin ($tData[$1]) & ' '
    Next
    GUICtrlSetData ($eBinary,StringReplace ($bin,'00100000', '/ 00100000 /'))
    $lastdata = $Data
EndFunc
Func _ChrtoBin ($chr)
    Local $asc, $bin, $2
    $asc = Asc ($chr)
    $bin = ''
    For $2 = 7 To 0 step -1
        If $asc >= 2 ^ $2 Then
            $bin &= 1
            $asc -= 2 ^ $2
        Else
            $bin &= 0
        EndIf
    Next
    Return $bin
EndFunc
Func _Math ($chr)
    Local $form, $tform, $bin, $asc, $2, $base
    $asc = Asc ($chr)
    $bin = ''
    For $2 = 7 To 0 step -1
        $base = @CRLF & $asc & ' >= ' & 2 ^ $2
        $bin = StringReplace ($bin,' & ','')
        If $asc >= 2 ^ $2 Then
            $bin &= 1
            $tform = $base & ' [ True ] ' & @TAB & StringTrimRight ($bin,1) & ' & 1'
            $asc -= 2 ^ $2
        Else
            $bin &= 0
            $tform = $base & ' [ False ]' & @TAB & StringTrimRight ($bin,1) & ' & 0'
        EndIf
        $form &= $tform
    Next
    Return $form
EndFunc
Func _Mini ()
    GUISetState (@SW_MINIMIZE, $GUI)
EndFunc
Func _Exit ()
    Exit
EndFunc
Edited by CodyBarrett

Share this post


Link to post
Share on other sites



Interesting.

Share this post


Link to post
Share on other sites

comments\suggestions\Critique?

Share this post


Link to post
Share on other sites

Nice, works good.

Strange colors, but not hard to read.

X on wrong side pisses me off ;)

Overall good.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

thanks lol

damnit.. i realised something XD my formula is wrong.. thats the forumla for BINtoASCII converstion not ASCIItoBIN... *sigh* simple change though...

EDIT: fixed the Formula... Ugh now its huge and obnoxious

Edited by CodyBarrett

Share this post


Link to post
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
Sign in to follow this  
Followers 0