I want to search Apple News with text that I selected on the frontmost window. This is for paywalled articles on the web that are available on Apple News. (The Atlantic, WSJ, etc.) This macro sometimes works and somtimes doesn't. Thoughts?
Without knowing how it sometimes works and sometimes doesn't, it's difficult to guess.
But -- and possibly a hint -- what does the ⌃A do in this context?
And you don't need the pauses after the first "Copy" action -- are they meant to come after the "Activate News", to give time for the window to become active before you "Find"?
What the ⌃A does is select the previous text that is already in the search box on News. Your macro works great it seems but it concatenates the selected text onto the existing text in the search box. I inserted the ⌃A back into the macro and now it works fine. Thanks!
Normally that's ⌘A, so I was wondering if it was a typo or something special.
As @griffman said (and accounted for in his macro above), you don't usually have to select text -- the "Find" command should activate the Find text field with an contents already selected. Typing ⌃A breaks that behaviour, moving the insertion point to the beginning of the text.
Maybe you've some other customisations going on? Helping could be difficult without knowing what they are, so hopefully you've got something that works now!
Sorry, I typed ctrl-A but actually inserted cmd-A. I take your point about cmd-F normally selecting the existing text in the search box but on my computer, it doesn’t and adds the selected text to the existing text. But anyway, it now works and I thank you for your help.
Your posted macro explicitly shows you were sending a simulated ⌃A:
...which is why I asked about it. That may be why it was sometimes working, sometimes not -- it would be fine if the text box was empty but would fail, prepending your clipboard contents to the existing text, if not.
The Debugger can be useful in situations like this -- you can use it to step through your macro one action at a time and take as long as you need to check what's happening in the UI.