Buttons Not Recognized? "Press Button" and "Pause Until ... A Button With This Name ... Is Enabled" Not Working

Hi there!

In this post I actually talk about not one, but three problems I am currently having with a macro. They are all somehow related, so I don't think it makes sense to create separate topics.

I am trying to create a macro that mounts my NAS. It activates Finder and opens a new window with Cmd+N, then hits Cmd+K to activate the "Connect to server..." menu entry. A new window opens where I could enter the IP of my NAS. Since it is already in there from previous connections I just let the macro hit the Return key. Up until here, everything works fine.

The connection process to the NAS itself however sometimes is instantanous (if the HDD is already running) or takes quite some time. When it is done, a new window appears where I can choose a folder to mount, along with "Cancel" and "OK" buttons.

(See German screenshot here)

To wait for that window to appear I'd prefer not to include a fixed pause of, say, 20 seconds to actually hit Return again to mount the highlighted folder. Because then I would need to wait 20 seconds every time - even if the NAS connected immediately.

Problem #1:
Instead I tried the "Pause Until Conditions are Met" action with "Pause until ... A button: with this name" - OK - "is enabled."

It doesn't work. According to the debugger this statement never gets true, although I clearly see that window appear, featuring that OK button.

Problem #2:
So I exchanged the "Pause until" for a fixed "Pause for 20 seconds" action and added a "Press the button named: OK" action after this. The pause works, but the macro is cancelled, because it failed to find the "OK" button.

Seems to me that both problems have the same cause: The OK button isn't being recognized.

So I resorted to the "Click at Found Image" action using this image:

Bildschirmfoto 2020-11-21 um 21.36.05

Problem #3:
In normal "Bright Mode", this works. It doesn't work in Dark Mode, however. I figured, this is because of the light grey surroundings next to the button. I then made a new screenshot, closer now, without any surroundings, figuring this piece would look identical in both bright and dark mode:

Bildschirmfoto 2020-11-21 um 21.39.42

Well, when you compare the colors, you already see: They don't match. And of course, it again doesn't work.

I am out of ideas. Does anyone else have one?

Thanks!

Hi @MrAxellency, I know the problem too. There are windows where the buttons are not recognized by KM.
But I never use "Pause Until - is Enable - OK" but "Pause Until - Exists". I have made better experiences with this.

Please try to include this action in your macro:

NAS : OK <4734 201121T223530>.kmmacros (56,9 KB)

NAS : OK <4734 201121T223530>

PS: I also use a german speaking macOS

Greetings from Frankfurt :wink:

Thank you, @appleianer - that worked! It solved problems #1 and #2. Obviously this would still only work in bright OR dark mode, depending on the mode that was active when creating the screenshots.

I now used an if-then-else statement to check whether bright or dark mode is active and then have the same actions in both the then and the else tree, just with differing screenshots. That works now, too. :slight_smile:

1 Like

I am glad to hear that it works for you @MrAxellency :+1:

Alternatively, in the "Pause Until" action you can also insert your screenshot for the dark (1) as well as the light (2) mode and make the selection (red arrow) that one of the conditions must be met.

Great hint, thanks!

1 Like