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

AppleScript to toggle calendar focus Apps
We recently ran a hint about displaying just one calendar quickly in OS X Calendar. A commenter said, "Anyone know how to show just one calendar and then go back to the group of calendars that were previously checked? That would be awesome."

It turns out that Daniel Jalkut of Red Sweater Software came up with a way to do just that . Using AppleScript and GUI scripting, he found a way to toggle to a single calendar and back to all calendars. Have a look at his blog post and download the script, edit it for your calendar names, and you're in business.
    •    
  • Currently 3.63 / 5
  You rated: 1 / 5 (8 votes cast)
 
[4,740 views]  

AppleScript to toggle calendar focus | 5 comments | Create New Account
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: robleach on Jan 18, '13 11:06:57AM

So I'm the guy that posted the comment "Anyone know how to show just one calendar and then go back to the group of calendars that were previously checked? That would be awesome.".

I've been chatting with the guy who wrote the script, Dan. He actually implemented a version as I had suggested which doesn't require editing, which is awesome, but it appears that it is 10.8 specific. It wouldn't work on my 10.7 system. Still, I give the hint 5 stars! Perhaps at some point, I'll see if I can implement a 10.7 version, but it looks like the script getAppInterface, which I would be dependent upon to get the necessary app elements won't give me anything about the drop-down window that comes up when you click the calendars button. And Accessibility inspector does not seem to give me anything that will give me a list of available calendars to cycle through to check the visibility of. Anyone know of another way to discover the applescript hooks needed to gather the list of checked calendars?

Rob



[ Reply to This | # ]
AppleScript to toggle calendar focus
Authored by: applescripter on Jan 20, '13 07:02:42AM
Have you tried apple's UIElementInspector?
Available here.
(https://developer.apple.com/library/mac/#samplecode/UIElementInspector/Introduction/Intro.html)

[ Reply to This | # ]
AppleScript to toggle calendar focus
Authored by: applescripter on Jan 19, '13 08:14:42AM
Here is a version that *should* work on 10.6 (tested) and 10.8 (not tested), but unfortunately not 10.7.
On my system at least it is also considerably quicker the the version linked to in the original post.

property os : (version of application "Finder")
property ICAL : "iCal"
if os > 10.8 then
set ICAL to "Calendars"
end if

property calsenabled : true
property savedCalendarNames : {}

tell application "System Events"
if UI elements enabled is false then
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."
-- Automaticaly prompts the user
set UI elements enabled to true
end if
end tell

on enableCalendars()
set allrows to {}
set n to 0
if calsenabled then set n to 1
tell application "System Events"
tell application process ICAL
tell window 1
if os > 10.8 then
set 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
display dialog "OS version not supported"
else
set allrows to (value of attribute "AXChildren" of outline 1 of scroll area 2)
end if
if not calsenabled then
repeat with therow in savedCalendarNames
click checkbox 1 of therow
end repeat
return
end if
set savedCalendarNames to {}
repeat with therow in allrows
try
set g to (group 1 of therow)
on error
try
if (value of checkbox 1 of therow is equal to n) then
if selected of therow is false then
click checkbox 1 of therow
set end of savedCalendarNames to therow
end if
end if
end try
end try
end repeat
end tell
end tell
end tell
end enableCalendars

enableCalendars()
if calsenabled is true then
set calsenabled to false
else
set calsenabled to true
end if


[ Reply to This | # ]
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 | # ]
AppleScript to toggle calendar focus
Authored by: weekilter on Jan 22, '13 07:12:56AM

Pretty much all GSM phones use the 'press 0 and hold' as the way to generate the + character a major exception to that being Nokia phones which make you press * rapidly twice. All GSM mobiles can use the + character instead of local dialing code to initiate an international call.



[ Reply to This | # ]