The reason why local_variable failed is because of async Custom HTML Prompt. There is ways to solve this
Put a Pause action after Custom HTML Prompt action (2sec)
Use document.kmvar.Local_variable
Use global variable.
When async is used for Custom HTML prompt, it returns immediately for KM to execute rest of actions, so the macro may finish before the custom prompt get to read the local variable (hence return empty).
This macro is great—I've turned it into a generic subroutine I call from a number of spots. What I'd like to do is add a floating button stuck to the top right corner of the window that would open the URL in the browser.
I am a Javascript neophyte, so everything I use comes from elsewhere :). I found some code for a floating button:
var button = document.createElement("Button");
button.innerHTML = "My Button";
button.style = "top:10;right:10;position:absolute;z-index: 9999"
document.body.appendChild(button);
Rob,
For this to work, the data—kmwindowid must be defined in body tag of custom HTML Prompt statically, not dynamically. So your custom prompt need to include the body tag with data—kmwindowid and cannot be created with document.write.
Anyway do not use document.write as it is destroying the KM reference to the prompt so you can no longer use Execute Javascript in Custom Prompt action
I was using the code above from @macdevign_mac, which uses document.write to put a live webpage into the custom HTML prompt. I'm far from an expert (hence, the help request), but I don't see how I could do that with your template?
Rob,
how do you define web page ? Are you defining it as the actual Website (eg http://www.infoworld.com) or some thing generated by KM variable as shown by your example ?
Thanks for clarifying. As I want to have an actual web page in the window, I think I can solve this another way—I'll just put my own prompt onscreen in another HTML window, and position the two of them together.
Thank you for this, mrpasini, I can use technique this for my Ultimate Web Search macro. Instead of using Brave and create tabs, I can position six windows on my main screen and another six on my secondary screen:
ALYB,
You can try putting all the custom prompt with the same data-kmwindowid , and when closing them together, just iterate and close them until the action indicates a status to break loop.
Toggle this HTML view's visibility based on the Trigger key? e.g. If I press ⌥ + T, it shows up, if I press it again and the view is visible, it closes/hides. Right now, it opens a new web view every time I trigger the macro.
Can I keep the view open in the background, basically in hidden mode, like the ⌘ + H feature of macOS where the app is hidden but still running the background. This would help to load the webview faster the next time I trigger it and take me to the exact place in the view. Reloading it makes some webpages lose their original position