Applescript to change the Calendar display to start at today

I would like to change the start day in Calendar for Mac to the current day, but although the code below opens the drop down box I cannot work out how to change the current day. the drop down box when clicked manually shows the days of the week starting at Sunday but I cannot figure out how to code that.

tell application "Calendar" to activate

tell application "System Events"
	tell process "Calendar"
		keystroke "," using {command down}
		repeat until exists window "General"
			delay 0.2
		end repeat

	end tell
end tell

MitchBVI,

GUI Scripting is wildly dependent on your App / OS version. Including yours will increase the chances of getting working code.

This works here.

--Running under AppleScript 2.8, MacOS 15.5
tell application "System Events"
	tell its application process "Calendar"
		set frontmost to true
		tell menu item "Settings…" of menu "Calendar" of menu bar item "calendar" of menu bar 1 to perform action "AXPress"
		tell its UI element "General"
			set PopUpButtonReference to pop up button "Days per week:"
			my Pop_Up_Button_Value_Set(PopUpButtonReference, "7")
			set PopUpButtonReference to pop up button "Start week on:"
			set currentDayOfWeek to (weekday of (current date)) as string
			my Pop_Up_Button_Value_Set(PopUpButtonReference, currentDayOfWeek)
		end tell
	end tell
end tell










on Pop_Up_Button_Value_Set(PopUpButtonReference, targetMenuItem)
	--https://www.macscripter.net/u/paulskinner/
	tell application "System Events"
		if value of PopUpButtonReference is not targetMenuItem then
			set menuItemsList to my Pop_Up_Button_Menu_Items_Get(PopUpButtonReference)
			if menuItemsList does not contain targetMenuItem then
				set AppleScript's text item delimiters to ", "
				set menuItemsListText to ((items 1 thru -1 of menuItemsList) as text) & " or " & (item -1 of menuItemsList)
				set AppleScript's text item delimiters to ""
				set errorText to "Invalid Menu Item." & linefeed & linefeed & "targetMenuItem must be one of " & menuItemsListText
				display alert errorText message "Mun" as informational
				error errorText
			end if
			tell window 1
				tell PopUpButtonReference
					try
						menu 1
					on error
						perform action "AXPress"
					end try
					try
						click menu item targetMenuItem of menu 1
						return true
					on error
						repeat with i from 1 to (length of menuItemsList)
							if (item i of menuItemsList) is targetMenuItem then
								click menu item i of menu 1
								return true
							end if
						end repeat
						return false
					end try
				end tell
			end tell
		end if
	end tell
end Pop_Up_Button_Value_Set

thanks for all the trouble but I get this error
error “Can’t make «class popB» "Start week on:" of window "General" of «class pcap» "Calendar" of application "System Events" into the expected type.” number -1700 from «class popB» “Start week on:” of window “General” of «class pcap» “Calendar”
my script editor is 2.8 and I am on sequoia which is 15.1

I do have a workaround but it its cumbersome

--PrintCalendarWeekWithNewStartDate V2
set todayName to (weekday of (current date)) as text
set dayList to {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}
-- 1) Ask operator,  fall back is current day
set targetDay to todayName
try
	with timeout of 5 seconds
		set choice to (choose from list dayList with prompt "Today is " & todayName & ". Select the start day of the week:" default items {todayName})
		if choice is not false then set targetDay to (item 1 of choice) as text
	end timeout
on error -- timeout or user closed the chooser; keep targetDay = todayName
end try
set abbr to (text 1 thru 3 of targetDay) -- e.g., "Thu"
-- 2) Open Calendar Settings → General and set the popup
tell application "Calendar" to activate
delay 0.2
tell application "System Events"
	set frontmost of process "Calendar" to true
	tell process "Calendar"
		-- Open Settings (⌘,)
		keystroke "," using command down
		delay 0.5
		-- Switch to General, then refresh window handle
		try
			if exists toolbar 1 of w then tell toolbar 1 of window 1 to if exists button "General" then click button "General"
		end try
		delay 0.2
		-- Set "Start week on:" if needed (type-to-select)
		set pb to pop up button "Start week on:" of window 1
		if (value of pb as text) is not targetDay then
			perform action "AXPress" of pb
			delay 0.1
			keystroke abbr
			delay 0.05
			key code 36 -- Return to commit
		end if
		-- Close Settings (⌘W)
		delay 0.2
		keystroke "w" using command down
		-- Week view → Today → Print
		delay 0.1
		keystroke "2" using command down -- Week view
		delay 0.15
		keystroke "t" using command down -- Today
		delay 0.15
		keystroke "p" using command down -- Print
	end tell
end tell
-- 3) Print flow: Return twice (Continue → Print)
delay 0.5
tell application "System Events" to tell process "Calendar" to key code 36 -- Continue
delay 0.5
tell application "System Events" to tell process "Calendar" to key code 36 -- Print