MCPcopy Create free account
hub / github.com/AutoHotkey/AutoHotkey / InputBoxParseOptions

Function InputBoxParseOptions

source/script2.cpp:4979–5022  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4977//////////////
4978
4979ResultType InputBoxParseOptions(LPTSTR aOptions, InputBoxType &aInputBox)
4980{
4981 LPTSTR next_option, option_end;
4982 for (next_option = aOptions; *next_option; next_option = omit_leading_whitespace(option_end))
4983 {
4984 // Find the end of this option item:
4985 if ( !(option_end = StrChrAny(next_option, _T(" \t"))) ) // Space or tab.
4986 option_end = next_option + _tcslen(next_option); // Set to position of zero terminator instead.
4987
4988 // Temporarily terminate for simplicity and to reduce ambiguity:
4989 TCHAR orig_char = *option_end;
4990 *option_end = '\0';
4991
4992 // The legacy InputBox command used "Hide", but "Password" seems clearer
4993 // and better for consistency with the equivalent Edit control option:
4994 if (!_tcsnicmp(next_option, _T("Password"), 8) && _tcslen(next_option) <= 9)
4995 aInputBox.password_char = next_option[8] ? next_option[8] : UorA(L'\x25CF', '*');
4996 else
4997 {
4998 // All of the remaining options are single-letter followed by a number:
4999 TCHAR option_char = ctoupper(*next_option);
5000 if (!_tcschr(_T("XYWHT"), option_char) // Not a valid option char.
5001 || !IsNumeric(next_option + 1 // Or not a valid number.
5002 , option_char == 'X' || option_char == 'Y' // Only X and Y allow negative numbers.
5003 , FALSE, option_char == 'T')) // Only Timeout allows floating-point.
5004 {
5005 *option_end = orig_char; // Undo the temporary termination.
5006 return ValueError(ERR_INVALID_OPTION, next_option, FAIL_OR_OK);
5007 }
5008
5009 switch (ctoupper(*next_option))
5010 {
5011 case 'W': aInputBox.width = DPIScale(ATOI(next_option + 1)); break;
5012 case 'H': aInputBox.height = DPIScale(ATOI(next_option + 1)); break;
5013 case 'X': aInputBox.xpos = ATOI(next_option + 1); break;
5014 case 'Y': aInputBox.ypos = ATOI(next_option + 1); break;
5015 case 'T': aInputBox.timeout = (DWORD)(ATOF(next_option + 1) * 1000); break;
5016 }
5017 }
5018
5019 *option_end = orig_char; // Undo the temporary termination.
5020 }
5021 return OK;
5022}
5023
5024BIF_DECL(BIF_InputBox)
5025{

Callers 1

BIF_DECLFunction · 0.85

Calls 8

omit_leading_whitespaceFunction · 0.85
StrChrAnyFunction · 0.85
ctoupperFunction · 0.85
IsNumericFunction · 0.85
ValueErrorFunction · 0.85
DPIScaleFunction · 0.85
ATOIFunction · 0.85
ATOFFunction · 0.85

Tested by

no test coverage detected