Come scrivere un servizio per ottenere una stringa?

1

Voglio scrivere un servizio su macOS, e restituisco solo una stringa, come il mio indirizzo email. Quindi, in qualsiasi applicazione, se ho bisogno di inserire l'indirizzo email, ho appena colpito la stessa scorciatoia.

Scrivo un servizio in automator ed eseguo script di shell:

#!/usr/bin echo "[email protected]"

ma invia solo il testo allo stdout invece dell'input dell'applicazione.

    
posta Sting Jia 12.04.2017 - 05:26
fonte

1 risposta

2

È possibile aggiungere un comando "run applescript" al flusso di lavoro dell'automator

set the clipboard to "[email protected]"
tell application "System Events"
    keystroke (the clipboard)
end tell

o

tell application "System Events"
    keystroke "[email protected]"
end tell

Puoi aggiungere questo AppleScript al tuo flusso di lavoro di Automator per poter inserire l'ora e la data dagli appunti

set AppleScript's text item delimiters to ","
set theLongDate to (current date)
set theLongDate to (date string of theLongDate)
set currentMonth to (word 1 of text item 2 of theLongDate)
set currentDay to (word 2 of text item 2 of theLongDate)
set currentYear to (word 1 of text item 3 of theLongDate)
set monthList to {January, February, March, April, May, June, July, August, September, October, November, December}
repeat with x from 1 to 12
    if currentMonth = ((item x of monthList) as string) then
        set theRequestNumber to (text -2 thru -1 of ("0" & x))
        exit repeat
    end if
end repeat
set currentMonth to theRequestNumber
set currentDay to (text -2 thru -1 of ("0" & currentDay))
set theShortDate to (currentMonth & "/" & currentDay & "/" & currentYear) as string
set CurrentTime to (time string of (current date))
set CurrentTimeandShortDate to (theShortDate & " @ " & CurrentTime)

set the clipboard to the result -- the result formatted like this 04/16/2017 @ 12:27:00 AM

-- If you only want to copy the time and date to your clip board without sending the keystrokes, Then comment out the next three lines

tell application "System Events"
    keystroke (the clipboard)  
end tell
    
risposta data 12.04.2017 - 19:37
fonte

Leggi altre domande sui tag