Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'AppleScript to toggle calendar focus ' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
AppleScript to toggle calendar focus
Authored by: applescripter on Jan 20, '13 06:55:38AM
For anybody interested, here is a slightly faster version:

property os : (version of application "Finder")
property ICAL : "iCal"
if os ≥ 10.8 then
	set ICAL to "Calendars"
end if
property calsenabled : true
script o
	property savedSelectedCalendarRows : {}
	property savedCalendarRows : {}
	property allrows : {}
	property savedallrows : {}
end script

tell application "System Events" to if UI elements enabled is false then
	tell current application to display dialog "This script requires that you enable 'UI Scripting' support for AppleScript. You will be prompted to authorize this change by the system. If you do not wish to authorize this, click Cancel."
	set UI elements enabled to true
end if

tell application "System Events" to tell application process ICAL to tell window 1
	if not calsenabled then
		repeat with therow in o's savedSelectedCalendarRows
			click checkbox 1 of therow
		end repeat
	else
		if os ≥ 10.8 then
			set o's allrows to (value of attribute "AXChildren" of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of splitter group 1)
		else if os ≥ 10.7 then
			--To support 10.7 "allrows" must be set here to the equivalent of the above or below
			tell current application to display dialog "Mac OS X 10.7 is not supported" buttons {"OK"} default button 1
			return
		else
			set o's allrows to (value of attribute "AXChildren" of outline 1 of scroll area 2)
		end if
		set unchanged to o's allrows is equal to o's savedallrows
		if unchanged then
			set o's allrows to o's savedCalendarRows
		else
			set o's savedallrows to o's allrows
			set o's savedCalendarRows to {}
		end if
		set o's savedSelectedCalendarRows to {}
		repeat with therow in o's allrows
			try
				if (value of checkbox 1 of therow as boolean) and selected of therow is false then
					click checkbox 1 of therow
					set end of o's savedSelectedCalendarRows to therow
				end if
				if not unchanged then set end of o's savedCalendarRows to therow's contents
			end try
		end repeat
	end if
end tell
set calsenabled to not calsenabled
Edited on Jan 20, '13 08:18:08AM by applescripter


[ Reply to This | # ]