Jump to content

Prevent Show Alfred with Selected Text from overwriting Clipboard


Recommended Posts

I love the bundled "Show Alfred with Selected Text" workflow, there is only only thing that is really bugging me: whenever I invoke the workflow, the selected text is not only shown in Alfred but also put in the clipboard, which overwrites its previous content.

 

Is there any way to prevent this behavior? I tried editing the workflow, but I only found the plist file with the settings and not the actual code of the workflow.

I consider the current behavior a bug and would be very happy if it got fixed. If I am wrong and the current behavior is by design, would you consider implementing an option for turning off the clipboard overwriting part (or including two workflows, one for each behavior)?

 

Thanks!

Link to comment
  • 5 months later...

I love the bundled "Show Alfred with Selected Text" workflow, there is only only thing that is really bugging me: whenever I invoke the workflow, the selected text is not only shown in Alfred but also put in the clipboard, which overwrites its previous content.

 

Is there any way to prevent this behavior? I tried editing the workflow, but I only found the plist file with the settings and not the actual code of the workflow.

I consider the current behavior a bug and would be very happy if it got fixed. If I am wrong and the current behavior is by design, would you consider implementing an option for turning off the clipboard overwriting part (or including two workflows, one for each behavior)?

 

Thanks!

 

You could make a workflow that has similar functionality and would preserve the clipboard. It WOULD still use the clipboard but would basically save whats in the clipboard, copy whats selected, and send that to Alfred, and then put the original data back in the top position of the clipboard. Or, I guess theoretically you could use the second clipboard for grabbing whats selected

Link to comment

You could make a workflow that has similar functionality and would preserve the clipboard. It WOULD still use the clipboard but would basically save whats in the clipboard, copy whats selected, and send that to Alfred, and then put the original data back in the top position of the clipboard. Or, I guess theoretically you could use the second clipboard for grabbing whats selected

After having thought a bit more about it, I had realized myself that the clipboard overwriting was the actual means for getting the selected text into Alfred and not just a byproduct. Thanks for the explanation and for pointing out possible solutions.

 

Unfortunately, my expertise does not currently go much beyond making simple changes to existing workflows, so I won't be able to create an improved version of this workflow. If someone else feels compelled to do so, it might be worthwhile to also include a check that ensures that the pasting does not happen before the Alfred bar is ready. The current workflow occasionally fails and just shows an empty Alfred bar. As far as I can tell, this primarily happens when the system resources are taxed.

Link to comment

After having thought a bit more about it, I had realized myself that the clipboard overwriting was the actual means for getting the selected text into Alfred and not just a byproduct. Thanks for the explanation and for pointing out possible solutions.

 

Unfortunately, my expertise does not currently go much beyond making simple changes to existing workflows, so I won't be able to create an improved version of this workflow. If someone else feels compelled to do so, it might be worthwhile to also include a check that ensures that the pasting does not happen before the Alfred bar is ready. The current workflow occasionally fails and just shows an empty Alfred bar. As far as I can tell, this primarily happens when the system resources are taxed.

 

Try this

 

Should grab whats in the clipboard, save that, grab the current selection, restore the clipboard, then tell alfred to search for what was selected

Link to comment

Try this

 

Should grab whats in the clipboard, save that, grab the current selection, restore the clipboard, then tell alfred to search for what was selected

Thanks, David, it works as advertised! :)

 

Since I used the original workflow with the "Cursor=left" setting (so that I can enter a keyword before the selected text), I modified the bundled AppleScript in the following way:

set prev to the clipboard

tell application "System Events" to keystroke "c" using command down
delay 0.2
set currSel to " " & the clipboard
set the clipboard to prev

tell application "Alfred 2" to search currSel

tell application "System Events" to keystroke key code 123 using command down

(this adds a space before the selected text and then simulates cmd-left to jump to the beginning of Alfred's search bar)

Link to comment

Thanks, David, it works as advertised! :)

 

Since I used the original workflow with the "Cursor=left" setting (so that I can enter a keyword before the selected text), I modified the bundled AppleScript in the following way:

set prev to the clipboard

tell application "System Events" to keystroke "c" using command down
delay 0.2
set currSel to " " & the clipboard
set the clipboard to prev

tell application "Alfred 2" to search currSel

tell application "System Events" to keystroke key code 123 using command down

(this adds a space before the selected text and then simulates cmd-left to jump to the beginning of Alfred's search bar)

 

Ah cool, gald you like it.

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