JMP 15 AppleScript Run Program()Ich habe Run Program() noch nie zuvor verwendet und benötige Hilfe. Da JMP keine passwortgeschützten Excel-Dateien öffnen kann, arbeite ich an einem kleinen Applescript, um sie zu öffnen und als ungeschützte CSV-Datei zu exportieren. Ich möchte dieses Applescript in einem JSL-Skript ausführen. Wenn es gut funktioniert, erstelle ich vielleicht eine kleine JMP-Benutzerfunktion, um es zu verpacken, damit ich in JMP die Möglichkeit simulieren kann, passwortgeschütztes Excel zu öffnen.
ABER ... ich habe Probleme mit Run Program(). Ein paar Fragen.
1. Soll mein Applescript als Anwendung (.app-Erweiterung) oder als Skript (.scpt-Erweiterung) gespeichert werden?
2. Meine JSL-Syntax sieht so aus:
Run Program( Executable( "Users/me/Desktop/myscript.scpt" ) )
aber es funktioniert nicht und gibt den folgenden Fehler aus:
launch path not accessible in access or evaluation of 'Glue' , Names Default To Here( 1 ); /*###*/Run Program(
Executable( "/Users/me/Desktop/re.scpt" )
) /*###*/;
In the following script, error marked by /*###*/
Names Default To Here( 1 ); /*###*/Run Program(
Executable( "/Users/me/Desktop/re.scpt" )
) /*###*/;
Wieder habe ich versucht, .app und .scpt zu verwenden, und überhaupt keine Erweiterung – keine Freude.
Natürlich muss ich etwas zusätzlichen Code hinzufügen, um die resultierende CSV-Exportdatei in den Griff zu bekommen, aber jetzt muss ich nur damit anfangen, überhaupt ein Barebone-Applescript auszuführen.
Vielen Dank für jede Hilfe.
Betreff: JMP 15 AppleScript Run Program()Danke, Julian.
Hier ist eine leicht verbesserte Version, die es Ihnen ermöglicht, einen Wert aus dem KM-Makro zurückzugeben, indem Sie als letzte Aktion Ihres KM-Skripts eine KM-Aktion „Set System Clipboard to Text…“ einfügen. Die JSL-Funktion verwendet dann den Inhalt der Zwischenablage als Funktionsrückgabewert.
Außerdem wurde mir klar, dass Sie die KM-Makro-UUID nicht verwenden müssen. Es funktioniert genauso gut, wenn Sie einfach den Plain-Vanilla-Namen des KM-Makros verwenden.
Add Custom Functions(
New Custom Function(
"ex",
"Run KMScript",
Function( {scriptID, paramlist = {}},
{paramstring, savedClipboard, macroResult = ""},
paramstring = Concat Items( paramlist );
savedClipboard = Get Clipboard();
Run Program(
Executable( "/usr/bin/osascript" ),
Options(
"-e tell application \!"Keyboard Maestro Engine\!" to do script \!"" || scriptID || "\!" with parameter \!"" || paramstring ||
"\!""
)
);
macroResult = Get Clipboard();
Set Clipboard( savedClipboard );
Return( macroResult );
)
) << Prototype( "ex:Run KMScript( scriptID as string, < {param1 as string, param2 as string, etc.} > )" ) << Parameter( "String", "scriptID" )
<< Parameter( "List", "parameter(s)" ) << Formula Category( "Utility" ) << Description(
"Runs a Keyboard Maestro (KM) script. The KM scriptID is either the KM macro's name or UUID. (You can reveal and copy the UUID by opening the 'Or trigger by shell script' text box at the top of your KM macro window.) The (optional) parameters to the KM script can be retrieved inside the KM macro using the KM '%TriggerValue%' token. KM receives them as a single concatenated string of space-separated values. If you want to return a value from KM, push it to the system clipboard before exiting the macro. This function will grab the clipboard contents and use as the function return value. (The function saves and restores the pre-invocation clipboard state, so the system clipboard is unaffected by the function.)"
)
);Betreff: JMP 15 AppleScript Run Program()Das ist fantastisch, John! Ich freue mich sehr, dass Sie dies geteilt haben. Ich bin mir sicher, dass es für jemanden hilfreich sein wird.
@julianischBetreff: JMP 15 AppleScript Run Program()Nur eine kleine Ergänzung dazu, die vielleicht für einige Mac-Benutzer nützlich sein könnte.
Die Applescript-Idee hat nicht funktioniert – nicht wegen JSL, sondern wegen der Einschränkungen beim MSExcel-Applescripting unter OSX 10.15. (Speicherbefehle in Excel funktionieren offenbar aufgrund von Sandboxing nicht mehr richtig; mir wurde gesagt, dass Microsoft seine Applescript-Unterstützung aktualisieren muss. )
Stattdessen habe ich beschlossen, das, was ich brauchte, mit Keyboard Maestro (KM) zu skripten, einer sehr guten OSX-Skript-/Makro-App. (Ich kann es wärmstens empfehlen – ich habe keine Interessenkonflikte.)
Ich habe das Drehbuch, das ich brauchte, in KM geschrieben. Dann habe ich eine kleine JSL-Funktion geschrieben, die ein KM-Skript aufruft:
Add Custom Functions(
New Custom Function(
"ex",
"Run KMScript",
Function( {scriptID, paramlist = {}},
{paramstring},
paramstring = Concat Items( paramlist );
Run Program(
Executable( "/usr/bin/osascript" ),
Options(
"-e tell application \!"Keyboard Maestro Engine\!" to do script \!"" || scriptID || "\!" with parameter \!"" || paramstring ||
"\!""
)
);
)
) << Prototype( "ex:Run KMScript( scriptID as string, < {param1 as string, param2 as string, etc.} > )" ) << Parameter( "String", "scriptID" ) <<
Parameter( "List", "parameter(s)" ) << Formula Category( "Utility" ) << Description(
"Runs a Keyboard Maestro script. The KM scriptID is a UUID; you can reveal and copy it by opening the 'Or trigger by shell script' text box at the top of your KM macro window. The (optional) parameters to the KM script can be retrieved inside the KM macro using the KM '%TriggerValue' token. KM receives them as a single concatenated string of space-separated values."
)
);Im Moment verwende ich dies in meiner JSL, um ein KM-Makro aufzurufen, das die geschützte Excel-Datei in Numbers öffnet, den Schutz aufhebt, sie als CSV speichert, sie in JMP öffnet und dann Numbers schließt. Es funktioniert gut.
Ich hoffe, dass jemand anderes dies nützlich finden könnte.
Betreff: JMP 15 AppleScript Run Program()Perfekt!! Danke!!!Betreff: JMP 15 AppleScript Run Program()Hallo @John madden ,
Ich würde Ihr Skript als .app speichern und dann zum Öffnen dieser Anwendung etwas wie das Folgende verwenden, das die ausführbare Datei „open“ zum Öffnen der .app verwendet:
Run Program(
Executable( "/usr/bin/open"),
options( {"/users/me/Desktop/myscript.app"} )
);
Ich hoffe, das hilft Ihnen beim Einstieg!
@julianisch