Jump to content

Search for pasted {query} in any App (i.e. ClickUp, Asana, etc.)


Recommended Posts

Hey guys, I just don't know what I'm doing wrong here. Please have a look at the screenshot attached.

 

I'm trying to open the website (that works just fine) and there I'd like the script to hit CMD+K (to open the search bar) and then CMD+V to paste the query I copied earlier. Well, NONE of my script actually does ANYTHING. The query doesn't go to the clipboard and the system events don't hit any shortcuts.

 

I'd appreciate some help. I'm sure for a Pro, this is just a tiny hint to give me a hand.

 

Thanks a lot!! 🤓

 

tell application "System Events"
    set {query} to the clipboard as string
    delay 10
    keystroke "k" using {command down}
    keystroke "v" using {command down}
end tell

 

889049194_ScreenShot2022-03-11at10_16_17.thumb.jpg.5f142a22bc3cd195e5c2f9c75afa073d.jpg

Edited by Tobi from Munich
Link to comment

The way you’ve organised your screenshot is interesting and clear. But for future reports, it’s best if you upload the Workflow somewhere and provide a link. That’s less work for you and is more helpful to anyone helping. Doing both is even better, but if you can only do one pick sharing the Workflow because that allows us to try it in context.

 

On with the problem.

 

4 hours ago, Tobi from Munich said:
set {query} to the clipboard as string

 

You’re conflating Alfred features with AppleScript code. {query} doesn’t come into play here because you’re (correctly) using with input as argv. The though process is reversed: that code is to store the clipboard contents into a variable, not make the given argument become the clipboard contents. Long story short, get rid of that line as it’s not doing anything.


Another likely problem is that despite you having a large delay at the top, you don’t have any between the two keyboard shortcuts. That’s part of the perils of GUI automation, you always need to ensure everything has waited enough time. Try:

 

tell application "System Events"
    delay 10
    keystroke "k" using {command down}
    delay 5
    keystroke "v" using {command down}
end tell

 

And adjust the second delay accordingly. Or better yet, use Alfred’s native objects: Delay Utility (wait) → Dispatch Key Combo Output (press shortcut) → Delay Utility (wait again) → Copy to Clipboard Output (paste)

Link to comment
1 hour ago, Tobi from Munich said:

doesn't do a thing within the browser. Literally nothing, no key is pressed.

 

Are you sure ⌘K is the right shortcut and that doing it manually results in the desired behaviour? I don’t use ClickUp so I can’t go through all steps but everything looks to be working.

 

Do note that the second Copy to Clipboard needs to have {clipboard}, not {query}, because otherwise you’re copying the passed website address.

Link to comment
1 hour ago, vitor said:

 

Are you sure ⌘K is the right shortcut and that doing it manually results in the desired behaviour? I don’t use ClickUp so I can’t go through all steps but everything looks to be working.

 

Do note that the second Copy to Clipboard needs to have {clipboard}, not {query}, because otherwise you’re copying the passed website address.

 

I tried it with ⌘Q (quit) or ⌘W (close window). Neither of these work either.

Thanks, I replaced the second Copy to Clipboard to have {clipboard}, instead of {query}.

 

Any other ideas? Are you sure it can't be anything about permissions or else? Where do I go from here?

Link to comment
Posted (edited)
16 minutes ago, Tobi from Munich said:

Any other ideas? Are you sure it can't be anything about permissions or else? Where do I go from here?

 

For any poor crusader running into the same issue. Here is the → solution 😉 :

  

On 7/9/2020 at 4:24 PM, Vero said:

There's likely been some corruption in macOS establishing whether Alfred has the necessary permissions. Removing and resetting this permission should take care of it :)

Edited by Tobi from Munich
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...