Unable to Get A Value For %SafariURL% Text Token

I am using this but it is not getting the url. The Year of Birth is just to help me know the macro is running.

Hi @RogerW - it's not working because %SafarURL% is a KM token and not a field on a webpage.

Try using it like this in a Set Variable to Text action:
KM 0 2021-11-22_15-39-13

Thanks but I am still having a problem.I notice that in my insert token there is a small box at the right with the letter T where your's dose not have this.

I use the Safari Document URL it that the correct one?

I use the Thanks

KM Version: 10.0.1, Mac OSX: 11.6 (20G165)


KM Version: 10.0.1, Mac OSX: 11.6 (20G165)

Hi @RogerW - you know Safari has to be running and showing a web page, right, because it looks to me like maybe it isn’t? (At the bottom of your action only empty is showing whereas on mine an actual URL is displayed.)

You were editing your post as I was replying. I don’t know why yours has a T and mine doesn’t. As for the actual token, there is only one %SafariURL% as far as I know…

Yes I have the same web page you have showing in the Safari browser and it is the only page open.

The macro runs. I have quit and restarted the editor and also quit and restarted the engine.

I will try re-starting the computer.

That's because your cursor is in that field and it's active; if you click out of it the "T" disappears.

1 Like

OK - but just in case here's my macro for you to try. (It works fine here...)

Test Safari URL.kmmacros (2.3 KB)

KM 0 2021-11-22_16-35-41

Well the restart did no good. I downloaded you macro and it gives me the same results. It dose not work either.

So it has to be something on my end? But I am not sure what.

I think I will have lunch and take a nape maybe it that will cause some bells to ring???

Are you running the same version of OS and KM?

KM Version: 10.0.1, Mac OSX: 11.6 (20G165)

KM 10.0.1, but I'm on Mojave...

If when you try later you're still having a problem, it would be worth asking Peter Lewis.

EDIT: searched the forum and found another user having a similar problem and who found a solution. Check this out:

Well I shut the computer down and took a nap. Came back fired it back up and tried the macro and it still did not work.

In looking at the previous suggestion it is for a earlier version of the mac OS and I am a little skeptical about trying to do those kind of changes.

Any other suggestions from anyone?

Thanks for the suggestions and help.


KM Version: 10.0.1, Mac OSX: 11.6 (20G165)

Ok - well, I’ve run out of suggestions so I wonder - @ccstone any ideas?

I'm not sure if it matters, but in case it may help, have you allowed javascript:


Also, a side note, unless you want it to be restricted to Safari, I generally prefer FrontBrowserURL. I later found myself need to switch between browsers and had to change all SafariURL to FrontBrowserURL. The advantage of FrontBrowserURL can also allow us to test the token. If it works with, say, Chrome, but failed on Safari, chances are that the issue is not with the token or the macro or KM but with Safari.



I think @martin has proposed the most likely issue.


OK Based on Martin's suggestions I have checked the JavaScript and it had Allow JavaScript from AppleEvents checked. I also changed to use FrontBrowserURL.

None of this helped with Safari as it still did not work.

I then changed to the Google Chrome and it works. But It did ask me for some permission to allow Keyboard Maestro to access which I allowed.

Now I just need to know what to do to Safari to make it work?


Well, crud...

What does it say in the Keyboard Maestro Engine log when you run the macro?

The last entry

Hey @RogerW,

Run this, and see if it works.


Safari ⇢ Test JavaScript via Apple Events v1.00.kmmacros (6.6 KB)
Keyboard Maestro Export


It did not run initially but in looking at the log I had a the following error

Not authorized to send Apple events to Safari. (-2700)

Looked this error up on the internet and found the solution.

The check boxes for Keyboard Maestro editor or engine were not all checked. When I checked them then stopped and restarted the Keyboard Maestro engine and editor it now works great. My macro also runs,

Thanks Chris I vote you the number one bug killer and award you the golden bug swatter award.. :trophy: :1st_place_medal:

I also want to thank all of the others who helped. I got a lot of suggestions which I learned a lot from being just a new beginner.

I am sure I shall return with more questions. I have now been using Keyboard Maestro for just 2 weeks and have purchased the application.




How can I run this window?