Jump to content

Recommended Posts

Hi,

 

My Mac keyboard is not working so well unfortunately as I spilt coffee on it. As a result, I can't invoke the "greater/lower than" keys (i.e. `<` and `>`), and I need them badly as I write a lot of HTML code. Is there a way to simulate a keystroke using Alfred's Workflow? For example, I'd love to configure a hotkey that will result in printing the `<` symbol, for example.

 

Thanks.

Share this post


Link to post

You could do that with AppleScript :)

 

tell application "System Events" to keystroke "<"

 

Or change it to ">" for the other end of course.

 

You could create a workflow that uses a hotkey or a keyword to action that AppleScript. Should work great.

Share this post


Link to post

Thanks David, but I couldn't make it work. I'm an Alfred workflows newbie so I guess I didn't do it right: I used "Actions -> Run NSAppleScript" and I copied the exact command there, but it doesn't work. Any idea? Thanks!

Share this post


Link to post

Thanks David, but I couldn't make it work. I'm an Alfred workflows newbie so I guess I didn't do it right: I used "Actions -> Run NSAppleScript" and I copied the exact command there, but it doesn't work. Any idea? Thanks!

 

Oh man, my bad. Sorry, I should have been a little more specific. When using an NSAppleScript module, you need wrap your code like this:

on alfred_script(q)
   tell application "System Events" to keystroke "<"
end alfred_script

 

You don't have to wrap the text if you use a Run Script module and just set the language to be /usr/bin/osascript

 

Ping back and let me know that you got things going :) Sorry again for the confusion

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...