How to trigger a KM macro only in google sheets?

I want to have a KM macro triggered only when I'm in google sheets, for example in the chrome browser.

I already know how to trigger only when an application like Chrome is running, but google sheets is an application within an application so I'm confused.

I don't think your question is clear. If you have google sheets open, do you want the macro triggering constantly, like 100 times per second? That's the way you worded it. So I don't think that's what you want.

I presume what you really want is for KM to be able to detect whether the currently open tab in chrome is actually in a google sheets page. That may be possible. But is that what you want? I might be wrong.

I want to be able to detect if the currently open tab in chrome is in a google sheets page and only trigger the macro under that condition.

The macro I want to trigger has no need for automatically repeating

You could try using the Focused Window trigger in a Chrome-only group with an if-statement that checks whether or not the window title is/contains Google Sheets (or however the tab/window name for it is called, I'm not certain because I don't use Google products).

1 Like

You are still confusing the idea of "detecting" with "triggering". Based on what you just said, you only want it to function ONCE. You didn't say how often you want the macro to "detect" the change.

I'm fairly sure you want it to run more than once. But how often? Do you want it running in an infinite loop? Or do you want a hotkey to trigger it? I can't write a solution until I know what you want.

Hemicyon just made a suggestion that is based on a trigger that occurs only when the window changes. Maybe that's what you want. He might be right, maybe that's what you want.

@hemicyon Your response led me a solution -- thank you. Apparently all Google Sheets tabs contain "Google Sheets" and this is called the "title"; in any event, my KM macro only executes when I'm in Google Sheets

Here is the macro I came up to solve my problem with for anyone interested. Sometimes it's the simple ones that make life easier.

Ah yes, it was a hotkey that you wanted for a trigger, and you were looking for a way to detect if google sheets was open.