Dialog Box AppleScript With Specific Icon

Nr.5-need_input – “But if you’re willing to learn how it all works with help just ask here in the forum. You can learn a lot from the folks here, trust me...”
But I'm well aware
Greetings from France - Loiret

That doesn't change how the script is run – just where it is run from.

The same limitations apply. Try it and see.

Thanks Chris for clarifying this issue… this is odd because with the power of ASObjC there are so much possibilities what you can put in custom dialogs …

I assume that this issue would even exist using Shane’s Dialog Toolkit Plus. So the best we could do so far is using something like swiftDialog - mentioned by @Nige_S in post 11 yesterday, something like Carsten Blüm‘s Pashua - which was last updated on December 29th,2021 or a a custom solution running the code with KM using FastScripts or by building our own custom Applet which will then run our Dialog…

Greetings from Germany

Tobias

I am sorry that I am asking you in this context @peternlewis - but is it possible giving us a new feature for the Execute AppleScript Action that makes it possible to run our own Dialogs, Dynamic Dialogs, Alerts or Enhanced Alerts written in ASObjC - forcing them to run on the mainthread?

I think this would be a great enhancement for AppleScripters who use KM - but also for others as well - having more options in building custom GUI‘s for their Workflows.

Greetings from Germany

Tobias

Tobias – “having more options in building custom GUI‘s for their Workflows.”
Thank you Tobias, I support your request, while absolutely not knowing what this will impose as development in KM...

1 Like

Hello and a good morning to France Loiret (@tempo)

Thank you for supporting my request for Peter … let’s wait to see what he will response with … maybe there isn’t any way based on his manner developing Keyboard Maestro.

But what I can say is that even though the fact that I still have a lot to learn using AppleScript - is it the good old Vanilla AppleScript or AppleScript Objective-C syntax - I am a person that has fallen in love with this Language.

Yes, giving you a response on some words from you yesterday, the syntax is sometimes very confusing or clunky or even both - but I love the way this syntax is build and the fact that if you know how to do it you can even customize it further writing your own Script-Libraries with their own Terminologies..

Greetings from Germany

Tobias

Tobias“I am a person that has fallen in love with this Language.”
Me too, but just because I've been fighting it for decades, I've memorized a few principles, I like it, and it seems "relatively easy" (I put a ton quotation marks) to apprehend...
The fact that KM integrates AS makes me happy.
Now, when I see the solution offered by Apple with its Shortcuts application, I laugh and I cry at the same time: heartbreaking!...

Tobias“...but I love the way this syntax is build”
I also have the feeling of an “almost” readable language for a non-specialist like me... :crazy_face:

I very much doubt it - AppleScript is not even executed within the Keyboard Maestro Engine process, far less on the main thread. It is executed in an entirely different process (on it's main thread, but I doubt that makes any difference for this purpose).

As far as a Dialog Box with a Specific Icon, in Keyboard Maestro I would recommend you use the Custom HTML Prompt action, which can make anything you want, including a floating window, though not strictly a dialog box in the conventional sense.

Nice !...

Hello Peter

Thanks for your reply.

I understand - but could it be a possible thing to do it ? I am asking because of the current situation that I am in where it not only has to be a custom icon for the Dialog/Alert - it has to do with dynamic changes and redrawing possibilities all based on AppleScript and Apple‘s Objective-C API‘s.

Shure I could do something like that in HTML, too but here comes the thing that I only want to tinker with at least one Language and as less external resources or packages as possible.

My GUI‘s would not be possible with the usage of the dependencies that I or @Nige_S mentioned earlier in this topic.

Even if any one else here wants to draw such GUI‘s using AppleScript Objective-C the will have to build very complex routines using at least two or three or maybe more macros and a custom applet or a routine that builds the applet before launching it to have a GUI that has focus.

It would be nice to have something built into KM, that makes this less more complex.

Greetings from Germany to Australia

Tobias

This probably isn't all that useful, but I'm trying to get my head around AppleScript, so I had a go at an AS dialog subroutine...

Call Dialog.kmmacros (20 KB)

Macro screenshot

Display Custom Dialog.kmmacros (24 KB)

Macro screenshot

If you leave any caller fields blank, that attribute won't feature in the dialog. In other words, you can have a dialog with or without a title, an icon, a text prompt (and user input field) or buttons.

The only thing I couldn't figure out was how to get the escape key to dismiss the dialog when there isn't a "Cancel" button among the custom button titles.

1 Like

Hey Neil, look at the "Customizing Dialog Buttons" section on this page Mac Automation Scripting Guide: Displaying Dialogs and Alerts Sorry - you probably already saw that!!

Hey Neil (@noisneil)

Sounds very clever what you’ve built - but this is only possible for the Vanilla AppleScript based dialogs what you’ve built here.

If you want to have for example some additional fields of any type and of course more than three buttons you will have to play with Apple’s Objective-C API’s of the AppKit Framework by programming in ASObjC directly or using a Script-Library with its own Terminology (sdef) written by Shane Stanley called Dialog Toolkit Plus in Vanilla AppleScript … it uses some of AppKit‘s API’s…

And these types of Dialogs are the problem because they have to run as modal on the main thread what KM at this time is not able to do by it self.

It is currently quite a hassle to get such custom GUI‘s to work in Keyboard Maestro Macro based workflows.

Greetings from Germany

Tobias

I think I figured it out. It just got so long that my head was spinning! I've edited it above.

1 Like

Thanks. Just doing this was hard enough, so I think I'm done! :woozy_face:

1 Like

At the beginning everything seems very hard … think of the custom GUI’s written in HTML and JavaScript from Dan … with a lot of learning and effort it is even possible to write them by just using ASObjC :sunglasses::sunglasses:

Greetings from Germany

Tobias

The problem is in the method that Keyboard Maestro uses to run AppleScript, and that is unlikely to change anytime soon.

FastScripts has no such problem – AppleScriptObjC UI elements run and are naturally made frontmost.

FastScripts is scriptable and can be driven by Keyboard Maestro, and in my view is the best solution to this problem.

It used to be very inexpensive (at $10.00 US), but Daniel has recently added functionality and increased the price to $39.95. That's fairly expensive for a Mac utility, but if you use it day in and day out as I do it pays for itself pretty quickly.

Dialog Toolkit is nothing more than AppleScriptObjC packaged in an AppleScript library.

I've peeked at that, and although it seems powerful enough I'm not really interested in learning how to use it.

Pashua Future Plans

“I do not have any roadmap for Pashua. Probably, I will have almost no time for working on it (as it was the case in the last few years), so its future is currently unclear.”

Pashua is fairly powerful, but it's a lost cause. Once again I have no interest in learning how to use it.

The most efficient use of your time is going to be to learn more HTML and JavaScript and to use Keyboard Maestro's Custom HTML Prompt.

That mechanism is enormously powerful and flexible.

-Chris

2 Likes

Hopes raised!

...and then crushed :frowning:

This does seem to be the best bet at the moment, Tobias (@Nr.5-need_input). If you're using ASObjC then you should find learning the HTML/CSS/JavaScript you'll need to be a walk in the park -- and that stack is very transferable, so any time spent on it will be an investment rather than a waste.

And just to add an off-the-wall idea... If you are looking more for an UI for your macro(s), maybe reverse things? Create an actual app with a SwiftUI interface, and do your interactions with KM via script/URL triggers!

1 Like

You got this where? What is a 'private user'? Are you referring to dropping support for standalone vaults The future of local/standalone vaults — 1Password Community?