Back to specific specific URL already opened in Safari

pgAdmin creates a page with the URL: http://127.0.0.1:52587/browser/

Can I create a macro to go to that page if it opened?

Use case is that this page is often used while working with a database and it gets lost in the tabs.

Or maybe another way to go about this. Thanks for any suggestions.

Do you mean it opens in another tab and you want to activate the tab with that page?

I'm not quite clear on what you're asking, but I want to go the that tab (URL=http://127.0.0.1:52587/browser/) and display it (of course if the URL isn't opened, then need some error checking). BTW, the tab is named 'pgAdmin 4' if that helps.

I don't really get how this works. The URL is opened by an app pgAdmin 4, but the app's only interface is via the URL. The app is (also) creating a connection to the Postgres databases stored somewhere on my computer.

We still don't completely understand each other, but based on what you are saying I just wrote a macro that looks for the the existing tab (in safari) with the word "youtube" in the title and displays it. You could replace Youtube by "127.0.0.1" if I understand your problem correctly, which I'm not sure I do.

There's probably better ways to solve this problem than that, but for the moment I just want to know if this code does what you want. That is, this code looks for the tab containing a string and switches to it.

I apologize if I don't understand correctly. This is an attempt to understand the problem.

I think a screenshot would be helpful here. That's because there are different types of tabs. There are tabs at the top of a web browser, and tabs inside the web page itself. I'll bet that's where the communication problem lays here.

Safari tabs. Not webpage tabs.

I tried the script. Maybe I typo'ed but I went right by the page in an endless loop. So need some error checking (which I would need if the page isn't opened anyway).

I won't if the "typo" is that when I copy the url from Safari to KM http:// is added but Safari doesn't show that (at least in my setup). Doesn't matter.

Just realized I don't have the Group. What's that for?


Thank you.

Sorry, the Group action does nothing, other than make it easier for me to take a screenshot.

Your screenshot shows the wrong key in the TYPE action box. But that's not really your fault because I accidentally left that TYPE action in there when it shouldn't have been there at all. Sorry, again. it doesn't actually break the macro, it just made it messy.

If it still doesn't work after you remove that action, it's probably one of two things:

  1. The string you are using, "127.0.0.1:52587/browser/" is incorrect, or
  2. The pause statement needs to be larger.

I think the mistake is your string because in your screenshot I do not see 52587 I see 61468. This is part of the reason I asked you to search for the string "127.0.0.1". But you added 15 extra characters. Try it my way, using "127.0.0.1", to make it easier to debug this.

There are some wizards on this forum that can answer most questions like this using AppleScript. But I'm not that skilled yet. If for any reason my solution doesn't work for you, we can press one of them for an AppleScript solution.

That does it. Thank you @Sleepy.

I hadn't noticed that the number changes. Lucky I had to restart it, so that error became apparent.

I removed the type action, but I use Cmd-Shift-Right Arrow to cycle through the tabs. Tab goes to any field that text can be entered in on the page. Control-Shift-tab works. I found that out looking for where I'd implemented Cmd-Shift-Right arrow. Of course when you're writing as I'm doing now in this textbox, some of the commands don't work.

Thanks again. I'll have to see how fast I can make it.

Final solution for anyone trying to figure this out. Although I need add error checking in case I start the macro without having the 127.0.0.1 opened. I had to quit KM engine to stop it. I assume I can wrap it in a until and stop after say 15 tabs:

It may be possible to avoid a pause statement if you simply compare successive tabs to make sure they are different. Once they are different you know you are on a new tab (rather than a pause statement). I didn't write the code to do that because that would have greatly complicated the issue for the moment. Do you see how it's possible to do this? Or maybe it's just not very important to gain another 5% speed and reliability.