Oh, yes, you must get the window in System Events. AppleScript is a mess.

        set theWindow to first window where its document is theDocument
        set theName to name of theWindow
        tell app “System Events”
                tell process “Skim”
                        delay 1
                        set theWindow to window theName
                        repeat while count of sheets of theWindow > 0
                                delay 1
                        end repeat
                end  tell
        end tell

the app that runs the script (Script Editor) must have assistive access enabled 
(Security & Privacy system preferences -> Accessibility -> Privacy).

Christiaan

> On 28 Jan 2018, at 20:44, Jan David Hauck <[email protected]> wrote:
> 
> Yes, that does seem the problem.
> Adding some delay after converting helps. 
> 
> Your workaround gave me an error though: 
> "Can’t make sheets of window id 8402 into type specifier." 
> 
> Jan David Hauck, Ph.D.
> Lecturer
> Department of Anthropology
> University of California, Los Angeles
> http://ucla.academia.edu/hauck <http://ucla.academia.edu/hauck>
> http://www.anthro.ucla.edu/content/jan-david-hauck 
> <http://www.anthro.ucla.edu/content/jan-david-hauck>
> 
> 
> On Sun, Jan 28, 2018 at 11:17 AM, Christiaan Hofman <[email protected] 
> <mailto:[email protected]>> wrote:
> I already know what your problem is. The one thing that has changed in the 
> last release is that notes conversion now works asynchronously. Therefore the 
> convert notes command returns before the actual conversion has taken place. 
> Perhaps I should modify the command a bit to allow running it synchronously.
> 
> For now you could try to wait in the script while Skim is converting. I think 
> adding the following lines after the command may do that (i did not test 
> this; you may reduce the time steps):
> 
>     set theWindow to first window where its document is theDocument
>     delay 1
>     repeat while count of sheets of theWindow > 0
>         delay 1
>     end repeat
> 
> Christiaan
> 
> 
>> On 28 Jan 2018, at 19:12, Christiaan Hofman <[email protected] 
>> <mailto:[email protected]>> wrote:
>> 
>> The convert notes AppleScript command does work for me.  And nothing really 
>> changed. Are you sure the file does have these types of notes?
>> 
>> The highlightNote should be a list, I think, and it looks rather convoluted. 
>> Also did you set the myFile and skimNotes variables properly?
>> 
>> Does the Convert Note action work in the app?
>> 
>> Christiaan
>> 
>>> On 28 Jan 2018, at 18:37, Jan David Hauck <[email protected] 
>>> <mailto:[email protected]>> wrote:
>>> 
>>> Sorry, I didn't provide the full script, but I do set numberOfNotes.  This 
>>> is the full script.  It had been working flawlessly before.  
>>> 
>>> 
>>> tell application "Skim"
>>>     launch
>>>     open myFile
>>>     set theDocument to document 1
>>>     convert notes theDocument
>>>     
>>>     set noteTypeStrings to {"Box", "Underline", "Freehand"}
>>>     set noteTypes to {}
>>>     repeat with noteTypeString in noteTypeStrings
>>>             set noteTypeString to contents of noteTypeString
>>>             else if noteTypeString is "Box" then
>>>                     set end of noteTypes to box note
>>>             else if noteTypeString is "Underline" then
>>>                     set end of noteTypes to underline note
>>>             else if noteTypeString is "Freehand" then
>>>                     set end of noteTypes to freehand note
>>>             end if
>>>     end repeat
>>>     set highlightNote to highlight note
>>>     set lineNote to noteTypes
>>>     set highlightColor to {63798, 59381, 37996} -- New Yellow 
>>>     set linesColor to {45073, 3851, 6345} -- Dark Red
>>>     set numberOfNotes to 0
>>>     tell contents of theDocument
>>>             repeat with aNote in (get notes)
>>>                     set aNote to contents of aNote
>>>                     set theType to get type of aNote
>>>                     if highlightNote contains theType then
>>>                             set color of aNote to highlightColor
>>>                             set numberOfNotes to numberOfNotes + 1
>>>                     else if lineNote contains theType then
>>>                             set color of aNote to linesColor
>>>                             set numberOfNotes to numberOfNotes + 1
>>>                     end if
>>>             end repeat
>>>     end tell
>>> 
>>>     if numberOfNotes = 0 then
>>>             close theDocument saving no
>>>     else
>>>             save theDocument in skimNotes as "Skim Notes"
>>>             close theDocument saving no
>>>     end if
>>> end tell
>>> 
>>> 
>>> Jan David Hauck, Ph.D.
>>> Lecturer
>>> Department of Anthropology
>>> University of California, Los Angeles
>>> http://ucla.academia.edu/hauck <http://ucla.academia.edu/hauck>
>>> http://www.anthro.ucla.edu/content/jan-david-hauck 
>>> <http://www.anthro.ucla.edu/content/jan-david-hauck>
>>> 
>>> 
>>> On Sun, Jan 28, 2018 at 1:06 AM, Christiaan Hofman <[email protected] 
>>> <mailto:[email protected]>> wrote:
>>> You never seem to assign the numberOfNotes variable in your script. 
>>> 
>>> Christiaan
> 
> 
> 
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot 
> <http://sdm.link/slashdot>
> _______________________________________________
> Skim-app-users mailing list
> [email protected] 
> <mailto:[email protected]>
> https://lists.sourceforge.net/lists/listinfo/skim-app-users 
> <https://lists.sourceforge.net/lists/listinfo/skim-app-users>
> 
> 
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! 
> http://sdm.link/slashdot_______________________________________________
> Skim-app-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/skim-app-users

Christiaan

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Skim-app-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-users

Reply via email to