Change Sort view via AppleScript?

Discussion regarding all scripting related questions
Please DO NOT post to this thread anything that is not directly related to scripting of Capture One.

Change Sort view via AppleScript?

Postby SeanMurp » Wed Oct 24, 2018 7:13 pm

Anyone know if it's possible to change the Sort View without using UI or key code calls? We are currently using key codes to press a keyboard shortcut for Sort by Rating and then Reverse the order. Would be great if we could do it via code. Nothing is sticking out to me in the dictionary. :?

I did just find the Available Filters code which helps us switch one key code to a script call but would be lovely to switch all of our key codes. For those that are curious here is how you can set the filter to all images with Red or Green color label:
Code: Select all
tell application "Capture One 11"
   tell current document
      set filters to {"Color Tag|Red", "Color Tag|Green"}
   end tell
end tell


To get a list of all available filters you can run this:
Code: Select all
tell application "Capture One 11"
   tell current document
      get available filters
   end tell
end tell
SeanMurp
 
Posts: 78
Joined: Wed Nov 02, 2016 4:30 am

Re: Change Sort view via AppleScript?

Postby ben_US » Wed Oct 24, 2018 8:20 pm

Not via AS to Capture One.
Please make a support case for Technical Support with Capture One software:
http://support.phaseone.com and click on Contact Support, then select Technical Support.
ben_US
Crew
Crew
 
Posts: 669
Joined: Mon Feb 01, 2016 9:51 pm
Location: New York, USA

Re: Change Sort view via AppleScript?

Postby SeanMurp » Wed Oct 24, 2018 9:23 pm

Ok, thanks Ben. That would definitely be a feature request for us. Our digitechs use a script on each look that filters by green label and then sorts by rating and then reverse the order. Would be great if we could code that without the key commands/keyboard shortcuts.
SeanMurp
 
Posts: 78
Joined: Wed Nov 02, 2016 4:30 am

Re: Change Sort view via AppleScript?

Postby Eric Nepean » Thu Oct 25, 2018 4:10 am

Hi Sean, what's your ubjection to UI scripting?

BTW I have useful tools that will give the AS reference to any key you press.
Cheers, Eric
[late 2015 iMac, 4GHz i7, 24GB RAM, external SSDs. GX8, E-M1, GX7, GM5, GM1 ....]
Eric Nepean
 
Posts: 519
Joined: Sat Oct 25, 2014 8:02 am
Location: Ottawa

Re: Change Sort view via AppleScript?

Postby ben_US » Thu Oct 25, 2018 3:08 pm

SeanMurp wrote:Ok, thanks Ben. That would definitely be a feature request for us. Our digitechs use a script on each look that filters by green label and then sorts by rating and then reverse the order. Would be great if we could code that without the key commands/keyboard shortcuts.


I wholeheartedly agree.
Please make a support case for Technical Support with Capture One software:
http://support.phaseone.com and click on Contact Support, then select Technical Support.
ben_US
Crew
Crew
 
Posts: 669
Joined: Mon Feb 01, 2016 9:51 pm
Location: New York, USA

Re: Change Sort view via AppleScript?

Postby SeanMurp » Thu Oct 25, 2018 4:07 pm

Hey Eric,
UI scripting is fine in cases but we have a large enough fleet of computers which use a large library of custom applications that we have developed. The requirement to give the applications Assistive Access for each application that uses UI is too much of a hindrance on the user when every minute they are delayed costs quite a bit of money. Plus many of those users are switching between different computers on a daily basis which just compounds the issue. We just have much fewer issues to deal with not using UI calls when possible.
SeanMurp
 
Posts: 78
Joined: Wed Nov 02, 2016 4:30 am

Re: Change Sort view via AppleScript?

Postby Jim_DK » Fri Dec 21, 2018 2:24 pm

Sort order for collections has been added in Capture One 12
James
Phase One DK
Jim_DK
Crew
Crew
 
Posts: 652
Joined: Thu Dec 03, 2009 10:00 pm

Re: Change Sort view via AppleScript?

Postby SeanMurp » Fri Dec 21, 2018 6:27 pm

Thanks for the note Jim. I just saw that in the notes the other. Really looking forward to testing out 12.
SeanMurp
 
Posts: 78
Joined: Wed Nov 02, 2016 4:30 am

Re: Change Sort view via AppleScript?

Postby EPAIN » Wed Mar 20, 2019 9:28 pm

Hello, I have a similar goal here (yet working in Capture One 10 FYI)
Trying to sort the Browser by Date. When I run this from the Script Editor it works perfectly:

Code: Select all
try
   tell application "Capture One 10" to activate
   tell application "System Events"
      tell process "Capture One 10"
         set frontmost to true
         click menu item "Date" of menu 1 of menu item "Sort" of menu 1 of menu bar item "View" of menu bar 1
      end tell
   end tell
