Keystrokes: upgraded to a M1 Mac and my Outlook script stopped working

I tried all the permission tricks I know form the past but for some reason I cannot get this to work again.

here is the script:

tell application "Microsoft Outlook" to activate

-- bring it to the front
tell application "System Events"
	tell application process "Microsoft Outlook"
		set frontmost to true
	end tell
end tell

--run send and receive
tell application "System Events"
	tell application "Microsoft Outlook" to activate
	tell application "Microsoft Outlook"
		if it is running then
			activate
		end if
		tell application "System Events"
			keystroke (ASCII character 107) using control down & command down
		end tell
	end tell
end tell

-- go to the Desktop were Outlook runs
repeat 2 times
	tell application "System Events" to key code 123 using control down
end repeat


Anybody please have an idea or tip?

Try giving this a shot.

tell application "Microsoft Outlook" to activate

tell application "System Events"
	set frontmost of application process "Microsoft Outlook" to true
	repeat until application process "Microsoft Outlook" is frontmost
		delay 0.1
	end repeat
	tell application process "Microsoft Outlook"
		keystroke "k" using {control down, command down}
	end tell
end tell

No same problem, as App it is not allowed to send keystrokes.

You need to grant access in System Preferences/Security & Privacy/Privacy/Accessibility, Input Monitoring, Full Disk Access, etc… to allow Microsoft Outlook, System Events, and your AppleScript Applet to be able to control your computer.

System Events is located here…. /System/Library/CoreServices/System Events.app

I have given those permission as stated in my post. checked again and they are there. still not allowed to send keystrokes.

What would be the etc?

OK Solved it. Running it in Automator as an App works like this.

on run {input, parameters}	
	
	tell application "Microsoft Outlook" to activate
	
	tell application "System Events"
		set frontmost of application process "Microsoft Outlook" to true
		repeat until application process "Microsoft Outlook" is frontmost
			delay 0.1
		end repeat
		tell application process "Microsoft Outlook"
			click menu item "Send & Receive" of menu 8 of menu bar 1
		end tell
	end tell
	
	return input
end run

It also works as a shortcut in the Shortcuts App.

Thanks for your help folks.