Jump to content

Recommended Posts



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.



Link to comment

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.

Link to comment

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

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...