LiquidNitrogen Posted January 19, 2012 Share Posted January 19, 2012 (edited) Converts:- String to Binary- String to Hex- Binary to String- Hex to StringAdded Error Checking.expandcollapse popup#Include <EditConstants.au3> #include <String.au3> #NoTrayIcon Main() StringToB() StringToH() BinaryToS() HexToS() Func Main() GUIDelete() $Main = GUICreate("String Converter", 250, 230) $title = GUICtrlCreateLabel("String Converter by ReaperX", 55, 20) $StringToB = GUICtrlCreateButton("String -> Binary", 75, 60, 100, 30) $StringToH = GUICtrlCreateButton("String -> Hex", 75, 90, 100, 30) $BinaryToS = GUICtrlCreateButton("Binary -> String", 75, 120, 100, 30) $HexToS = GUICtrlCreateButton("Hex -> String", 75, 150, 100, 30) $about = GUICtrlCreateButton("About", 0, 210, 80, 20) $exit = GUICtrlCreateButton("Exit", 170, 210, 80, 20) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case -3 Exit Case $StringToB StringToB() Case $StringToH StringToH() Case $BinaryToS BinaryToS() Case $HexToS HexToS() Case $about MsgBox(0, "About", "Created By ReaperX (C) 2011.") Case $exit Exit EndSwitch WEnd EndFunc ;==>Main Func StringToB() GUIDelete() GUICreate("String Converter", 300, 260) $title = GUICtrlCreateLabel("String To Binary", 110, 50) $text_label = GUICtrlCreateLabel("Text String:", 15, 101) $text = GUICtrlCreateInput("", 75, 100, 170, 18) GUICtrlSetTip($text, "String to Convert to Binary.") $result = GUICtrlCreateInput("", 75, 130, 170, 18, BitOr($GUI_SS_DEFAULT_INPUT, $ES_READONLY)) GUICtrlSetTip($result, "Conversion Displayed Here.") $result_label = GUICtrlCreateLabel("Result:", 35, 131) $convert = GUICtrlCreateButton("Convert", 130, 160, 50, 30) $back = GUICtrlCreateButton("<- Back", 0, 0, 45, 20) $copy = GUICtrlCreateButton("Copy To Clipboard", 105, 200, 100, 20) GUICtrlSetTip($copy, "Copy Conversion Result to Clipboard.") $converter = "" GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case -3 Exit Case $convert $read = GUICtrlRead($text) $converter = StringToBinary($read) GUICtrlSetData($result, $converter) Case $back Main() Case $copy ClipPut($converter) MsgBox(0, "Copied!", "Conversion Copied to Clipboard!") EndSwitch WEnd EndFunc ;==>StringToB Func StringToH() GUIDelete() GUICreate("String Converter", 300, 260) $title = GUICtrlCreateLabel("String To Hex", 110, 50) $text_label = GUICtrlCreateLabel("Text String:", 15, 101) $text = GUICtrlCreateInput("", 75, 100, 170, 18) GUICtrlSetTip($text, "String to Convert to Hex.") $result = GUICtrlCreateInput("", 75, 130, 170, 18, BitOr($GUI_SS_DEFAULT_INPUT, $ES_READONLY)) GUICtrlSetTip($result, "Conversion Displayed Here.") $result_label = GUICtrlCreateLabel("Result:", 35, 131) $convert = GUICtrlCreateButton("Convert", 130, 160, 50, 30) $back = GUICtrlCreateButton("<- Back", 0, 0, 45, 20) $copy = GUICtrlCreateButton("Copy To Clipboard", 105, 200, 100, 20) GUICtrlSetTip($copy, "Copy Conversion Result to Clipboard.") $converter = "" GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case -3 Exit Case $convert $read = GUICtrlRead($text) $converter = _StringToHex($read) GUICtrlSetData($result, $converter) Case $back Main() Case $copy ClipPut($converter) MsgBox(0, "Copied!", "Conversion Copied to Clipboard!") EndSwitch WEnd EndFunc ;==>StringToH Func BinaryToS() GUIDelete() GUICreate("String Converter", 300, 260) $title = GUICtrlCreateLabel("Binary To String", 110, 50) $text_label = GUICtrlCreateLabel("Binary String:", 8, 101) $text = GUICtrlCreateInput("", 75, 100, 170, 18) GUICtrlSetTip($text, "Binary String to Convert to Text.") $result = GUICtrlCreateInput("", 75, 130, 170, 18, BitOr($GUI_SS_DEFAULT_INPUT, $ES_READONLY)) GUICtrlSetTip($result, "Conversion Displayed Here.") $result_label = GUICtrlCreateLabel("Result:", 35, 131) $convert = GUICtrlCreateButton("Convert", 130, 160, 50, 30) $back = GUICtrlCreateButton("<- Back", 0, 0, 45, 20) $copy = GUICtrlCreateButton("Copy To Clipboard", 105, 200, 100, 20) GUICtrlSetTip($copy, "Copy Conversion Result to Clipboard.") $converter = "" GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case -3 Exit Case $convert If StringInStr(GUICtrlRead($text), "0x") And Not StringTrimLeft(GUICtrlRead($text), 2) = "" Then $read = GUICtrlRead($text) $converter = BinaryToString($read) GUICtrlSetData($result, $converter) Else MsgBox(16, "Error!", "The Binary String Entered is Not Valid!") GUICtrlSetData($text, "") GUICtrlSetData($result, "") EndIf Case $back Main() Case $copy ClipPut($converter) MsgBox(0, "Copied!", "Conversion Copied to Clipboard!") EndSwitch WEnd EndFunc ;==>BinaryToS Func HexToS() GUIDelete() GUICreate("String Converter", 300, 260) $title = GUICtrlCreateLabel("Hex To String", 110, 50) $text_label = GUICtrlCreateLabel("Hex String:", 15, 101) $text = GUICtrlCreateInput("", 75, 100, 170, 18) GUICtrlSetTip($text, "Hex String to Convert to Text.") $result = GUICtrlCreateInput("", 75, 130, 170, 18, BitOr($GUI_SS_DEFAULT_INPUT, $ES_READONLY)) GUICtrlSetTip($result, "Conversion Displayed Here.") $result_label = GUICtrlCreateLabel("Result:", 35, 131) $convert = GUICtrlCreateButton("Convert", 130, 160, 50, 30) $back = GUICtrlCreateButton("<- Back", 0, 0, 45, 20) $copy = GUICtrlCreateButton("Copy To Clipboard", 105, 200, 100, 20) GUICtrlSetTip($copy, "Copy Conversion Result to Clipboard.") $converter = "" GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case -3 Exit Case $convert If StringIsXDigit(GUICtrlRead($text)) Then $read = GUICtrlRead($text) $converter = _HexToString($read) GUICtrlSetData($result, $converter) Else MsgBox(16, "Error!", "The Hex String Entered is Not Valid!") GUICtrlSetData($text, "") GUICtrlSetData($result, "") EndIf Case $back Main() Case $copy ClipPut($converter) MsgBox(0, "Copied!", "Conversion Copied to Clipboard!") EndSwitch WEnd EndFunc ;==>HexToS Edited January 23, 2012 by ReaperX Formerly ReaperX Link to comment Share on other sites More sharing options...
AZJIO Posted January 20, 2012 Share Posted January 20, 2012 ReaperX Hex String: 0xzz Result: 0xzz My other projects or all Link to comment Share on other sites More sharing options...
LiquidNitrogen Posted January 20, 2012 Author Share Posted January 20, 2012 (edited) ReaperXHex String: 0xzzResult: 0xzzThere is No "0xzz" in Hex. Otherwise It Would Work. Edited January 20, 2012 by ReaperX Formerly ReaperX Link to comment Share on other sites More sharing options...
JohnOne Posted January 20, 2012 Share Posted January 20, 2012 You should check for invalid chars and return an error. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
AZJIO Posted January 20, 2012 Share Posted January 20, 2012 ReaperX StringIsXDigit My other projects or all Link to comment Share on other sites More sharing options...
LiquidNitrogen Posted January 21, 2012 Author Share Posted January 21, 2012 You should check for invalid chars and return an error.Good Idea. Ill Work on that and Update it. Formerly ReaperX Link to comment Share on other sites More sharing options...
LiquidNitrogen Posted January 21, 2012 Author Share Posted January 21, 2012 ReaperXStringIsXDigitI Dont get What You are Saying... Formerly ReaperX Link to comment Share on other sites More sharing options...
JohnOne Posted January 21, 2012 Share Posted January 21, 2012 (edited) StringIsXDigitChecks if a string contains only hexadecimal digit (0-9, A-F) characters.StringIsXDigit ( "string" ) Edited January 21, 2012 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
LiquidNitrogen Posted January 21, 2012 Author Share Posted January 21, 2012 Oh Ok. Thanks. Formerly ReaperX Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now