Jump to content

Can we get modifier keys as argument to Script Filter?


Recommended Posts

I am working on a keyboard shortcut cheat sheet workflow that is different than most of the other ones in that the results are listed right in Alfred itself.

 

I can successfully look up shortcuts that I know the name of but I would like to be able to enter a key combination and have it return the shortcut that is attached.

 

It there anyway we can get the equiv of {query} for the state of ctrl, shift, alt, cmd?

 

Thanks

Link to comment

I am working on a keyboard shortcut cheat sheet workflow that is different than most of the other ones in that the results are listed right in Alfred itself.

 

I can successfully look up shortcuts that I know the name of but I would like to be able to enter a key combination and have it return the shortcut that is attached.

 

It there anyway we can get the equiv of {query} for the state of ctrl, shift, alt, cmd?

 

Thanks

 

You can't get the state of them but you can create different script actions based on modifier keys. Is that what you are talking about? For instance, double click on a connection from a keyword or script filter to a script and you should be able to set a modifier key for that action. You can change paths/actions dependent upon the current modifier key.

Link to comment

You can't get the state of them but you can create different script actions based on modifier keys. Is that what you are talking about? For instance, double click on a connection from a keyword or script filter to a script and you should be able to set a modifier key for that action. You can change paths/actions dependent upon the current modifier key.

This workflow doesn't even have any actions. It's just about bringing up a list of items based on search criteria that is entered in Alfred.

So basically, with no arguments it would list all the shortcuts but I want to make it so if I hit shift it will reload the script filter and only show me shortcuts that utilize the shift key.

I realize this functionality currently isn't possible unless you can somehow connect the script filter to another script filter without having to hit enter.

Link to comment

This workflow doesn't even have any actions. It's just about bringing up a list of items based on search criteria that is entered in Alfred.

So basically, with no arguments it would list all the shortcuts but I want to make it so if I hit shift it will reload the script filter and only show me shortcuts that utilize the shift key.

I realize this functionality currently isn't possible unless you can somehow connect the script filter to another script filter without having to hit enter.

 

Well... technically you can't do this but.. if you are ok with having to hit enter, you could somewhat achieve what you are looking for.

 

You could set a script filter that would show the default shortcuts. Then, if you press Shift+Enter, it would go to a script that would run an external trigger to another script filter in the same workflow and show the new shortcuts you want. Would something like that work?

Link to comment

Well... technically you can't do this but.. if you are ok with having to hit enter, you could somewhat achieve what you are looking for.

 

You could set a script filter that would show the default shortcuts. Then, if you press Shift+Enter, it would go to a script that would run an external trigger to another script filter in the same workflow and show the new shortcuts you want. Would something like that work?

 

it doesn't feel like anything will make it a nice experience like you would expect from an apps keyboard shortcut search.

 

thought about some fun ideas though

 

Reading the keyboard state directly from the script filter itself. when you hit F you could potentially detect wether cmd or ctrl is pressed. but it looks like you will not be able to actually enter text in the search field for those cases and you couldn't deal with the arrow,page up,etc keys

 

or find a way to have a live script filter that auto updates based on whatever keys are pressed independent of what is entered in the search field by by calling an external trigger at the end of each script filter execution. (sounds like it could cause a lot of problems though)

 

for future alfred updates, it might be something to think about, where you poll a script and give it control over the search field and allow it to do it's thing independently. give it the ability to add icons to the search field for special keys like arrows.

Link to comment

If you want to do that, you need to parse the info.plist in each installed workflow and grab the relevant modifiers and text.

 
Shawn has done all the work of figuring out which code is which key in his Workflow Help Workflow, so if you dig through the source code of that, you'll be able to see which crazy number means which modifier keys.

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