Can't get KM to execute javascript, however when JS code is put into the console, javascript is executed

The above are my settings I have. The code is for stackoverflow, and here I'll just post a random thread: https://stackoverflow.com/questions/33005388/how-to-invoke-safaris-search-method-by-send-hot-key-from-javascript

I want it so that whenever I press “\”, KM will execute the code inputted which will press on the "Post Your Answer Button". Whenever I press “\” though, nothing happens, nor does anything is put in the console. When I copy the JS and paste it into the console, it gets executed and does what it's supposed to do.

Any help?

If nothing is happening, then try the Assistance window (Help ➤ Assistance) and click the Something expected is not happening link.

I followed your directions, and the window said everything is fine. I tested the macro and it said it triggered.

I tested the macro in Chrome and nothing happened, and I checked the console and nothing was inputted.

Is it being triggered when you are in Chrome?

If not, you need to resolve that. If so, then the problem is with the actions.

Next thing is to change the “ignore results” to display results in a text window so you can see what results the JavaScript is getting.

Also add a notification action of some kind to the start to verify the macro is actually executing - something like Speak Text would work.

I’ve resolved the problem somehow, I was trying to activate the JS through KM today and it worked, I don’t know what the cause of it was if I find out though I’ll edit my main post with the solution. Thanks for the help nevertheless.

I am stuck with the same issue. I am trying to run the code below using Keyboard Maestro, but the macro does not respond.

document.querySelector("input[value='Add']").click();

When I use this code on Google Chrome's console though, it works fine.

I chose Display results in large as well, but that does not respond anything either. Unsure what might be happening here.


I also used the Assistance window and everything looks to be fine there.

I am on macOS 10.14.1 - Mac OS Mojave with Google Chrome Version 70.0.3538.77 (Official Build) (64-bit) if that helps.

Hey Arun,

It's pretty much impossible to help without having access to the page your working with.

Although you might scope this out the bottom of this thread:

Bug? Execute Javascript in browser

-Chris