BusyCal support

OK, I have updated the scripts with a number of improvements.

  1. The scripts should never hang in a loop now if the clipboard is not updated properly or the input is not formatted as expected.
  2. A delay is only used if needed and proportionately to the delay needed for the speed of system and current load on the system.
  3. Instead of using a loop to trim the Name the script uses a single calculation.

Hopefully this should speed up the scripts and make them much more robust.

Are you still seeing the long delay? Hopefully not with these changes.

That’s great — I don’t use the To Do feature, so it’s good to know.

Get Name

set afterTitle to " <busycalevent://info/"
set lengthOfClipboardAfterTitle to 69

tell application "System Events"
	tell process "BusyCal"
		if enabled of menu item "Copy Event URL with Title" of menu 1 of menu bar item "File" of menu bar 1 then
			-- Item selected
			click menu item "Copy Event URL with Title" of menu 1 of menu bar item "File" of menu bar 1
			set titleFound to false
			repeat 3 times
				set theURLWithTitle to the clipboard
				if theURLWithTitle contains afterTitle then
					set lengthOfTitle to (length of theURLWithTitle) - lengthOfClipboardAfterTitle
					set trimmedTitle to characters 1 thru lengthOfTitle of theURLWithTitle as string
					set titleFound to true
					exit repeat
				else
					-- Clipboard doesn't contain title of selected item, so try getting clipboard again
					delay 0.1
				end if
			end repeat
			if titleFound then
				get trimmedTitle
			end if
		end if
		-- else item not selected
	end tell
end tell

Get Address

set startOfURL to "busycalevent://info/"

tell application "System Events"
	tell process "BusyCal"
		if enabled of menu item "Copy Event URL to Clipboard" of menu 1 of menu bar item "File" of menu bar 1 then
			-- Item selected
			click menu item "Copy Event URL to Clipboard" of menu 1 of menu bar item "File" of menu bar 1
			set urlFound to false
			repeat 3 times
				set theURL to the clipboard
				if theURL contains startOfURL then
					set urlFound to true
					exit repeat
				else
					-- Clipboard doesn't contain URL of selected item, so try getting clipboard again
					delay 0.1
				end if
			end repeat
			if urlFound then
				get theURL
			end if
		end if
		-- else item not selected
	end tell
end tell
1 Like