Changing Font Color for One Note without opening menus

Hello this is the first forum I am been on so I apologize if this is out of place, I did try haha.
I have been in the painstaking process of writing my first script for longer than i’d like to mention so just a heads up I have very little idea as to what i’m doing.

Anyways so I wrote a basic little script for changing the font color in One Note mapped to double tapping the edges of my trackpad via Better Touch Tool. It works well enough but I was hoping someone could help me in figuring out how I can run the script without actually having any of the menus show up.


activate application "Microsoft OneNote"
tell application "System Events"
	tell process "Microsoft OneNote"
		perform action "AXShowMenu" of menu button "Font Color" of group 2 of scroll area 1 of tab group 1 of front window
		click button "More Colors..." of group 1 of group 1 of window "Font Color"
		delay 0.1
		click color well 1 of list 1 of list "favorite swatches" of scroll area 1 of splitter group 1 of window "Colors" of application process "Microsoft OneNote" of application "System Events"
		click button "OK" of window "Colors"
	end tell
end tell

Model: Macbook Air
AppleScript: 2.11
Browser: Google Chrome
Operating System: macOS 10.14

Hi there, this Script is not running for me. Any ideas? Thanks.

Sorry but this is the only way.
First - “Onenote” is not scriptable
Second - The color function is only available thru the button on the main window. It doe not exist in the main menubar.

So the only way to script it is as you did.

I added some better timing loops to guaranty that the windows are open and available.

tell application "Microsoft OneNote" to activate
tell application "System Events"
	tell process "Microsoft OneNote"
		perform action "AXShowMenu" of menu button "Font Color" of group 2 of scroll area 1 of tab group 1 of front window
		repeat until exists window "Font Color"
			delay 0.2
		end repeat
		click button "More Colors..." of group 1 of group 1 of window "Font Color"
		repeat until exists window "Colors"
			delay 0.2
		end repeat
		click color well 1 of list 1 of list "favorite swatches" of scroll area 1 of splitter group 1 of window "Colors" of application process "Microsoft OneNote" of application "System Events"
		click button "OK" of window "Colors"
	end tell
end tell

I cleaned it up some more to check if Home tab is selected first

tell application "Microsoft OneNote" to activate
tell application "System Events"
	tell process "Microsoft OneNote"
		repeat until (value of radio button "Home" of tab group 1 of front window) = 1
			click radio button "Home" of tab group 1 of front window
			delay 0.2
		end repeat
		perform action "AXShowMenu" of menu button "Font Color" of group 2 of scroll area 1 of tab group 1 of front window
		repeat until exists window "Font Color"
			delay 0.2
		end repeat
		click button "More Colors..." of group 1 of group 1 of window "Font Color"
		repeat until exists window "Colors"
			delay 0.2
		end repeat
		click color well 1 of list 1 of list "favorite swatches" of scroll area 1 of splitter group 1 of window "Colors" of application process "Microsoft OneNote" of application "System Events"
		click button "OK" of window "Colors"
	end tell
end tell