I’m new to KM and trying to use it to search a pdf file that holds employee names & phone extensions. I’d like to search the PDFPen file for the employee name and capture the found results. Is there a group of commands or AppleScript (trying to learn some of that too) to capture the results into a variable of a ⌘F keystroke (Find) that can then be parsed to get the extension and speak the extension as text?
This AppleScript gets the value of field 2 of every row in the found-items table in the Find window.
tell application "System Events"
tell application process "PDFpenPro"
set frontmost to true
tell window "Find"
set foundList to value of text field 2 of rows of table 1 of scroll area 1 of splitter group 1
end tell
end tell
end tell
It’s a kludgy way of going about things, but it works.
The PDF file is an in-house list that I always use to look up the four-digit extension of other employees. I’m running OS X Yosemite v10.10.5. I’m new to the company so I’m often pulling out the list from my briefcase to look up the numbers. Since trying KM, I decided to attempt to use my computer to find the extensions and have some fun learning.
foundList only has one item in the format: {ExtensionFirstName_LastNameTitlePhoneNumber}, where _ is a space between First & Last Name.
I would like to parse foundList and speak any or all pieces of it with appropriate english syntax (adding any necessary words), but I haven’t figured out how or find a way to convert it to a string. I use “say foundList”, but it just speaks the entire item all together (e.g. 0123JoeSmithDirector(999)999-9999)
I'm not sure there is a good definition of a splitter group anywhere...
GUI-Scripting with System Events is complicated and takes mucho patience to learn.
You need Apple's Accessibility Inspector (part of Xcode), or preferably UI Browser ($55.00 U.S – there is a demo.). You need to know a bit about AppleScript, and you need some mentoring.
Either utility is able to highlight UI-Elements in an app, so it's easier to associate the name with the element. The syntax of all the items can get really gnarly though.
I bit my tongue about 10 years ago and bought UI Browser 1.0; it has me hours of time and kept me from pulling my hair out.
If you're willing and able to install an AppleScript Extension and a small Unix command-line program that transforms PDF-to-Text it's likely we can do a lot better.
You mentioned PDF-to-Text, but I also have the file as an MS Excel file that I could process for the employee contact information. Would finding the name in an Excel file be easier for obtaining string values? Each aspect of the contact information resides in a separate cell of the row the employee’s name is found in!
Again, very helpful! Your macro makes clear the ability to use KM command
with regular expression (which I’ve also been trying to learn for this
macro). I was originally just trying to get the extension using regex, but
found the KM Get Substring command based upon the character position (which
was easy because its always in the first four characters) in the string.
I’ll see if I can capture and set variables to the extension, name and
position title using regular expression.