macOS Sequoia and keystroke

I have a script using cmd-C and cmd-N keystroke commands. It worked fine for several weeks!
Now, after upgrading my mac to Sequoia it stops working. To be more precise, the “keystroke “c” using {command down}” does no longer set the clipboard content.

Any idea?

This works for me on macOS 15.1 beta5 + SD 8.0.9

use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use scripting additions

tell application "Safari" to activate

tell application "System Events"
	tell process "Safari"
		keystroke "n" using {command down}
	end tell
end tell

Hi Piyomaru,

I ran your script and it works fine on my mac.
But here’s a stripped down version of my code and I see the problem with cmd-C:
the clipboard does NOT contain the table copied.

Any idea?

set inDokName to “/temp/xyz.numbers”
tell application “Numbers”
try
set inDokDia to open inDokName
on error errorMessage number errorNumber
display alert errorNumber message errorMessage
end try

-- select table 1 in sheet 1
tell inDokDia to tell sheet 1 to tell table 1
	set selection range to range "A:W"
end tell

-- copy selected table
tell application "System Events" to tell process "Numbers"
	keystroke "c" using {command down}
	delay 1
end tell

-- open preview and create a new document from clipboard contents
tell application "Preview"
	activate
	delay 1
	tell application "System Events"
		-- click button "Abbrechen" -- of front window
		keystroke "n" using {command down}
	end tell
	delay 1
	
end tell
close inDokDia without saving

end tell – Numbers

You have to activate Numbers.app before Command-C.

Your script may copy Script Debugger contents or Script Editor contents which are located at front.

Joe. GUI scripting with multiple apps tends to be error prone. However, the following script worked on my Sequoia computer. I’ve included numerous large delays just for testing purposes.

--test smaller or no delay values after script works
--it's best not to nest application tell statements

set inDokName to "Macintosh HD:Users:Robert:Working:Test.numbers" --use HFS path

--open file and select range
tell application "Numbers"
	activate
	set inDokDia to open file inDokName --will error if file not found
	if inDokDia is missing value then error number -128
	delay 1
	tell table 1 of sheet 1 of document 1
		set selection range to range "A:B"
	end tell
	delay 1
end tell

--copy selected table
tell application "System Events" to keystroke "c" using {command down}
delay 1

--open preview and create a new document from clipboard contents
tell application "Preview" to activate
delay 1
tell application "System Events" to keystroke "n" using {command down}
delay 1

--close document
tell application "Numbers" to close inDokDia without saving

Hey Piyomaru,

you found it! Activating Numbers before Cmd-D did the job!
Thanks a lot, grab a beer or whatever is your favorite drink!

Hey Peavine,

thanks for your help too!
Same about the drin!