"Can't get current document" issues

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

"Can't get current document" issues

Postby SeanMurp » Tue Jun 26, 2018 4:44 pm

Hi all,
Has anyone else been experiencing random "Can't get current document" errors with Capture One 11? I just finished converting all of our CO10 scripts to CO11 and we are randomly getting that error. Trying to figure out when it happens but doesn't seem to be consistent. Anyone know of some strange bugs that might cause this?

Image
SeanMurp
 
Posts: 75
Joined: Wed Nov 02, 2016 4:30 am

Re: "Can't get current document" issues

Postby Eric Nepean » Wed Jun 27, 2018 3:17 am

I can make this happen by closing all documents, leaving open Capture One's Menu to open a file.

Then execute
Code: Select all
tell application "Capture One 11" to set currentDocRef to get current document
tell application "Capture One 11" to set currentDocName to get name of current document

you get the following Applescript replies
Code: Select all
tell application "Capture One 11"
   get current document
      --> missing value
   get name of current document
      --> error number -1728 from current document

CO doesn't have a document open (missing value), asking for the name of the open document generates an error message. This may or may not be your issue.

If this is your issue, the answer is simple, first try
tell application "Capture One 11" to set currentDocRef to get current document
If the result is "missing value" (a class, not text), then stop and tell the user to select a document.

If this is not your issue, then I would try inserting the following code into your script and see what data it gathers:
Code: Select all
try
   tell application "Capture One 11" to set currentDocRef to get current document
   tell application "Capture One 11" to set currentDocName to get name of current document
on error errormessage number errornumber
   tell application "System Events"
      set errorProcList to every process whose background only is false
      set errorProcNameList to name of every process whose background only is false
      set errorFrontProcNameList to name of (every process whose frontmost is true)
      set errorFrontProcDispNameList to displayed name of (every process whose frontmost is true)
      set COPProcNameList to name of every process whose name contains "Capture One"
      set COPProcDispNameList to displayed name of every process whose name contains "Capture One"
      set COPProcDispFileList to file of every process whose name contains "Capture One"
      set COPProcDispVisibleList to visible of every process whose name contains "Capture One"
      set COPProcDispFrontList to frontmost of every process whose name contains "Capture One"
      log {" errorProcNameList", errorProcNameList}
      log {" errorFrontProcNameList", errorFrontProcNameList}
      log {" errorFrontProcDispNameList", errorFrontProcDispNameList}
      log {"COPProcNameList", COPProcNameList}
      log {"COPProcDispNameList", COPProcDispNameList}
      log {"COPProcDispFileList", (get COPProcDispFileList)}
      log {"COPProcDispVisibleList", COPProcDispVisibleList}
      log {"COPProcDispFrontList", COPProcDispFrontList}
      error errormessage & " " & errorNumber
   end tell
end try
Cheers, Eric
[late 2015 iMac, 4GHz i7, 24GB RAM, external SSDs. GX8, E-M1, GX7, GM5, GM1 ....]
Eric Nepean
 
Posts: 398
Joined: Sat Oct 25, 2014 8:02 am

Re: "Can't get current document" issues

Postby SeanMurp » Wed Jun 27, 2018 2:55 pm

Thanks Eric! Really simple/easy bit of code to enter in to check if a current doc is open. I'll have to explore to see if it is at the point when no document is actually open when it is trying to get the current document.

On a somewhat related topic now that you mention Capture One's menu to open a file, is there a way to escape out of that dialog without hitting key commands (which never worked well for us). We have since been opening a blank session programmatically to then create a new session with our AppleScript and then auto-close the blank session. Takes a few extra seconds to perform but has eliminated any issues caused when the Open a File window appears because it doesn't appear at all.
SeanMurp
 
Posts: 75
Joined: Wed Nov 02, 2016 4:30 am

Re: "Can't get current document" issues

Postby Eric Nepean » Thu Jun 28, 2018 4:24 am

