Continue macro after user clicks a particular image

For context:
I use an app called EasyFind to find some files Finder can't.
Some protected files, for example files that are set to read-only, when I try to delete them I get this window:
Bug EasyFind

The issue is that when I click Delete, nothing happens. I've already contacted the developer, but his replies are a bit weird (if you want to read the thread), because he says that at the moment EasyFind doesn't allow the deletion of files that require admin password. So my question is: then why the Delete button at all and why asking "Do you want to delete them immediately?" if the button doesn't do what's supposed to do? Go figure...

So my plan is to create a macro that starts running once EasyFind is running and it's always scanning the screen until this window is visible. When it does it will pause the macro and will be waiting for me to click the Delete button (either using the image of the button or if possible, the button itself, if KM can identify it as such).

Then once I click it, it closes that window, presses a certain shortcut I have to Reveal in Finder and then hit Delete so I can be prompted with the password window.

So I guess that the trigger would be this:
Screen Shot 2022-06-20 at 10.34.00 AM
It's not a big problem that it's repeating every second and that it may slow the computer down or something. This is a task I do just once in a while and when I do, I'm just focused on deleting files and I'm not working with other apps, so no big deal.

Now my issue is to find a way to resume the macro once I click the image/button. Is this possible?

If you're using a hotkey to attempt deletion in EasyFind, why not use that to trigger the macro?

Screenshot

Set the Pause until button is enabled action to timeout quite quickly so that only deletions that require confirmation trigger the remainder of the macro.

Also, is there a shortcut or menu item to copy the selected file's path? If so, you might be able to use this to perform the deletion without having to reveal the file.

There's "Pause Until" action, and you can use a "Found Image" condition in it. Using the alert dialog's icon as the image might be good enough -- one problem could be if you moused over the image, that might be enough to cause detection to fail.

So you'd have the macro triggered by EasyFind's launch, use a "While" loop so it keeps running until you quit EasyFind, use a "Pause Until" either the image is found or EasyFind is quit -- and you take further actions depending in which of those is true. I've used a different app (Angry IP Scanner -- grrr!) and the image from your post, so you should change all app references and use a better image, but something like this could work:

EasyFind Delete.kmmacros (59.6 KB)

Summary

Have you got some examples? I usually see this when I've put something somewhere the OS thinks I shouldn't -- which could lead to problems in the long run...

Not all files show this window, just some, so KM doesn't need to be paused/running that macro if there's no window, which is in most cases. But your solution made me think that I can instead use an IF ELSE action. If it finds the button, it automatically runs the other actions. Otherwise it times out after 2 seconds.
Thanks for that tip!

EasyFind - Delete Protected Files
Keyboard Maestro Actions.kmactions (44 KB)

Summary

Keyboard Maestro Export

One that's pretty obvious and it's so annoying is that when you have an audio file that has a name X, but the metadata for Title is Y, Finder looks for the metadata, not the file name. For example:
song.wav with the metadata's title set to "Winter", if you try to find it as Name:song.wav, Finder will not find it, but if you try Name:Winter, it will.

And it actually behaves kinda weird on a regular basis when I try to find normal files, not system files. Sometimes it says there's 0 items, when I have another window with the files right in front of me. Oh well...

But EasyFind finds them, so I tend to use both

Thanks for sharing.
I actually used @noisneil 's approach and it's working now. See my reply above.

Now I'm experiencing something weird. My last action to close the window, doesn't always work. I tried with 2 files. The first time I ran the macro, the Finder's window was automatically closed. The second time for the second file, it did not. Any idea why?

As you know, I try to avoid found images wherever I can. Perhaps this might work more reliably...?

EasyFind Delete.kmmacros (26 KB)

Macro screenshot

1 Like

...also, it's a good idea to do things "programmatically" with KM actions whenever you can -- they're much more robust than GUI scripting with menu clicks etc. So try changing your final action to:

1 Like

Yes, I would too, but my knowledge is still not that deep... but I will eventually get better at it!

Your macro doesn't work for me. It stops at the Revel in Finder action.
Screen Shot 2022-06-20 at 1.29.10 PM

My version works properly, except for the fact that the last action to close Finder's window, doesn't always work. Keeping my macro, do you know how I could fix this?

I've just improved the end conditions, so you should download it again from my previous post.

As I don't have EasyFind, I can't properly set the menu item; I just copied it from your macro screenshot and left it set to Front Application. Replace the Select "Reveal in Finder" action with whichever hotkey or menu item selection will reveal the file in Finder for you.

It's working now, thanks!
I know what was happening with that action. The menu is
Reveal In Finder (capital i - In)
and not
Reveal in Finder

