If the search bar is empty condition

Hello!

Recently Firefox removed the function I get used to. What is did is: pressing the enter key on the focused search bar with no text goes to my default search provider's homepage.

Is it possible to

1.Click on the search bar field
2. If it's empty, enter loads the specified URL.

I have some vague ideas but nothing I could recommend. Instead I would recommend you try one of the following methods and get used to working in a slightly different way.

  • Add a bookmark to your preferred search engine site.
  • Set the home page to display "custom URLs" and create a link to the site there (Preferences > Home).
  • Create a KM macro to run the Open a URL action (and set the trigger to something more sensible than Return :wink: ).
  • If you use launcher apps such as Alfred, you can trigger a Web search within them.
1 Like

For point 1: Is it you clicking in the address/search bar, or do you want the macro to do that after you trigger it?

If it's the first, it might be possible if you:

  • Have a macro that is always running when Firefox is frontmost
  • Is waiting for an indication that the text field is active -- the best I can think of is image detection on the search settings cogwheel image

If it's the second then that's much easier -- a "Keystroke: ⌘L" will do it.

From then on it's the same for both methods -- "Keystroke: ⌘A" to select everything in the text field, then see if the Copy menu item is available. If it isn't then there was no text in the field, so insert your search engine's address and "Keystroke: ". If Copy is available then there is text in the field, so do whatever is appropriate in that case (you didn't state what in your OP).

You can see that the second method is much easier. If it's the first method you want and you get stuck, just shout out.

1 Like

Image detection occurred to me but personally I didn't want to encourage that line of thought. :laughing: It's often not a robust solution, and what, really, is the problem? There are many convenient ways to trigger a Web search already.

As the KM Wiki says:

"There may be a much better way to solve the actual problem rather than resolving the difficulty with your specific attempt."
Using the Keyboard Maestro Forum

That said, if it is really important to the OP to go to the search engine's page by "pressing the enter key on the focused search bar with no text", I can suggest one close substitute: type a space and then enter.

1 Like

Agreed. Hopefully OP can adjust their habits to using one of those ways -- the "space-Enter" trick is a nice substitute if not.

But if there is a strict requirement for a manual click in the address field and the stated subsequent behaviour, I can't think of another way of doing it.

1 Like

It's the first one. Unfortunately, image detection doesn't work well in this situation.

I am not the one who hates this Firefox decision. Have a look

Of course I can get used to the new behavior as well as to the another browser.

If you are open to using a different browser, that may well be your best solution. Firefox has its positive points still but it is far from being the most "Mac-friendly" of browsers.

1 Like

It's working 100% for me:

image

What's the problem on your side?

The "If, when clicked, the address bar is empty" bit works fine as well. The problem will be if there is text which you then manually delete -- would you be OK pressing Space-Return, as per @kevinb's suggestion, rather than Delete-Return as you've probably done up to now?

1 Like

The problem is just the Firefox doesn't work as before and it can't be fully fixed by macro. Space-Bar+ Enter is not the same as just Enter.
I will get used to it in the end.
Other browsers do not suggest the same functionality anyway.