Find Image on Screen CPU load and how to add timeout to this action?

Hi,ALL
I'm using Find Image on Screen to click thewifi logo and select a said automatically, but I'm having a CPU load trouble with this action. Every time I run this macro, the CPU load gains up about 100% without stoping.
so the question is:

  1. Is there a better way to automatically select the SSID I want to join?(I've tried networksetup from command line, but that didn't work, because it didn't bring up the login windows of the SSID)
  2. Why is the high CPU load not stoping?
  3. Can I add a timeout to this action?


Hi @Boyin_Zou,

Our resident AppleScript guru @ccstone just recently provided an example of how to manipulate the Wi-Fi menu bar item and select the network you want without using any found image actions whatsoever:

As he says in the post, the script that clicks on the Wi-Fi icon is written with an English language system in mind, so you may need to make adjustments for Chinese, but this should certainly help get you on your way.

As for your other questions, the high CPU load is because you are using a lot of different "Find image" actions in your macro, an inherently CPU-intensive process that is made more intensive by searching the entire screen, as you currently have the actions configured. Generally, "Find image" is best used as a last resort when it comes to automation, preferably with its search scope limited by screen area or window (and no, it seems there is, unfortunately, no way to set a timeout for this action).

Thank you very much! I know there should have a better way to do this.
for the Find Image action, does it quit after a certain time or it keeps finding all the time?

No problem! KM's developer, @peternlewis states here: KBM takes up 572% CPU that the function does not execute for very long, and only drives the CPU hard when used continuously, so it shouldn't keep finding all the time. My guess is that your use of multiple "Find Image" actions that scan the entire screen for a small, not incredibly unique image kept the action running long enough that you started seeing the hit to your CPU, so as long as you limit the area KM searches in the future, you should be fine to use it in other macros.

Hey Guys,

Remember too that having the Keyboard Maestro Editor open can under certain circumstances drive processor use up quite a bit.

Although that should show up in the Activity Monitor as the editor and not the engine.

-Chris

Because the search is continuously running. This could be for a number of reasons:

  1. The action is being run multiple times within the macro (eg within a While or Repeat loop).
  2. Pause Until will run the search continuously until the match is found.
  3. The macro itself is being run multiple times.
  4. The editor is displaying a condition that is testing the screen image, and thus asking for engine for the answer continuously to update the action’s “(currently true/false)” displayed state.

For 1&2, check the Cancel sub menu in the Keyboard Maestro status menu to see if a macro is running.

For 3, check the Engine.log file to see if the macro is executing multiple times.

For 4, quit the editor, turn off Edit mode, or deselect the macro (selecting a macro group for example), or undisclosed the actions that search for an image.