Click Button in Confirm Replace Dialog

Hello,

i am trying to write a small script to automate saving (includes replacing) a MacDown document and sending it to a server. The problem is, that i can’t click the “Replace” Button of the confirm dialog of the save dialog. I just don’t know how to access this button.

Below is what i got.

Thank already!


tell application "MacDown"
	activate
end tell

tell application "System Events" to tell process "MacDown"
	keystroke "e" using {command down, option down}
	click button "Save" of sheet 1 of window 1
	click button "Replace" ???
end tell

The button [Replace] doesn’t belong to a sheet belonging to the main window.
I don’t know the application MacDown but I guess that it belongs to a sheet belonging directly to the process.

Try :

tell application "MacDown"
	activate
end tell

tell application "System Events" to tell process "MacDown"
set frontmost to true
	keystroke "e" using {command down, option down}
	click button "Save" of sheet 1 of window 1
		repeat
			if exists sheet 1 then exit repeat
			delay 0.1
		end repeat
	tell sheet 1
	click button "Replace" 
	end tell
end tell

Yvan KOENIG running El Capitan 10.11.2 in French (VALLAURIS, France) samedi 19 décembre 2015 23:55:34