Possible to select a "container"?

I have a very handy KM macro working for me know that speeds up the transfer of taking text from iA Writer over to Rapidweaver (the web design software I use). The macro is fine as is but I'm wondering if I can make it even more special.

When the macro moves from iA Writer to RapidWeaver I'd love for the macro to identify the active "container" in the frontmost page and then insert the copied text into that container. I know how to automate the select-all, delete, then paste commands on the RapidWeaver side. What I don't know is possible or not is to activate/identify the active container or a specific container. I may not even be using the right lingo from a KM perspective. I've provided a screenshot below as I'm anticipating most folks don't use RapidWeaver and don't understand what I'm writing about.

Any hints/suggestions would be appreciated. Actually, if this is simply impossible to do this would also be useful for me to know!

The only way I can find to do this is by using KM's Found Image-related actions.

This is a screen capture of part of my RapidWeaver app on my Mac:

You'll notice (and it's the same on your screen capture above) that the active container is highlighted in blue. So that's the property I'll use to identify it. The difficulty comes when a different container is active, such as this one:

Why is that difficult? Well, you'll notice that the background colour for each is different, so the means of detecting these must take that into account.

This is the example macro I have come up with:

Test - Click Active Container.kmmacros (23 KB)

Click to see macro

When you download this macro and install it into your own KM app, you'll see that

  1. It is disabled for your safety, so you'll have to enable it.
  2. It is in a macro group called APP - RapidWeaver so it will only function when RapidWeaver is the active app.

The way this works is it first tries to move the mouse to the active container with the darker background:

KM 1 2022-07-28_14-15-33

If that fails it tries to move the mouse to the active container with the light background:

KM 2 2022-07-28_14-22-29

If either of those is successful it plays a successful sound; if they both fail, a different sound is played. In your use-case you might also have to click the mouse too...

Now this is just an example macro which I've made sure works for me and my system. Your macro would not only have to move the mouse to the active container but it would also have to do other stuff that you require!

The real difficulty comes from the fact that that "light" and "dark" colours come from the background colours I've specifically set for my containers. I can see from your screen capture that the background colours you use are both different and more numerous than mine. So your challenge will be to come up with a way to get round that in KM. I can think of one way: capture the container name itself like this:

KM 4 2022-07-28_14-48-49

KM 5 2022-07-28_14-53-48

and do that for every possible container (name) that RapidWeaver supports and then use a cascading set of KM actions employing the Found Image condition. To me this sounds both tedious and long-winded but definitely possible. EDIT: but this gives rise to the problem of multiple containers with the same name: how do you distinguish between them?

If only RapidWeaver supported something like AppleScript (which it doesn't).

Anyway, this is food for thought and I hope it gives you some ideas.

@tiffle Wow, thanks so much! This is very helpful and gives me what I need to start playing around with. I really appreciate your detailed response and will start playing around with your KM macro today.

1 Like

I appreciate the feedback @Mathew. Just ask if you have other queries.