KickStarter15 Posted September 21, 2018 Share Posted September 21, 2018 Hi Experts, I need your expertise on this one and need help. I've been searching whole day to see what should be the correct way in checking symbols or characters inputted in inputbox that is invalid. As of the current symbol that is invalid is "Greek letter mu (03BC)" which should be the correct symbol to use is "micro sign (00B5)" but both symbols is the same in actual character but different hexadecimal code. Now, I want to prompt the (0x03BC) hexadecimal code as invalid once it was inputted in my inputbox as actual character/symbol " μ ", but could not find a way how to do this. However, I have found something like below related issue but I think this is not what I want but similar to it. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> ;checks input to ensure the letter 'r' is not typed AdlibRegister("check", 100) Local $msg GUICreate("Test", 300, 300) Global $input = GUICtrlCreateInput("", 10, 10, 280, 40) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd GUIDelete() Func check() If StringInStr(GUICtrlRead($input), Hex(0x03BC, 4)) Then ;~ This is the actual character "µ" and this is the hexadecimal code "0x03BC" MsgBox(0, "", "Illegal character entered.") ;inform user GUICtrlSetData($input, StringTrimRight(GUICtrlRead($input), 1)) EndIf EndFunc Need your help Experts, please. Thank you in advance. KS15 Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare. Link to comment Share on other sites More sharing options...
Malkey Posted September 21, 2018 Share Posted September 21, 2018 Based on your example, this modified example informs the user that one unicode character will be replaced with another unicode character. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> AdlibRegister("check", 250) Local $msg GUICreate("Test", 300, 300) Global $input = GUICtrlCreateInput(" " & ChrW(0x03BC), 10, 10, 280, 40) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE AdlibUnRegister("check") ExitLoop EndSelect WEnd GUIDelete() Func check() If StringInStr(GUICtrlRead($input), ChrW(0x03BC)) Then ;~ This is the actual character "µ" that has the hexadecimal unicode code "0x03BC". MsgBox(0, "Illegal character entered.", 'Unicode character 0x03BC, "' & ChrW(0x03BC) & '"' & @CRLF & _ ' will be replaced with, ' & @CRLF & _ 'Unicode character 0x00B5, "' & ChrW(0x00B5) & '"') GUICtrlSetData($input, StringReplace(GUICtrlRead($input), ChrW(0x03BC), ChrW(0x00B5))) MsgBox(0, "", "Done", 1) EndIf EndFunc ;==>check KickStarter15 1 Link to comment Share on other sites More sharing options...
KickStarter15 Posted September 21, 2018 Author Share Posted September 21, 2018 @Malkey, Wow, you save my whole day. Thank you so much Malkey, but I never saw ChrW() function in my searching glad you're here. This is exactly what I wanted to do. Thumbz up men, wowwww.... Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare. 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