1

This Automator workflow works perfectly when run from Automator.

However, when launched as a service from a keyboard shortcut, the script generates a timed out error.

The keyboard shortcut is valid. If we map the shortcut to Automator script #2, script #2 runs from the shortcut without issue.

The keyboard shortcut is Command+Shift+F.

tell application "Google Chrome"

    set allTabs to every tab of front window

    repeat with aTab in allTabs
        set curURL to URL of aTab
        set newURL to my findAndReplaceInText(curURL, "%3F", "?")
        set URL of aTab to newURL
    end repeat

end tell

on findAndReplaceInText(theText, theSearchString, theReplacementString)
    set AppleScript's text item delimiters to theSearchString
    set theTextItems to every text item of theText
    set AppleScript's text item delimiters to theReplacementString
    set theText to theTextItems as string
    set AppleScript's text item delimiters to ""
    return theText
end findAndReplaceInText
  • 2
    1. The keyboard shortcut ⇧⌘F is already the default assigned to Always Show Toolbar in Full Screen under the View menu in Google Chrome, did you modify it? 2. You said, "If we map the shortcut to Automator script #2, script #2 runs from the shortcut without issue.", there is only one AppleScript script shown in your OP. 3. You have not said what settings you're using in the Automator Service. 4. You said, "script generates a timed out error", how is this error shown and what is the exact wording? Continued in next comment... – user3439894 Feb 20 '18 at 3:06
  • 1
    5. A repeat loop that is going to essentially load multiple webpages should alway have a delay set at the bottom of the repeat loop, e.g. delay 3 at a minimum. This may help with the time out error, test it and see. That all said, from what I can see there is a bit of information missing making this a very low quality question. BTW I ran your code on a Google Chrome window with 10 tabs that would meet the search/replace criteria with the delay 3 added and didn't get a time out. (I didn't test without the delay 3 because I'd never use a loop in this uses case without it.) – user3439894 Feb 20 '18 at 3:12
  • @user3439894 thanks for the reply. it was implied that Always Show Toolbar in Full Screen was remapped already. otherwise, the other script wouldn't run. you're right, though, that the service properties were omitted. it's set to receive no text input. anything else that would be helpful? thanks for the reply! – Crashalot Feb 20 '18 at 7:06
  • @user3439894 did the script work, i.e., replace instances of %3F with ?? thanks for testing it out, appreciate the help! – Crashalot Feb 20 '18 at 7:06

You must log in to answer this question.

Browse other questions tagged .