This "one liner" should do it:
Code: Select all
tell application "System Events" to tell process "Capture One 11" to ¬
   if (1 = (count of windows)) and ("" = name of window 1) then ¬
      tell window 1 to tell group 1 to tell button "Cancel" to click


To get to here, I first surveyed (with the code below) the behaviour of Capture One with no file open and no windows open, with only the select file window open, and with a session open.

Once I determined that the "open File" window of Capture One was window 1 (no name or index or ID) and there was no window 2 in that state, then I used "get entire contents" to get the list of the window's UIs.

Code: Select all
tell application "System Events"
   set errorProcList to every process whose background only is false
   set errorProcNameList to name of every process whose background only is false
   set errorFrontProcNameList to name of (every process whose frontmost is true)
   set errorFrontProcDispNameList to displayed name of (every process whose frontmost is true)
   set COPProcNameList to name of every process whose name contains "Capture One"
   set COPProcDispNameList to displayed name of every process whose name contains "Capture One"
   set COPProcDispFileList to file of every process whose name contains "Capture One"
   set COPProcDispVisibleList to visible of every process whose name contains "Capture One"
   set COPProcDispFrontList to frontmost of every process whose name contains "Capture One"
   get every window of process named "Capture One 11"
   set COPProcWindowNameList to name of every window of process named "Capture One 11"
   set COPProcWindowIDList to id of every window of process named "Capture One 11"
   set COPProcWindowIndexList to index of every window of process named "Capture One 11"
   set COPProcWindowDocList to document of every window of process named "Capture One 11"
   try
      get properties of window 1 of process named "Capture One 11"
      get entire contents of window 1 of process named "Capture One 11"
   end try
   log {" errorProcNameList", errorProcNameList}
   log {" errorFrontProcNameList", errorFrontProcNameList}
   log {" errorFrontProcDispNameList", errorFrontProcDispNameList}
   log {"COPProcNameList", COPProcNameList}
   log {"COPProcDispNameList", COPProcDispNameList}
   log {"COPProcDispFileList", (get COPProcDispFileList)}
   log {"COPProcDispVisibleList", COPProcDispVisibleList}
   log {"COPProcDispFrontList", COPProcDispFrontList}
   log {"COPProcWindowNameList", COPProcWindowNameList}
   log {"COPProcWindowIDList", COPProcWindowIDList}
   log {"COPProcWindowIndexList", COPProcWindowIndexList}
end tell
Cheers, Eric
[late 2015 iMac, 4GHz i7, 24GB RAM, external SSDs. GX8, E-M1, GX7, GM5, GM1 ....]
Eric Nepean
 
Posts: 398
Joined: Sat Oct 25, 2014 8:02 am

Re: "Can't get current document" issues

Postby Eric Nepean » Mon Jul 02, 2018 6:46 pm

SeanMurp wrote:Hi all,
Has anyone else been experiencing random "Can't get current document" errors with Capture One 11? I just finished converting all of our CO10 scripts to CO11 and we are randomly getting that error. Trying to figure out when it happens but doesn't seem to be consistent. Anyone know of some strange bugs that might cause this?

Image


As I was working yeterday I have noticed that I also got missing document issues in my AppleScript due to a second version of Capture One 11 trying to start up.

I had a version of Capture One 11.2 in my system, as I was working yesterday I noticed that when I started my Applescript which referred to Capture One 11, the newer version would try to start even though Capture One 11.1 was already runnning. Then of course it would throw an error that it couldn't start because another version was already running.

It was at this point that I got the the missing document error.

I fixed that by deleting the other version.

Capture One 10.2 is also present, but no issues there, it doesn't identify as Capture One 11.
Cheers, Eric
[late 2015 iMac, 4GHz i7, 24GB RAM, external SSDs. GX8, E-M1, GX7, GM5, GM1 ....]
Eric Nepean
 
Posts: 398
Joined: Sat Oct 25, 2014 8:02 am


Return to Scripting



Who is online

Users browsing this forum: No registered users and 1 guest