I am trying to get a DateTime control to accept a date that has been typed using numbers only (in example, to select 03/07/2017 in the control i whant it to accept the user typing 03072017 instead of requiring something like 03{RightArrow}07{RightArrow}2017. I also need the control to understand when the user has finished the input and to move for the next control automatically.
Here is my solution thus far. It works, but there are some issues (such as users clicking the fields or using the left/right arrows in the control sometimes causing the algorithm to misbehave).
Code: Select all
#SingleInstance, Force
Gui, Font, s14
Gui, Add, DateTime, gFLUID_INPUT x30 y110 w160 vDATA_ATE
Gui, Add, DateTime, gFLUID_INPUT2 x210 y110 w160 vDATA_ATE_2
Gui, Add, Button, x150 y160 w100, To Focus
Gui, Show, w400 h300
Return
FLUID_INPUT:
FLUID_DATE_INPUT()
Return
FLUID_INPUT2:
FLUID_DATE_INPUT()
Return
FLUID_DATE_INPUT()
{
Static OLD_DATE_CHECK
Static LAST_CHANGE_IN_DATE
If (!(%A_GuiControl% = OLD_DATE_CHECK))
{
If !(SubStr(%A_GuiControl%, 8, 1) = SubStr(OLD_DATE_CHECK, 8, 1))
{
LAST_CHANGE_IN_DATE := 1
Send {Right}
}
Else If !(SubStr(%A_GuiControl%, 6, 1) = SubStr(OLD_DATE_CHECK, 6, 1))
{
LAST_CHANGE_IN_DATE := 2
Send {Right}
}
Else if !(SubStr(%A_GuiControl%, 4, 1) = SubStr(OLD_DATE_CHECK, 4, 1))
{
Send {Right}
Send {Tab}
}
OLD_DATE_CHECK := %A_GuiControl%
}
Else
{
If (LAST_CHANGE_IN_DATE = 1)
{
Send {Right}
LAST_CHANGE_IN_DATE := 2
}
Else if (LAST_CHANGE_IN_DATE = 2) OR (LAST_CHANGE_IN_DATE = "")
{
Send {Right}
Send {Tab}
}
}
}
Return
Best wishes.