KM Won't Open a (Bare) Local IP Address in Web Browser

I am somewhat of a newbie here. Anyhow I created a very simple (at least I though) macro to open a local IP address in Safari (I get the same error in Chrome). I want to have a hot key to open my Synology Disk Station on my network. If I go to Safari and simply type in the address it works fine, but if I tell KM to do it I get the message, "Safari can't open "192.168.4.223" because the first part of its address is not valid." What am I doing wrong????

Thanks

Jimmy

1 Like

Is your browser inserting the missing http:// for you? They tend to do that. KM probably isn’t.

3 Likes

Thanks! That was it. I appreciate the help.

Jimmy

1 Like

You’re very welcome. It’s not instinctive that your browser would help you like this.

I wonder if KM could invoke Safari in a way that would cause Safari to treat it like an address pasted in.

Hey Martin,

Sure you can, if you brute-force the UI.

But you can't if you use the Safari Actions in Keyboard Maestro – or via AppleScript which they use behind-the-scenes.

Try for yourself:

tell application "Safari"
   set URL of front document to "192.168.4.223"
end tell
tell application "Safari"
   set URL of front document to "http://192.168.4.223"
end tell

-Chris

1 Like

Thanks. And as my browser of choice - especially for HTML 5 Canvas support - is Firefox I might well go this AppleScript route in my applications.

Hey Martin,

Firefox as you know has no app-specific AppleScript support. It only supports the standard AppleScript suite, which allows you to do things like get/set the bounds of the front window.

tell application "Firefox"
   set frontWindowBounds to bounds of front window
end tell

But you can't perform any browser functions.

I think maybe there are some command line switches that can be used when activating from the shell, but it's been too long since I researched that.

You can do something like this though:

tell application "Firefox"
   open location "http://192.168.4.223"
end tell

This by itself would open the URL in the default browser:

open location "http://192.168.4.223"

By telling a specific browser you can override the default.

-Chris

Cmd+L would be my friend. :slight_smile:

1 Like