"Open in background" in gear menu of Open URL Action not working

https://wiki.keyboardmaestro.com/action/Open_a_URL

This apparently came out in 9.0 and I tried to turn it on but it didn't work, is this true for anyone else?

Didn't work how, exactly? If I use the action to open a URL with Chrome, it brings Chrome to the front whether or not the action is set to open in the background, but if I use it with Safari, it seems to work as expected.

I tried it on chrome, safari, default application, setting default browser to either, all didn't work. By didn't work I mean it didn't open in the background, it brought me right to the url.

I see. It looks like there's a bit of misunderstanding here caused by identical terms in similar but slightly different contexts. The background function of the Open a URL action isn't meant to open the tab in the background, but the browser application itself (and it evidently doesn't even do that with Chrome, but I'll chalk that up to Chrome's oddities). If you want to open background tabs, Safari lets you do that with AppleScript, but Chrome doesn't seem to, so the next best thing is to save the current tab's index and re-select it once the URL(s) have been opened:

Keyboard Maestro Actions.kmactions (1.2 KB)
image

(It says Brave Browser in the image instead of Chrome because I've configured KM to use that for all Chrome-related actions, but it should still show up as Chrome for you when you import these actions)

I see. It looks like there's a bit of misunderstanding here caused by identical terms in similar but slightly different contexts.

Thanks, That makes a lot of sense. This question is related to the opening 25 tabs at a time question that I asked you earlier. While I have you here I was curious if you had an opinion on whether either of the solutions I'm about to propose make more sense.

I'm building out a macro to perform actions on 900 tabs all automated, closing each one after it's been worked. Using the macro you provided above I could start with a few tabs, and after performing the actions on each tab, close it, open a new one and repeat until finished. Or I could start with ~25 go through all of them, and open a new 25 at a time. Is either of these better than the other in the scope of being more efficient or easier on the CPU?

I'm afraid I don't know enough about the technical underpinnings to definitively say which of those would be more efficient, but if you're only going to be working with one tab at a time regardless, I'd say it's worth starting with small batches of tab rather than batches of 25 and see how well that works. CPU-wise I'm sure any computer from the last decade can easily handle that many tabs, but thinking about memory usage and network I/O, a few at a time are probably going to let the computer perform more consistently. Then again, if the pages you're opening are mostly text based and lightweight, that may not be a concern at all. Like so many things, it depends on the particulars of the situation :slightly_smiling_face:

CPU-wise I'm sure any computer from the last decade can easily handle that many tabs

So just to understand you do you think a computer could have trouble going through 900 tabs even if there's only a few tabs open at a given time?

As long as you're only working with a few open tabs at a time, I'm sure it would be fine. If you're trying to work with all 900 at once, though…that, I'd be less sure about.

Great! Thanks so much for all your help

If you're trying to work with all 900 at once, though…that, I'd be less sure about.

I'll make sure not to find out :grin:

1 Like

There are plenty of web pages on the internet that cause Safari to tell me "this page is using too many resources, please close it." Or something like that. When I've tried to open a dozen pages from websites which have this problem, Safari generally crashes or hangs up. So yes there are lots of bad pages out there.

I would just use one window with one tab, and change the URL when ready to process the next one.

I see no advantage in opening more than one tab at a time.

What are you doing on each URL page? Scraping data, or filling in a form?
If scraping data you may be better of using one of these tools:

  • macOS Command line curl, followed by RegEx to extract the data
  • python -- never used it, but it is often cited as one of the best web-scraping tools

JavaScript in Browser is my tool-of-choice these days, and is quite powerful. The biggest downside is that you have to use a Browser, and you have to make sure the page is loaded before you use the JSinB.

@JMichaelTX Do you just use wait for browser to finish loading? It's what I use but I'd love to speed some macros up that use it. I fear my only options are reducing reliability or getting a faster internet connection :frowning:

Edit: Early morning brain was probably being too optimistic and hoping for something that doesn't exist.

I don't think that the "Wait for Safari to Finish Loading" macro works properly anymore. Read this about it:

It's technically an impossible task to know when a web page is finished loading anyway. In fact some pages on the internet literally NEVER finish loading. If you scroll down they just keep growing. Forever. I would even opine that any web page which has auto-refresh also never finishes loading. And most websites that I access have auto-refresh.

So ultimately you have to decide when a page is finished loading. If you tell us which page you are trying to load, we might be able to tell you for that page how to tell when it's finished loading. And in that case your macros could be sped up because they could start once the page has finished loading.

@Sleepy. Wait for Safari to finish loading has been fixed in 9.0+. I use front browser actions predominantly with Brave so it's a moot point for me. Plenty of different pages, I think I'm just hoping for something that can't exist now that I think about it for longer than a second. Anyway, this is getting off topic

No, I do not just wait for the browser to appear to finish loading.
I use this:

MACRO: Pause Until Web Page Element Exists [Example]

Works very well.

1 Like

Even if that's true, my statement remains true when I said "It's technically an impossible task to know when a web page is finished loading". And "ultimately you have to decide when a page is finished loading." JM offered an extremely great possible solution. Thanks JM, I didn't know about that.