AutoHotKey Format Zeit

AutoHotKey Format Zeit

Ich versuche, die 24-Stunden-Zeit so zu formatieren.

Wenn ich "1930+" eingebe → 19:30

Wenn ich "0630+" eingebe → 06:30

Wenn es am Ende einer Zahl zwischen 0 und 9 ein „+“ liest, fügt es zwei Stellen weiter hinten ein „:“ hinzu. Ich bin mir nur nicht sicher, wie das geht.

Antwort1

; *: An ending character is not required 
; ?: The hotstring will be triggered even when it is inside another word 

#Hotstring * ? 

::0+::
::1+::
; ...
::9+::
    PriorKey := SubStr(A_PriorKey, 0) ; remove "Numpad" if using number pad
    SendInput, %PriorKey%{Left 2}:{Right 2}
return

Wenn du es genauer haben willst:

#Hotstring * ? 

::0+::
::1+::
; ...
::9+::
    ClipSaved := ClipboardAll   ; save Clipboard
    clipboard := ""             ; empty the clipboard
    PriorKey := SubStr(A_PriorKey, 0) ; remove "Numpad" if using number pad
    SendInput, %PriorKey%{Shift Down}{Left 4}{Shift Up} ; select the last 4 typed chars
    Send, ^c                    ; copy the selected text
    ClipWait, 1                 ; wait for the clipboard to contain data. 
    if (!ErrorLevel)            ; If NOT ErrorLevel clipwait found data on the clipboard
    {
        If ((clipboard is number) && (SubStr(clipboard, 1, 2) < 24) && (SubStr(clipboard, -1) < 60))
            Send, {Left}{Right 2}:{Right 2}
        else 
            Send, {Right}
    }
    Sleep, 300
    clipboard := ClipSaved    ; restore original clipboard
return

https://autohotkey.com/docs/Hotstrings.htm#Options

verwandte Informationen