How Do I Search URL of All Safari Tabs and Make Found Tab Frontmost?

The below Macro provides an example of how to do this.

This seems like a contradiction in terms to me.

  • CMD-Y would trigger the macro
  • But then you need a Prompt to receive the typed string "maestro"
  • And then "press enter" would close the prompt and continue execution of the macro.

So, it being unclear as to what you actually want, I have provided a macro that will work with either a Typed String trigger, or with a HotKey Trigger.
Remember that if you use a Typed String Trigger, you MUST type it into a document or text area that accepts text entry.

The "Prompt for User Input" is required if you use a HotKey Trigger, but not if you use a typed string trigger.

Using the Prompt has the advantage of remembering your last search string.

Below is just an example written in response to your request. You will need to use as an example and/or change to meet your workflow automation needs.

Please let us know if it meets your needs.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

MACRO:   Search Safari for Text in URL [Example]

**Requires: KM 8.2.4+   macOS 10.11 (El Capitan)+**
(Macro was written & tested using KM 9.0+ on macOS 10.14.5 (Mojave))

#### DOWNLOAD Macro File:
<a class="attachment" href="/uploads/default/original/3X/a/1/a17527c86b327af7a75c8e977c06076d2d0f07dc.kmmacros">Search Safari for Text in URL [Example].kmmacros</a>
**Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.**

This macro was also uploaded with a typed string trigger (between the quotes):
"`;sf\.[^ ]+ ` "
Note the SPACE at the end.

So, to search for text in the URL, you would enter, for example:
`;sf.TextToFind `

You can change the "sf" to any other characters you want, except for a PERIOD and SPACE.

---

### ReleaseNotes

Macro Author:  @JMichaelTX

This is just an example written in response to the below KM Forum Topic.  You will need to use as an example and/or change to meet your workflow automation needs.


**MACRO SETUP**

* **Carefully review the Release Notes and the Macro Actions**
  * Make sure you understand what the Macro will do.  
  * You are responsible for running the Macro, not me.

**==USE AT YOUR OWN RISK==**

* While I have given this a modest amount of testing, and to the best of my knowledge will do no harm, I cannot guarantee it.
* If you have any doubts or questions:
  * **Ask first**
  * Turn on the KM Debugger from the KM Status Menu, and step through the macro, making sure you understand what it is doing with each Action.

`~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`

Topic Title:	Save in variable the typed string

URL:  https://forum.keyboardmaestro.com/t/save-in-variable-the-typed-string/16929

Post Date:  2020-02-09
Posted By:  gginer

I'm trying to make a simple macro to search between Safari Tabs. I have everything working from different pieces of codes I found around the forum and I managed to create a user input form that asks for a portion of the domain name it needs to look for from the Safari tabs.
`~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`

<img src="/uploads/default/original/3X/6/6/66eb31ec08dad2f9e31c128efcab4e2e0cf0288f.png" width="603" height="1366">
2 Likes