on error errMsg
   display dialog "Error: " & errMsg
end try


However, from within CaptureOne I get:
"Error: System Events got an error: Can’t get menu bar 1 of process "Capture One 10". Invalid index."

Any thoughts on how to solve this?
EPAIN
 
Posts: 4
Joined: Thu Jun 22, 2017 8:34 pm

Re: Change Sort view via AppleScript?

Postby Eric Nepean » Thu Mar 21, 2019 1:14 am

For an aplication to be allowed control of the user interface, it must be enabled to do so in the accessibility section of the the Privacy menu of the Security amd Privacy item of System Preferences. When Script editor is running a script, the script gets the privileges of Script Editor, which is very likely enabled in the Acessibility menu.

But when Apple script is saved and run as an application then the application has to have these privileges. I have a script that automatically sets the brightnes of the display to the value used for screen calibration using UI controls, and this is what I had to do.

I don't know off hand if it is useful or necessary for Capture One to have these privileges.
Cheers, Eric
[late 2015 iMac, 4GHz i7, 24GB RAM, external SSDs. GX8, E-M1, GX7, GM5, GM1 ....]
Eric Nepean
 
Posts: 519
Joined: Sat Oct 25, 2014 8:02 am
Location: Ottawa

Re: Change Sort view via AppleScript?

Postby EPAIN » Thu Mar 21, 2019 5:45 pm

Thanks for the reply Eric!

I believe I set that up properly and still have problems.
So: Settings -> Security and Privacy -> Accessibility -> Add CaptureOne
And that's it right?

Since I get the "Invalid Index" rather than a permissions error I think I have something else happening.
EPAIN
 
Posts: 4
Joined: Thu Jun 22, 2017 8:34 pm

Re: Change Sort view via AppleScript?

Postby Eric Nepean » Thu Mar 21, 2019 6:29 pm

Good point.

Now that you mention this it triggers a memory; There is another strange effect that sometimes happens and I think this a likely cause.

The message is actually telling you two things
1. There is no menu bar 1
2. There are no menu bars. If there were menu bars, one of them would be assigned an index of 1.

Conclusion: Name of the class “menu bar” is not what we expect it to be.

When an Apple script is run as an application, instead of as a script, the some of the Capture One classes loose their names, and are expressed in RAW form. In this case the name starts with the left Chevron symbol “<<“.

So I would write an application that does a “get every UI” command, convert to text and display. Run as a script of course.

Check for unexpected names.
Cheers, Eric
[late 2015 iMac, 4GHz i7, 24GB RAM, external SSDs. GX8, E-M1, GX7, GM5, GM1 ....]
Eric Nepean
 
Posts: 519
Joined: Sat Oct 25, 2014 8:02 am
Location: Ottawa

Re: Change Sort view via AppleScript?

Postby Eric Nepean » Thu Mar 21, 2019 10:20 pm

Sorry for the confusing reply. Now that I hve rturned from work and have access to my Mac, here is a better one.

Now that you mention this it triggers a memory; There is another strange effect that sometimes happens and I think this a likely cause.

The message is actually telling you two things
1. There is no menu bar 1
2. There are no objects called "menu bar". If there were objects called "menu bar", one of them would be assigned an index of 1.

Conclusion: Name of the class “menu bar” is not what we expect it to be.

When an Apple script is run as an application, instead of as a script, the some of the Capture One classes loose their names, and are expressed in RAW form. In this case the name starts with the left Chevron symbol “«“, and ends with "»"

Write this script and save it as an application. Grant the application Aaccessibility rights, then run it, and you will see the evidence.

If you run the application as a script from Script editor, the result is this: "window; window; window; menu bar"
If you run the the application from finder, the result is this: "window; window; window; «class mbar»"
(blue highlighting is mine)
Note that every time you save your application you have to red-grant the accessibility.

Thus the problem. I'm not sure how to get around it.
Code: Select all
tell application "System Events"
   tell process "Capture One 10"
      set theUIList to get every UI element
      set uiClassNameList to ""
      set seperatorString to ""
      repeat with someUI in theUIList
         set uiClassNameTest to (get (class of someUI) as text)
         set uiClassNameList to uiClassNameList & seperatorString & uiClassNameTest
         set seperatorString to "; "
      end repeat
      display dialog uiClassNameList
   end tell
end tell
Cheers, Eric
[late 2015 iMac, 4GHz i7, 24GB RAM, external SSDs. GX8, E-M1, GX7, GM5, GM1 ....]
Eric Nepean
 
Posts: 519
Joined: Sat Oct 25, 2014 8:02 am
Location: Ottawa


Return to Scripting



Who is online

Users browsing this forum: No registered users and 1 guest