Is there a way to Create a Custom HTML Form without Making it "Active"?

All you need to access local variables from another macro is the instance of the calling macro. Have a look in the wiki here: token:ExecutingInstance [Keyboard Maestro Wiki]

Access Local and Global Variables

You could have each macro call your subroutine, passing %AccessedVariables%, on a periodic basis. Except that doesn't give you the Local values. So each macro would need to iterate through %AccessedVariables%, and build a list of variable names and values, which you would pass to your subroutine.

Or...

Each maro could fill a global variable with its current local and instance variables and values, and you could update it any time you want to - it doesn't matter. Because every second or whatever, another macro could access this global variable and use it to update the prompt. But if you do it this way, you'll need to use Semaphores to keep from reading the global variable while you're updating it. This isn't hard at all, by the way. Really easy, in fact.

Updating the Prompt

Now, as far as recreating the prompt each time, here's the logic to not have to recreate the prompt each time: You can use the action "Execute JavaScript in Custom HTML Prompt" to call a function in your prompt, passing the variables and their values.

This will require some effort on your part, including learning some JavaScript. Since you're interested in Custom HTML Prompts, you're going to need to learn some javascript anyway. You can't really accomplish a lot in HTML pages, without some javascript.

So if you're interested in doing something like this, let me know. I can walk you through it, and I can even write some of the javascript so you get the idea. Just be aware that it will take some time to baby-step through the process.

That's what I meant when I said, "That would probably be implemented by a subroutine that passes both the name and value of a local variable in such a way that the local variable's name and value can be store in a dictionary." Except that I said I would use a dictionary, while you were suggesting a variable.

Interesting. I have never used that before. Now I grasp what it's for.

I agree. I have used a little bit of Javascript in Custom HTML forms already, but I quickly forget everything I've learned.

That's a very nice offer. I may take you up on it, but give me more time to consider the direction you've set my sail in.

That would be amazing. I'm very familiar with accessing local and global variables from AppleScript, but despite spending the last 15 minutes trying to figure out how the instance ID of the calling macro would help me find a local variable's value. I couldn't find a single page on the wiki that demonstrates how to use the macro's instance ID to get a variable. But I'll keep looking.

2 Likes

Maybe this will help you:

You’ll need to read the whole thread to get the info you need.

2 Likes

I believe that will help me out a lot. I had never seen that thread before. It will take me days to figure it out, but thanks.

With the tips above, I probably won't have to worry about fixing my original problem in this thread. But putting all the pieces together will take a while.

Good luck!

That is so awesome! Somewhere in the back of my mind, I think I may have learned about this, but I never needed it. But now, I can see how I might use it in my Variable Inspector Prompt. I'll give it some thought.

Thanks!

1 Like

and what is even more awesome is that you might use it in something!

1 Like