Actually a couple of issues. I have this code here that works.
on run_JW_lua_file(fileLoc, appName)
set luaFile to (fileLoc)
set the clipboard to (read luaFile)
menu_click({appName, "Plug-ins", "JW Lua", "JW Lua..."})
win_wait_active("JW Lua", appName)
tell application "System Events"
tell process appName
tell window "JW Lua"
click radio button "Development" of radio group 1
delay 0.2
keystroke tab
delay 0.2
keystroke "a" using command down
delay 0.2
keystroke "v" using command down
tell button "Run Script" to click
delay 0.2
tell button "Close" to click
end tell
delay 0.2
tell window 1
tell button "No" to click
end tell
end tell
end tell
end run_JW_lua_file
Basically I’m opening up a window with a scroll area where you can enter text. I’m pushing tab to get the cursor to display, emptying out its contents by selecting everything that’s already there (if there is anything) and pasting from the clipboard the contents of a file. Then it clicks run, close, this annoying window pops up asking to save and it clicks no.
Here’s the small issues:
-
Is filling in the clipboard with the contents of the file and pasting it in the best way to do this? I’d rather not use the clipboard but it might be the only / most succinct way…?
-
I’d rather not tab in when AS is perfectly capable of setting the focus there. I tried it in fact:
tell application "System Events"
tell process theFinale
tell window "JW Lua"
set value of attribute "AXFocused" of scroll area 1 to true
end tell
end tell
end tell
The Inspector reads:
<AXApplication: “Finale 2014”>
<AXWindow: “JW Lua”>
So shouldn’t that work. It executes without error but the focus is not there…
- When it asks me to save, it is a nameless window. The code I have above works when I tell it to click “No” but it literally takes 4-5 seconds to do it… Is there any reason to that?