Applescipt to click OK button in Safari

I copied this script from a previous post to enable Private Browsing upon launching Safari web browser.

tell application "Safari" to activate
tell application "System Events"
tell process "Safari" to click menu item "Private Browsing" of menu "Safari" of menu bar 1
end tell

The script works like a charm but I want to extend it to click the OK button and close the Private Browsing dialog box. What do I need to add to this script to achieve this. Everything I’ve tried has failed.

-Xstatical :confused:

Add

keystroke return

like this

tell application "Safari" to activate
tell application "System Events"
	tell process "Safari" to click menu item "Private Browsing" of menu "Safari" of menu bar 1
	keystroke return
end tell

I’m a newbie to scripting but I can’t believe I didn’t try this. Thankyou for your advice.