Below is my current v.0.2 Beta version for my BTT Actions PlugIn for Keyboard Maestro. I unfortunately get an Invalid PlugIn Error Message at the top of my KM Editor Window when I try to import this. Sinsheim this is my first PlugIn that contains many different configurations based on different Parmeter based relationships I need help.
My guess is that I’ve made some mistakes with the PopupMenu Params. But I absolutely don’t have a clue.
I definitely want to have this fixed before I continue developing this PlugIn any further - since it gets a lot of more code added into it (maybe 1000 lines of AppleScript code or even More) on top of the existing code.
Of course anyone else I didn’t mention here - who also wants to help me fix the errors - is welcome to do so.
Edit: File Download removed due to the reason that the PlugIn‘s appearance is static.
OK -- and bearing in mind I'm a complete newb just poking around -- I think you've got your popup menu sections wrong.
You've got, for example:
<dict>
<key>Default</key>
<string>Choose Option</string>
<key>Label</key>
<string>Options to change SD Brightness</string>
<key>Type</key>
<string>PopupMenu</string>
<menu>Choose Option|Change Brightness on all Stream Decks|Change Brightnesson on Stream Decks by Serial No.</menu>
</dict>
But I think it should be:
<dict>
<key>Default</key>
<string>Choose Option</string>
<key>Label</key>
<string>Options to change SD Brightness</string>
<key>Type</key>
<string>PopupMenu</string>
<key>Menu</key>
<string>Choose Option|Change Brightness on all Stream Decks|Change Brightnesson on Stream Decks by Serial No.</string>
</dict>
Note the key/value pair of Menu/string_of_options.
I've only tried it with that one parameter, but it changed things from failed to successful import. Give it a go and see what happens.
When I tried to open the plist file with PlistEdit Pro.app I get this error:
and consequently I can't progress any further to examine it,
I don't know what you used to create the plist file but there's definitely a problem with it.
Since it relates to an unknown tag menu on line 28 I suggest - and I'm guessing here - you use a valid type tag, for instance PopupMenu
Since I can't actually see what's in the plist file I really don't understand how what @Nige_S is suggesting is supposed to fit into the definition of the file as detailed in the KM wiki manual:Plug In Actions [Keyboard Maestro Wiki]
It’s based on the script. (I‘ll fix this mentioning from my post for others)
You should dig into the code. Everything to explain here would be to much to write out - even though there aren’t all planned Action Options built in yet.
Edit: I already wrote down that the script is telling the route.
Not having BTT I won't get far with that. But I believe that parameters are made available via environment variables, so you don't need all those tell blocks to get values. You've also quite a few spelling mistakes in your parameter names, eg KMPARAM_Sream_Deck_Model (missing the "t" in "Stream") that you'll want to get cleared up before people start testing.
tell application "Keyboard Maestro Engine"
set bttStreamDeckModelNameParam to system attribute "KMPARAM_Stream_Deck_Model"
end tell
As I understand it you don't need to tell the Engine to get the value of a system attribute -- they are exported as part of the environment at script instantiation. Indeed, you'll slow things down slightly by including the tell.
But the point is that there's no mention of "appearance" in the code, so you'll get far better help if you tell us what should change, as a result of what, and how, instead of expecting us to dig for it
I suspect you want the action's form to change depending on selected option, eg only showing the "SD Serial No" field when "...Stream Decks by Serial No" is selected. AFAIK the action's form is static and you can't do that. But today is the first time I've even looked at a plug-in, so I could well be wrong!
I don't have a ton of experience with plug-ins, but I have built a couple for personal use. I am not aware of any way to create a dynamic plug-in; you build a plug-in with the options you want to have available, and that's what gets presented when the plug-in action is called.
Maybe someone could do something really fancy with XML via AppleScript to replace a plug-in on the fly, but that's way beyond my skill level. You'd have to replace the plug-in's XML script, and then reload the app and editor (as per the wiki) to reload the modified plug-in:
In normal use, once a plug in action is read, it will stay in memory and changes will not be noticed (although the script will be executed each time, so changes to that will be noticed). To cause the editor and/or engine to notice changes to the plug while in development, use AppleScript to reload the macros:ㅤ
So maybe it's possible in theory, but it seems like a real mess. Maybe it's better to have a family of plug-ins, each configured as necessary, then call the proper plug-in based on user input? I have no idea what/how BTT works, nor the purpose of the plug-in, and honestly have no time to look into it, but creating a self-modifying plug-in is not going to be a simple task—at least based on what I know about plug-ins.