I use use auto hot key v2 so that hotstrings like
;todojd7
get replaced by
<WRAP noprint><todo @john.doe start:2024-01-22 due:2024-01-29 > </todo></WRAP>
where;todo
is the trigger prefix, jd
is the user initials and 7
is the number of days to the due
date. Start
date is assumed to be today and I don't like my tasks appearing in printed output to I wrap
the whole lot.
this is the AHK script that does the text swap. Its quite complicated as it has to account for a number of days for the due date that can be different numbers of digits
;dokuwiki
:B0*:;todo::
{
userList := Map("jd", "john.doe", "mm", "mickey.mouse", "dv", "darthvader")
;;get input either 4 chars or 2 seconds
myInputHook := InputHook("V L4 T2")
myInputHook.Start()
myInputHook.Wait()
myInput := myInputHook.Input
;default duration
duration := 7
;; get the initials from the first 2 characters or default to jd if empty
initials := SubStr(myInput, 1 , 2) = "" ? "jd" : SubStr(myInput, 1 , 2)
length := StrLen(myInput) < 3 ? StrLen(myInput) : 3
;;get the duration or default to 7 days
if ( SubStr(myInput, 3, 1 ) = " " or SubStr(myInput, 3, 1 ) = "")
{
duration := 7
}
Else
{
if ( SubStr(myInput, 3) > 0 )
{
duration := SubStr(myInput, 3)
}
}
;;calculate how many chars to delete
extrachars := StrLen(duration) + length +4
;;SendInput % "name is " text[initials] " and duration is " duration " number chars to delete is " extrachars " :987654321 "
;;delete the extra intials and duration characters
SendInput "{BS " . extrachars . "}"
;;calculate dates
today := FormatTime(A_Now , "yyyy-MM-dd")
dueDate := DateAdd(A_Now, duration, "days")
dueDate := FormatTime(dueDate , "yyyy-MM-dd")
;;send output
SendInput userList.has(initials) ? "<WRAP noprint><todo @" userList.get(initials) " start:" today " due:" dueDate " > </todo></WRAP>{left 15}" : " No Matching user{shift down}{left 17}{shift up}"
;;give audio feedback
SoundBeep 2500
Return
}
a simpler one is to create a level 4 date stamp title
;;dokuwiki level 4 title
:*:;dw4::
{
today := FormatTime(A_Now , "yyyy-MM-dd")
SendInput "{= 4}" . today . "{= 4}`n"
return
}
you can even do clipboard manipulation for example to turn urls in the clipboard into DW namespace paths
;;dokuwiki paste url as wiki namespace
:*:;dwurl::
{
Clipboard := A_Clipboard
myVar := "Default"
if (A_Clipboard != "" and InStr(A_Clipboard,"mydomain.com" ) > 1 )
{
;;myVar := StrReplace( A_Clipboard, "https://mydomain.com","")
myVar := RegExReplace(A_Clipboard,"https:\/\/.*mydomain\.com","")
myVar := StrReplace( myVar, "/",":")
;;myVar := StrReplace( myVar, "#","{#}")
myVar := RegExReplace(myVar,"(\s|\n|\r)+","")
A_Clipboard := myVar
SendInput "^v"
Sleep 100
A_Clipboard := Clipboard
}
return
}
so it should easily be able to come up with ;mypath1
etc to return your long path
I use ;
as the prefix as in theory this character is always followed by a space in normal typing so if its followed by a character it will be a hotstring replacement.
This saves me loads of time and it works everywhere I type it, on any website or in any application. However it only works from My PC so I can't easily share these time saving tips with other users of the wiki which is why I was also looking for javascript that I could add to the wiki that listened for these hotstrings and did the replacements so that ALL users of the site I add it to can benefit.