Sunday, December 4, 2022

#1 2022-11-15 10:14:14 am

Jeffkr
Member
Registered: 2005-11-05
Posts: 498

Skim - Difficutly counting words less than 7 points filled with white

Hello all,
I am using an application called "Skim", which analyzes a PDF. My end goal is to get a count of all words less than 7 points that are filled with white, without repeating through a list of words.

This snippet does not work:

Applescript:

tell application "Skim"
   set myColor to "65535654246521765535"
   set myCount to count of (words of text of front document whose size is less than 7 and color is "65535654246521765535")
end tell

it returns the following error:
error "Skim got an error: Can’t make \"65535654246521765535\" into type RGBA color." number -1700 from "65535654246521765535" to RGBA color

However,
I can use a separate script to get a color of a specific word. For example:

Applescript:

tell application "Skim"
   set my2ndWordColor to color of word 2 of text of front document as string
end tell

Will return: "65535654246521765535"

if my2ndWordColor is not set to string, then the result would be {65535, 65424, 65217, 65535}


Likewise, I can use a separate script to determine how many words are less than 7 points:

Applescript:

tell application "Skim"
   set myCount to count (words of text of front document whose size is less than 7)
end tell

will return: 3

Therefore, I have seen some crazy one liners from this group and was hoping there was a way to count each word that is both less than 7 in size and whose color (as string) is "65535654246521765535"

I know it's a stretch, but I figured I would ask just in case somebody is up for the challenge to help?

Offline

 

#2 2022-11-15 12:22:39 pm

KniazidisR
Member
From:: Greece
Registered: 2019-03-03
Posts: 2589

Re: Skim - Difficutly counting words less than 7 points filled with white

The color property is an RGB color in Skim.app, not a string. You must understand that the comparison only makes sense for things of the same type. So compare color with an RGB color, that is, with {65535, 65424, 65217, 65535}, and not with the string "65535654246521765535". Whose command compares when filtering.

Applescript:


tell application "Skim"
   set myCount to count of (words of text of front document whose size is less than 7 and color is {65535, 65424, 65217, 65535})
end tell

Last edited by KniazidisR (2022-11-15 12:29:22 pm)


Model: MacBook Pro
OS X: Catalina 10.15.7
Web Browser: Safari 15.6.1
Ram: 4 GB

Offline

 

#3 2022-11-15 01:00:26 pm

Fredrik71
Member
Registered: 2019-10-23
Posts: 1091

Re: Skim - Difficutly counting words less than 7 points filled with white

Color is a list a simple demostration

Applescript:

(choose color)'s class

So you could do....

Applescript:

set {theRed, theGreen, theBlue} to (choose color)

If you like to get the green color
return theGreen


Node-RED makes it easy to automate IoT

Offline

 

#4 2022-11-15 02:19:39 pm

Jeffkr
Member
Registered: 2005-11-05
Posts: 498

Re: Skim - Difficutly counting words less than 7 points filled with white

Thank you both VERY MUCH! Very helpful information that I was lacking and definitely needed to know.

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)