Issue with System Events

Hi folks,

Really weird issue, hope someone can shed some light on it. I have the following script that works as intended in Script Editor but when inserted in an ASOC project, does not run at all, with no errors.


set sigName to "Name of Signature"
tell application "Microsoft Outlook" to activate
	tell application "System Events"
		
		click menu item "Preferences..." of menu 1 of menu bar item "Outlook" of menu bar 1 of application process "Outlook"
		click item 1 of (buttons of window "Outlook Preferences" of application process "Outlook" whose description is "Signatures")
		if ("Microsoft Outlook.app" is in (do shell script "ls /Applications")) then
			-- OUTLOOK 2016
			click pop up button 2 of group 2 of window "Signatures" of application process "Outlook"
			click menu item sigName of menu 1 of pop up button 2 of group 2 of window "Signatures" of application process "Outlook"
			click item 1 of (buttons of window "Signatures" of application process "Outlook" whose description is "close button")
		else -- OUTLOOK 2011
			click button "Default Signatures..." of window "Signatures" of application process "Outlook"
			repeat with thisRow in rows of table 1 of scroll area 1 of sheet 1 of window "Signatures" of application process "Outlook"
				click pop up button 1 of thisRow
				click menu item sigName of menu 1 of pop up button 1 of thisRow
				click button "OK" of sheet 1 of window "Signatures" of application process "Outlook"
				click item 1 of (buttons of window "Signatures" of application process "Outlook" whose description is "close button")
				exit repeat
			end repeat
		end if
	end tell
end try

Essentially it’s making a specific signature the default. This is Xcode 7 with El Cap.

thanks

Saw an Apple kbase about adding to the app accessibility database:

do shell script "sudo sqlite3 /Library/Application\\ Support/com.apple.TCC/TCC.db \"REPLACE INTO access values ('kTCCServiceAccessibility', 'com.mckinney.Signature-Maker', 0, 1, 1, NULL, NULL);\"" user name "admin" password "pword" with administrator privileges

This did in fact add it but still can’t do any of those click events. Unfortunately Outlook doesn’t have AS hooks into adding default signatures, only making them.

Any ideas?

Actually it is working, as long as I don’t generate a new build of the application and run the build from the Finder (double-clicking). Seems like the app may need a restart before working. Wonder if there’s a way around that without making someone restart.