Close system dialog with applescript -


is there way click ok button on system dialog applescript? have made workflow on , closing dialog part missing. dialog appears on safari app (since make script work on safari) when button "stop reminders" clicked via javascript function. it's confirmation dialog destructive action (stoping reminders).

enter image description here

clickid("stop reminders button id") --clicking on button need delay 2 -- making sure dialog has enough time appear pressenterbutton() --just trying close  clickid(theid)     tell application "safari"         javascript "document.getelementbyid('" & theid & "').click();" in document 1     end tell end clickid  pressenterbutton()     tell application "system events"         keystroke return     end tell end pressenterbutton 

that's how try now, not works way (it's sad, because when press "enter" on keyboard, works should , dismisses dialog).

@shooteko had point wrapping dialog part of code in

ignoring application responses block

this work existing code.

i tested using adjusted html - javascript code snippet www.w3schools

( added id button. )

the html page test on is:

<!doctype html> <html> <body>  <p>click button demonstrate prompt box.</p>  <button id="mybtn" type="button"" onclick="myfunction()">try it</button>  <p id="demo"></p>  <script> function myfunction() {     var person = prompt("please enter name", "harry potter");      if (person != null) {         document.getelementbyid("demo").innerhtml =         "hello " + person + "! how today?";     } } </script>  </body> </html>  

and code adjusted.

clickid("mybtn") --clicking on button need  delay 2 -- making sure dialog has enough time appear pressenterbutton() --just trying close  clickid(theid)     tell application "safari"         ignoring application responses             activate              javascript "document.getelementbyid('" & theid & "').click()" in document 1         end ignoring     end tell end clickid  pressenterbutton()     tell application "system events"         keystroke return     end tell end pressenterbutton 

Popular posts from this blog