I have a script that I wrote that works fine when run from Script Editor, but does not if run from the Scripts menu in Capture One. I cannot seem to figure out why it will not work. The error I receive when trying to run the script from within Capture One is that System Events cannot find menu bar item 6- invalid index. Does using ‘on run’ change how the script can access the GUI elements? Any help would be appreciated. GUI scripting has always flummoxed me.
on run argv
if (class of argv is list) then set selectedImage to item 1 of argv
tell application "Finder"
set selectedImageName to name of (POSIX file (item 1 of argv as string) as alias)
set styleNameToSet to text -5 through -8 of selectedImageName
tell application "System Events"
tell process "Capture One"
click menu item 2 of menu 1 of menu item 19 of menu 1 of menu bar item 6 of menu bar 1
click button 2 of group 1 of window 1
set text of text field 1 of window 1 to styleNameToSet
No, I am not running the script from another script- at least as far as I can tell. I am running the script from the application Capture One. In its menu bar, there is an item labelled ‘Scripts’. I can point the application to scripts that I have written and then they appear in the menu item within the application to select and run.
Sorry, I should have explained what I am trying to accomplish with the script. I am trying to automate the creation of custom image adjustment profiles that I can then use on other images. The portion of the script I posted is grabbing the filename of the selected image and then clicking on the corresponding menu bar item to save the image adjustments as a reusable profile.
I am using ‘on run’ because I thought I needed to do that in order to capture the selected image so that I can get information from it- namely the filename.
Does that make more sense? The problem I am running into is that I am getting an ‘invalid index’ error when the ‘click menu item.’ line is run. I do not understand why that is.