Hello, I am writing a palette for the Simple Mind MindMap app some of which require scripting.
KM Engine error message
AppleScript failed with script error: text-script:21:30: script error: A “"” can’t go after this identifier. (-2740)
activate application process "SimpleMind Pro"
tell application "System Events"
tell process "SimpleMind Pro"
click button 1 of group 1 of group 1 of splitter group 1 of window "content.smmx" of application process "SimpleMind Pro"
end tell
end tell
It looks like you need to wrap the tell application process line with tell application "System Events" like yo do further down.
The following works for me (at least in the sense that it lets me compile the script):
tell application "System Events"
tell application process "SimpleMind Pro" to activate
tell process "SimpleMind Pro"
click button 1 of group 1 of group 1 of splitter group 1 of window "content.smmx" of application process "SimpleMind Pro"
end tell
end tell
I don’t have that app to test with, but I imagine you could even shorten the script more so, like this:
tell application "System Events"
tell process "SimpleMind Pro"
activate
click button 1 of group 1 of group 1 of splitter group 1 of window "content.smmx" of application process "SimpleMind Pro"
end tell
end tell
both scripts failed. KM Engine log for each attempt
2023-01-30 17:21:07 Action 12935453 failed: Execute an AppleScript failed with script error: text-script:117:243: execution error: System Events got an error: Can’t get application process "SimpleMind Pro" of process "SimpleMind Pro". (-1728)
2023-01-30 17:21:07 Execute an AppleScript failed with script error: text-script:117:243: execution error: System Events got an error: Can’t get application process "SimpleMind Pro" of process "SimpleMind Pro". (-1728). Macro “Add as Style Preset” cancelled (while executing Execute AppleScript).
Thanks very much. Works perfectly now. I changed the name of the window to window 1, which works fine.
The only funny thing is that when I open a secondary window called Apply Style Preset with the script, the SimpleMind dock icon bounces a few times until I click on the canvas, which it does not if I click on the corresponding icon. How would you interpret that ?
To get the initial script, I used UI Browser which is tedious because it is buggy.
If I see a clickable icon on my screen (not a button) with an assigned name, for example Apply Style Preset, is there any way to create a script based on that knowledge alone, and knowing that I am working in the front window 1. I am asking because this is a common and recurrent issue.
You can't activate an application process – you'll end up activating System Events instead of the process.
tell application "SimpleMind Pro" to activate
tell application "System Events"
tell application process "SimpleMind Pro"
click button 1 of group 1 of group 1 of splitter group 1 of window "content.smmx"
end tell
end tell
If the process is running you can use its frontmost property to bring it to the front.
tell application "System Events"
tell application process "SimpleMind Pro"
set its frontmost to true
end tell
end tell