Jump to content

Using Application specific hotkeys to paste text


Recommended Posts

Dear forum members, 

 

I have not yet used Alfred, but am trying to find an app to do something quite simple, but specific. I'm hoping you can tell me whether Alfred is suitable for this task. 

 

I need to assign a combination of about 30 keywords to thousands of photos in Lightroom. It takes forever to do it by scrolling and clicking through the lists.

 

Ideally, I would like an app-specific way to create hotkeys to do this. So if I am in Lightroom, hit CMD-ALT-A (or some other combination of keys) to paste the text 'Avalanche', CMD-ALT-B to past 'Bobcat' etc. 

 

Is this possible? If yes, I'd love a link to a tutorial if you know one. 

 

Many thanks in advance. 

Link to comment

This is straightforward to do with a workflow, but you need a Powerpack licence to use/create workflows. I dare say it'd be worth the price for this job alone.

To do this, first create a workflow.

Then add a Hotkey trigger (+ > Triggers > Hotkey). Assign your hotkey, and drag the Lightroom application into the list in the Related Apps tab.

Then add a Run Script action (+ > Actions > Run Script). Set language to "/usr/bin/osascript (AS)" and paste the following in the Script box:
 

tell application "System Events" to keystroke "Avalanche"

Connect the Hotkey box to the Run Script action and you're good to go.

Repeat 29 more times for your other hotkey-text combinations. (You can copy and paste, then edit the existing actions).

Link to comment
  • 1 month later...

This is straightforward to do with a workflow, but you need a Powerpack licence to use/create workflows. I dare say it'd be worth the price for this job alone.

To do this, first create a workflow.

Then add a Hotkey trigger (+ > Triggers > Hotkey). Assign your hotkey, and drag the Lightroom application into the list in the Related Apps tab.

Then add a Run Script action (+ > Actions > Run Script). Set language to "/usr/bin/osascript (AS)" and paste the following in the Script box:

 

tell application "System Events" to keystroke "Avalanche"

Connect the Hotkey box to the Run Script action and you're good to go.

Repeat 29 more times for your other hotkey-text combinations. (You can copy and paste, then edit the existing actions).

 

 

Thanks! This was super helpful. I've been trying to set this up for a while and I'm having a really weird problem. The workflow works maybe every third time. The rest of the time is dumps tons of gibberish.

 

So, the details of my workflow. For the Hotkey I's tried many options:

CTRL-OPTION-<various letters>
CTRL-COMMAND-<various letters>
OPTION-COMMAND-<various letters>
CTRL-OPTION-COMMAND-<various letters>

And the script I've been using is just like yours, tried it with Run Script /usr/bin/osascript (AS):

tell application
   "System Events" keystroke "myemail@something.com"
end tell

And tried it with Run NSAppleScript:

on alfred_script(q)
   tell application "System Events" to keystroke "myemail@whatever.com"
end flared_script

If anybody has any ideas it would be really helpful. I have been testing with ALL applications closed down. For example: not even google drive or smcFanControl is running in the background. I tried to eliminate anything that might do anything with hotkeys.

Edited by goodkarma
Link to comment

This isn't a useful bug report.

That "gibberish" is the error message. You need to post that.

Fundamentally, if you need help with something, you have to specify:

  • The software/configuration that's throwing the error (i.e. the code and/or workflow configuration)
  • The exact input
  • The expected result
  • The actual result (including all the output, even if it looks like gibberish)
If someone reading your post can't replicate the problem you're having, the chances of it getting solved drop dramatically. The easier you make it for somebody to replicate the problem, the better your chances of getting help. Edited by deanishe
Link to comment

This isn't a useful bug report.

That "gibberish" is the error message. You need to post that.

Fundamentally, if you need help with something, you have to specify:

  • The software/configuration that's throwing the error (i.e. the code and/or workflow configuration)
  • The exact input
  • The expected result
  • The actual result (including all the output, even if it looks like gibberish)
If someone reading your post can't replicate the problem you're having, the chances of it getting solved drop dramatically. The easier you make it for somebody to replicate the problem, the better your chances of getting help.

 

 

Sorry for not including enough info. I know what you mean about that possibly being the error message, but I'm not so sure. Here's an example of what happens when I use the hotkey in TextEdit.

 2
 .



 2
 .



 2
 .
myemail@something.com

Other times it never gets to the email address and just prints more 2's and periods. Other times it outputs the email address multiple times:

2.



 2.



 2.



 2.



 2.



 2.
myemail@test.commyemail@test.commyemail@test.commyemail@test.commyemail@test.commyemail@test.commyemail@test.com

Today it is 2's and periods, but it's often a different letter or number or punctuation mark. But just one or two characters and lots of new lines.

Is there any other information I could submit that would be useful?

Link to comment

How are you activating the scripts?
 
If you're using Hotkeys, remember that if you've still got your fingers on modifier keys when you tell System Events to keystroke ..., it won't work as expected.
 
That is to say, if you use, say, ⌘+E to run a script that calls keystroke "v", if you've still got your finger on ⌘, that will become ⌘+V, i.e. Paste.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...