At this point, creating my own macros seems almost useless, because there's always a better solution provided by you guys haha
I spend this whole time creating something super simple with images and all that, and then you come up with a better solution by just using variables and all that complex stuff. My life sucks :sweat_smile:

I appreciate your time and help. Hopefully I will start learning more and more so I can one day create those more complex macros as well

1 Like

I'm still not at that level, I'm afraid. I wish...
I try to create macros that at least work and make my life easier, even if their structure is not the best one. But while I'm creating them, I'm learning, as well as when I look at the macros you guys create.

So I appreciate your time and help! :handshake: :raised_hands:

2 Likes

You are -- you just don't realise it!

By "programmatically" I mean "using a proper KM action" rather than "using KM to drive mouse and keyboard like you would". You'll generally get better results using an action to eg close the frontmost window than by using menu clicks.

I agree that these aren't always easy to find -- KM has so many options to so many actions that it's difficult to know where to start! I usually use the Actions pane's "Search" for a general word -- "window" in this case -- then pick something likely -- "Manipulate a Window" -- and see what's available.

1 Like

That's just... Words fail me. No they don't -- Apple, that's stupid, stupid, stupid! Even worse -- mine is finding a renamed mp3 by its actual filename, but displaying the name using the metadata "Title" so it looks like it wasn't found!

Doing a "proper" Find lets you add the "Filename" tag which also lets you find by actual filename -- but the results are still displayed using the "Title" metadata.

Not even three "stupid"s can cover how stupid that is...

1 Like

Off-topic:

I remember trying out EasyFind about a year ago, hoping it might be able to find Logic sessions that contained a certain plugin.

I couldn't get it to work, but it might be an interesting challenge for anyone who has the faintest clue how to interpret Logic session data. Imagine being able to find all projects containing a plugin that will soon become incompatible, so you can open them and bounce/freeze those tracks. Even if the search took all night, it would be miles quicker than opening every session manually to check which plugins were used.

2 Likes

You have no idea how that would be a blessing for me right now!

Recently I bought a new computer and started the process of migrating stuff from one OS to the other. I now have 2 volumes on my disk, one for the current OS and another for the old one. Thing is, I want my Logic projects to only have my current set of plugins and trying to find the projects that only have those, means I need to open each project one by one, replace them with others for compatibility purposes, etc.

This kind of tool or feature would be super cool!

If you ever find a way to do this, PLEASE let me know! :smiley:

Are you a member of the Logic Pro Help forum as well?
There's a lot of people there who have a deep understanding of some of the more specific stuff when it comes to Logic. Actually I will just post something about this in there just in case

Yeah I've asked there and a few other nerdy places, but nobody seems to know how to decipher the session data. I think it's encrypted somehow, so plugin names won't be explicit in any of the files. If anyone knows how, I'm yet to find them.

Ok here's what I just tested and maybe this could be a first step towards something...? I have no idea.

If you open a project file using the Show Package Contents, then go to Alternatives > 000 (if you only have 1 alternative) > Project Data and open it with the TextEdit, it will look like that crazy text with some weird characters combined with normal text. But for example I created a project with only the ES2 on the first instrument and when I searched for ES2, I got this (look at how you see the instrument track number and the name of the plugin):
Screen Shot 2022-06-20 at 4.18.12 PM

Tried adding more instruments and effects and it kept showing me everything, so I guess it would be possible to somehow have a list of all stock plugins along with a way to scan all available plugins on our system, merge them, and perform a scan on the Project Data file, making it a list. Like "if you find the one of the words on our plugin list, copy and paste it on XYZ text file"

Does this spark any ideas on your end?

1 Like

The heck?!?! I can't believe I never looked in Alternatives!!!

I've written a macro that will work, but there's one hurdle I haven't been able to overcome yet.

The ProjectData file is encoded in a way that KM can't read. If we can fix that, we'll have a working plugin test!

We'll also have to make sure the most recent alternative is used to draw the data from, but I think that's doable. This encoding thing isn't something I've encountered before.

It appears that one has to alter the file encoding for it to be read, but of course that isn't possible with this file. We could copy it as a temp file and change that, but I don't know how to change encoding in the first place. So near yet so far!

Screenshot

I can already imagine how I'd use this to batch-test project files... by adding Finder tags if the plugin is found! :grimacing:

1 Like

I started this topic here:

des99 is also having some ideas. Maybe you two together can get there faster?
I'm just here throwing ideas at you. Apparently neither you or him were thinking about that file, so now that you do, maybe things get a little bit easier to prototype with the knowledge you both have (and I don't)...

What's your username there, by the way?

1 Like

@noisyneil. I mis-spelled it when I joined the KM forum, which is kinda annoying lol.

@Nige_S, sorry for the off-topic meanderings! Got a bit excited!

1 Like