I want to accomplish an apparently easy task with autohotkey: when certain hotstring is detected, then show a tooltip (in this case, with the current date). While the tooltip is displayed I want to react to UP and DOWN key-presses showing the next and previous item on an array respectively. Then when the Enter key is pressed I want to confirm the "selection" and paste that tooltip text. Here is the current code, which looks too big for a task that is so simple.
; ------------------------ Date tooltip
::#curdate::
EnteringDate := True
DateSeparator := [".","/","-"]
SelectedSep := 1
GoSub, ShowToolTip
return
ShowToolTip:
Sep := DateSeparator[SelectedSep]
FormatTime, Time,, dd%Sep%MM%Sep%yyyy ; dd MM yyyy is day month year
ToolTip, %Time%
return
#If EnteringDate
Up::
SelectedSep := cycle(SelectedSep,DateSeparator.MaxIndex(),1)
GoSub, ShowToolTip
return
Down::
SelectedSep := cycle(SelectedSep,DateSeparator.MaxIndex(),-1)
GoSub, ShowToolTip
return
Enter::
EnteringDate := False
SendInput, %Time%
ToolTip ; Clear the tool tip
return
#If ; end entering date
cycle(value,maxValue,increment:=1){
value += increment
if value not between 1 and %maxValue%
value := increment<0 ? maxValue : 1
return value
}