Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Set Evernote Mac Font and Text Size using AppleScript
property ptyScriptName : "Set EN Mac Font Name and Size"
property ptyScriptVer : "2.0"
property ptyScriptDate : "2017-06-12"
property ptyScriptAuthor : "JMichaelTX"
property LF : linefeed
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
my enSetFontAndSize("Courier New", "14")
on enSetFontAndSize(pFontName, pSizeStr)
(*
NOTE: Both FontName and Size MUST exist in EN Mac's popup menus,
or an error will occur. Typically the ONLY Font Sizes available are:
{9, 10, 11, 12, 13, 14, 18, 24, 26, 48, 64, 72}
*)
tell application "Evernote" to activate
try --=========== TRY ==============
tell application "System Events"
tell process "Evernote"
set frontmost to true
--- GET PARENT ELEMENT for either Main Window or Single Note Window ---
(*
THE EVERNOTE MAIN WINDOW HAS SPLITTER GROUPS
BUT the Window with only a Note, does NOT
So, we have to get the Parent Element of the Toolbar
controls in order to use those controls via UI scripting
*)
set oWin to (first window whose subrole is "AXStandardWindow")
set splitterList to every splitter group of oWin
set countSplit to count of splitterList
if countSplit > 0 then
set parentElem to splitter group 1 of splitter group 1 of oWin
else
set parentElem to oWin
end if
--- SET FONT ---
tell pop up button "Font" of parentElem
perform action "AXPress"
tell menu "Font"
tell menu item pFontName
perform action "AXPress"
end tell
end tell
end tell
delay 0.5 -- adjust as needed
--- SET TEXT SIZE ---
tell pop up button "Text Size" of parentElem
perform action "AXPress"
tell menu "Text Size"
tell menu item pSizeStr
perform action "AXPress"
end tell
end tell
end tell
end tell
end tell
on error errMsg number errNum --======= ON ERROR =========
tell application "SystemUIServer"
set msgStr to "Unable to Set Font and/or Size to: " & pFontName & " " & pSizeStr ¬
& LF & LF & "Due to ERROR:" & LF & errMsg
set msgTitleStr to "Set Evernote Font and Size"
--display notification msgStr with title msgTitleStr sound name "Glass.aiff"
do shell script "afplay /System/Library/Sounds/" & "Glass.aiff"
display dialog msgStr with title msgTitleStr with icon stop
end tell
tell application "Evernote" to activate
return msgStr
end try --======== END TRY ==========
return "OK"
end enSetFontAndSize
@JMichaelTX

This comment has been minimized.

Copy link
Owner Author

commented Jun 13, 2017

If you are new to installing and/or using Mac scripts, or would like detailed instructions, see:

How to Install AppleScripts or JXA Scripts

AppleScript: Beginner's Tutorial

at MacOSXAutomation.com

This may also be of interest:
Understanding AppleScript Scripting Additions 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.