Passing through keyboard shortcut to another application?
  • Hi,

    I was able to do what I want in another way, so this is not urgent, but I am curious if there was a way to do what I am asking.

    I've got a shortcut in an individual application which I would like to make into a global shortcut, by having it execute a script that activates the application and replicates the shortcut.

    Of course, if I try to use System Events to simulate this shortcut, it triggers the script that I am already executing, and so forth. Not so useful.

    So I thought, perhaps I could get FastScripts to temporarily delete the shortcut, trigger it, then restore the shortcut. But when I do this from a script, it seems it does not actually delete the shortcut completely. In addition, I can't figure out how to restore the shortcut from a script afterward.

    Here's what I've got so far:


    tell application "FastScripts"
    local _shortcut
    tell script item "Dictate"
    set _shortcut to keyboard shortcut's shortcut string
    delete keyboard shortcut
    end tell
    display dialog "no keyboard shortcut" -- it's not visible in the menu, but it still works
    tell script item "Dictate"
    set keyboard shortcut's shortcut string to _shortcut -- this doesn't work
    end tell
    end tell


    I tried initially using the keyboard shortcut rather than the keyboard shortcut's shortcut string, but this seemed to work even less well. With the above script, while the dialog is visible, the shortcut appears to be gone from the FastScripts menu, but when I press it, it still triggers my script. So it seems the shortcut is “halfway” gone.

    I guess one last option would be to quit and restart FastScripts, but that seems like a large hammer to use.

    Thanks!
  • Hi there - I think unfortunately you might be pretty limited in what you could do to get the shortcut to pass through. Indeed, the way that FastScripts currently handles shortcut keys, it will catch it every time, even if it's already handling one. There's no reliable way to temporarily shut off the keyboard-shortcut handling in FastScripts.

    Even the blunt hammer, I think, would not work, because by default FastScripts runs the scripts itself in the same process, so quitting FastScripts would probably terminate the running script and prevent it from e.g. reopening afterwards.
Start a New Discussion

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!