simple Edit control with mask
simple Edit control with mask
I'm sure, there's already something but I can't find it:
gui,add,edit,vMyEdit gMyformat
a subroutine, that reliable and full editable formats MyEdit like "##.##.####" , "##/##" or similar. It should use only one Edit-field and run with AHK 1.0.x
User should only enter or delete the numbers, not the special characters.
gui,add,edit,vMyEdit gMyformat
a subroutine, that reliable and full editable formats MyEdit like "##.##.####" , "##/##" or similar. It should use only one Edit-field and run with AHK 1.0.x
User should only enter or delete the numbers, not the special characters.
Re: simple Edit control with mask
Code: Select all
If !A_IsAdmin && !(DllCall("GetCommandLine", "str") ~= " /restart(?!\S)") {
Try Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
ExitApp
} Else Gui, Font, s10
Gui, Add, Edit, w240 vstr gCheck
Gui, Show,, Number
Return
Check:
BlockInput, On
Gui, Submit, NoHide
Send % str ~= "[^./0-9]" ? "`b" : ""
BlockInput, Off
Return
Re: simple Edit control with mask
I guess at least Try won't be available in AHK 1.0.x; it seems some people are still using Chris' last version 1.0.48.05 from 2009. Other things might need to be changed to run with that version, like ~= which was introduced in v1.0.90 (which is not considered a version of classic "Chris Mallet"v1.0.x, afaik, but already of "AHK_L(exikos)").
It's perhaps time to learn something new and move on, most people don't remember the specifics of 1.0.x, or don't want to - and to get support for it won't get easier, David4. Or was it just a typo?
It's perhaps time to learn something new and move on, most people don't remember the specifics of 1.0.x, or don't want to - and to get support for it won't get easier, David4. Or was it just a typo?
Re: simple Edit control with mask
Thanks, gregster, and sorry I did not pay any attention to the version!
Re: simple Edit control with mask
Yes. I could workaround that, but the code above seems to have no relation to my question...gregster wrote: ↑29 Jun 2022, 18:22I guess at least Try won't be available in AHK 1.0.x; it seems some people are still using Chris' last version 1.0.48.05 from 2009. Other things might need to be changed to run with that version, like ~= which was introduced in v1.0.90 (which is not considered a version of classic "Chris Mallet"v1.0.x, afaik, but already of "AHK_L(exikos)").
Nevertheless I can't find the meaning of `b in the docu. Until now I had not enough reasons to switch the version. Only for testing purposes. My scripts should run under all versions since 1.0.48. Thank you.
Re: simple Edit control with mask
Probably a backspace (as an escape sequence): https://www.autohotkey.com/docs/misc/EscapeChar.htm
No idea if this works in 1.0.48, but ~= as a shortcut for RegEx surely won't.
No idea if this works in 1.0.48, but ~= as a shortcut for RegEx surely won't.
Re: simple Edit control with mask
Bingo, thanks. I only searched in RegEx-Topics.gregster wrote: ↑30 Jun 2022, 13:16Probably a backspace (as an escape sequence): https://www.autohotkey.com/docs/misc/EscapeChar.htm
Nobody with an elegant solution for the "##/##"-mask - question?
Re: simple Edit control with mask
You tested my script?
Code: Select all
If !A_IsAdmin && !(DllCall("GetCommandLine", "str") ~= " /restart(?!\S)") {
Try Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
ExitApp
} Else Gui, Font, s10
Gui, Add, Edit, w240 vstr gCheck
Gui, Show,, Number
Return
Check:
BlockInput, On
Gui, Submit, NoHide
Send % RegExMatch(str, "[^./0-9]") ? "{BS}" : ""
BlockInput, Off
Return
Re: simple Edit control with mask
mikeyww please stop flooding this topic, thanks.
Re: simple Edit control with mask
OK, I shall do that. I replied because I believed that I had addressed your question, and you never indicated whether you tried the script, that's all. In my revision, I addressed any potential issue with ~= (OK, forgot the first one) as well as `b. Cheers.
- AlphaBravo
- Posts: 586
- Joined: 29 Sep 2013, 22:59
Re: simple Edit control with mask
@mikeyww , thanks for being so polite.
@David4, it is recommended to upgrade to the latest ahk
I don't know about "elegant" but gets the job done for the most part.
@David4, it is recommended to upgrade to the latest ahk
I don't know about "elegant" but gets the job done for the most part.
Code: Select all
Gui, Add, Edit, w240 vstr gMask number
Gui, Show,, Number
Return
;---------------------------------------
Mask:
if DelKey
return
Gui, Submit, NoHide
OnMessage(0x111, Func("Suppress"), 1)
str := StrReplace(str, ".")
str := RegExReplace(str, "^(\d\d)(?!\.)", "$1.") ; ##.
str := RegExReplace(str, "^\d\d\.\K(\d\d)(?!\.)", "$1.") ; ##.##.
str := RegExReplace(str, "^\d\d\.\d\d\.\K(\d\d\d\d).*$", "$1") ; ##.##.####
GuiControl,, str, % str
Send {End}
OnMessage(0x111, Func("Suppress"), 0)
Return
;---------------------------------------
#if getActiveEdit("str")
$BackSpace::
Gui, Submit, NoHide
if RegExMatch(str, "\.$")
Send {Left}{BackSpace}
else
Send {BackSpace}
return
Delete::
DelKey := true
Send {Delete}
DelKey := false
return
#if
;---------------------------------------
Suppress(wParam) { ; https://www.autohotkey.com/boards/viewtopic.php?t=57546#p243702
if (wParam >> 16) = 0x300 ; EN_CHANGE
return 0 ; Prevent default processing by returning a value.
}
;---------------------------------------
getActiveEdit(ctrlName){
GuiControlGet, var, focusV
return (var = ctrlName)
}
- flyingDman
- Posts: 2817
- Joined: 29 Sep 2013, 19:01
Re: simple Edit control with mask
@mikeyww You could have ignored that request. IMHO requests like that do not belong on the forum.
@AlphaBravo Very nice (and above my pay grade!)!
@AlphaBravo Very nice (and above my pay grade!)!
14.3 & 1.3.7
Re: simple Edit control with mask
I think that support for ancient 1.0.48 versions (dating back 13 years) shouldn't be taken for granted.
If you want such backwards compatibility, it's your own responsibility to keep up with the requirements.
A response like "mikeyww please stop flooding this topic, thanks", I would call "ziemlich frech" in german. I guess, David4 will understand that.
All helpers on these forums are dedicating their free time to help; antagonizing them is not a smart way to make use of their huge amount of experience and expertise.
If you want such backwards compatibility, it's your own responsibility to keep up with the requirements.
A response like "mikeyww please stop flooding this topic, thanks", I would call "ziemlich frech" in german. I guess, David4 will understand that.
All helpers on these forums are dedicating their free time to help; antagonizing them is not a smart way to make use of their huge amount of experience and expertise.