Trigger by noticing a web page sound? Click on an image that might be on two different monitors?

Two things I'm interested in here.

  1. To start a macro by a certain sound? I have a page that refreshes and makes a sound whenever a certain thing happens. is it possible to listen for the sound and run the macro if that sound plays? The sound is the same every time. my volume on the speaker might change but thats it.

  2. I have 2 seperate macros. For some reason and this took me a long time to figure out, the macro clicks on something. this something is known based on an image that i provide. But the image I provide only clicks on my mac if the image is a screenshot taken on the mac screen. the same window when shown on my iPad doesn't work unless I take a screenshot (on my mac) of the iPad screen when airplaying to the iPad. That said, I want to use a single keyboard shortcut for them both. In order to do this, when Im using the iPad, I must enable the iPad version, when Im not using the ipad, I must disable the iPad shortcut and enable the mac shortcut. Is there anyway to automate this so that when I hook up screen mirroring to iPad, it can automatically enable the iPad macro and disable the mac macro. and vice versa? I usually hook this up using USB connection, so if its only possible to automate this when hooking up device to usb thats fine as well (as long as its specifically the iPad device)

I don't know about the first issue, but you can work around the second issue using a conditional that has both images in it—twice. It's kind of a pain, but it works—I used a version of this to handle finding the green button which can appear differently in certain types of windows. In pseudo code, it works like this:

  1. If [any screen] contains [image from Mac] then
  2. Move/click at found image [image from Mac]
  3. Do any other actions needed on Mac screen
  4. Otherwise
  5. If [any screen] contains [image from iPad] then
  6. Move/click at found image [image from iPad]
  7. Do any other actions needed on iPad screen
  8. Otherwise error: No matching image found

Note: [Any screen] could be front window, or any of the other conditions for Found Image.

Let me know if you need more details, but that's the structure I used to make it work for me.

-rob.

KM does not have a sound level trigger, but something should be possible. For example, it is theoretically possible to monitor the sound level via the command line (and, therefore, KM's Execute a shell script action) – however it would take quite a lot of setting up, and I also doubt that it would be the best approach to your problem.

I have a page

A page in what?

that refreshes

Is it a Web page? What causes it to refresh? Does it perhaps refresh automatically, regularly?

and makes a sound whenever a certain thing happens

If the thing is certain, certainly you should be able to tell us more. :wink: There may well be an answer, but we will need more details.

True, but a "volume trigger" is possible (although the person asking about this may not want this approach.) I have achieved volume triggers in two separate ways. First, the volume level is visible in the System Settings program and the Find Image action can "see" the volume level. That's a simple solution, but if you don't like System Settings being visible, you can also do it in the background with Audio Hijack, which is a very powerful program that can "create a new file in a folder" if the volume of a specific app exceeds a certain level after a certain period of not being at that level. I think both of these approaches have been documented on this website.

1 Like

I dimly remembered relevant discussion here in the past (I might even have contributed to it? :laughing:) but I didn't comb the forum for it because I currently doubt that detecting a sound made within the Mac and routing it to something that could detect it is going to be the best approach. But we'll see, once we have more information!

The idea of visually checking onscreen metering occurred to me but it all seemed to be going a bit Heath Robinson / Wilf Lunn down that route :wink:

I use Audio Hijack every day but wasn't aware of the threshold trigger you mention – that's interesting. Well, I've never actually needed that functionality but I shall certainly investigate further, for whenever I might..!

Also I expect you know that a sister application to Audio Hijack, SoundSource, can provide menubar meters for the sound coming from the specific application. Anyway this is now surely off-topic. :slight_smile:

See How to Implement Voice Control/Triggers for KM Macros.

It is better to ask each question separately when they are completely unrelated, so that the topic title can be more descriptive.

2 Likes

But the sound is being made by an application, not via a microphone, so routing of the audio would be needed. Ultimately, triggering a macro as stipulated by the OP would be doable but, I still suspect, probably not optimal.

@NeedzHelp, please see what the Forum page of the Wiki explains about the "XY Problem", to understand why giving us more information may help you achieve your underlying aim. Frankly, I don't think question 1 can be discussed profitably till then.

Not following you here. No app required. The Keyboard Maestro macro is triggered by your voice via Dictation. I've tried it msyelf as an experiment and it works.

I don't doubt it, but try it with the sound from an (unspecified) application, as requested by the OP, instead of by voice. Turn up the volume, but beware acoustic feedback. Then find a way for the macro to trigger not only from sound from the Mac, but from one particular application. That will highlight why the challenge is not the same as for dictation or other voice activation, and we can then move to Plan B...

... Route the sound from the application (but only for one page?) within the Mac (for example with the utility Blackhole) and... or... and we could also... and so on... But do we need to? We shall perhaps find out in due course.

Ah, missed the requirement for the sound coming from an app. If the app is a browser, I'd hunt through the source for a trigger instead of waiting for the sound itself to play.

Again, we shouldn't have to guess, and it probably won't help to do so – eager beavers though we are!

Thanks. Your suggestion worked. took me a while to figure it out as the menu options are a bit confusing (to me). But playing around I got it work with both screens

Its a browser plugin. Distill.io which refreshes an internet page and looks for specified changes. once the change occurs, it shows me that there is a change and simultaneously plays a sound to alert me that a change happened.

The page refreshes at whatever interval i specify. usually every 5 seconds.

Not a user, but I notice it can "notify" via webhooks. You might be able to subvert those and run a KM macro instead by using one of the URLs listed in your macro's "Or by URL:" trigger:

I'd try the "Slack" option and rely on the fact that the parameter part of the URL will be ignored by a parameterless KM macro. So something like:

image