3

Instead of "asdf", I want to use the input variable here.

Seems like this should be easy, but for some reason I can't figure it out.

on run {input, parameters}
-- Type 'asdf'
delay 1.900231
set timeoutSeconds to 2.0
set uiScript to "keystroke \"asdf\""
my doWithTimeout(uiScript, timeoutSeconds)
return input
end run

on doWithTimeout(uiScript, timeoutSeconds)
set endDate to (current date) + timeoutSeconds
repeat
    try
        run script "tell application \"System Events\"
" & uiScript & "
end tell"
    exit repeat
    on error errorMessage
        if ((current date) > endDate) then
            error "Can not " & uiScript
        end if
    end try
end repeat
end doWithTimeout

For example, if I try set uiScript to "keystroke input", I get the error from Automator:

The action “Run AppleScript” encountered an error.
Check the actionʼs properties and try running the workflow again.
1
  • 1
    set uiScript to "keystroke \"" & input & "\"" ? Commented Apr 19, 2013 at 20:18

1 Answer 1

4

Figured it out myself. I feel dumb now.

set uiScript to "keystroke \"" & input & "\""

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.