【发布时间】:2015-02-20 23:51:47
【问题描述】:
我想用自动热键完成一项看似简单的任务:当检测到某个热字串时,显示一个工具提示(在这种情况下,显示当前日期)。显示工具提示时,我想对 UP 和 DOWN 按键做出反应,分别显示数组上的下一个和上一个项目。然后,当按下 Enter 键时,我想确认“选择”并粘贴该工具提示文本。这是当前的代码,对于如此简单的任务来说看起来太大了。
; ------------------------ 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
}
【问题讨论】:
标签: autohotkey