• Eine Frage an die Apple-Scripter...

    Ich habe hier was unspektakuläres:

    tell application "Mail"
    close front window of application "Mail"
    end tell

    Nun ist das vordere Fenster beim Aufruf eine offene Mail. Deshalb kommt die Abfrage "Diese Mail als Entwurf sichern?" mit den Buttons "Nicht sichern", "Abbrechen" und "Sichern"
    Ich möchte das Fenster nun mit "Sichern" schließen. Wie mache ich das in AS?

    Vielen Dank für Hilfen jeder Art
    ----------
    Danke und Tschüß
    Udo
    • das geht nur mit GUI scripting…

      Show Plain Text
      1. tell application "Mail"
      2.   activate
      3.   close front window
      4. end tell
      5. delay 0.5
      6. tell application "System Events"
      7.   tell process "Mail"
      8.     if exists sheet 1 of window 1 then
      9.       click button 2 of sheet 1 of window 1
      10.     end if
      11.   end tell
      12. end tell
      ----------
      Gruss

      Stefan
      • Vielen Dank, leider klappt das hier nicht so richtig.

        Ich habe nun folgenden Code:

        Show Plain Text
        1. tell application "Mail"
        2.   set newMessage to make new outgoing message with properties {visible:true, subject:"hans@wurst.de", content:"Nix als Laberei"}
        3.   tell newMessage
        4.     make new to recipient at end of to recipients with properties {name:"Paul", address:"paul@klee.de"}
        5.   end tell
        6.   close front window
        7. end tell
        8.  
        9. delay 0.5
        10.  
        11. tell application "System Events"
        12.   tell process "Mail"
        13.     if exists sheet 1 of window 1 then
        14.       click defaultbutton of sheet 1 of window 1
        15.     end if
        16.   end tell
        17. end tell


        Das Fenster wird leider nicht geschlossen. Nicht mit "defaultbutton" und auch nicht mit button 0 bis 3.

        Vielen Dank für Deine Mühe, Stefan. Das muss jetzt auch ohne gehen Die generierten Mails sollen sowieso abgeschickt werden. Es wäre einfach nur schöner gewesen.
        Das kann jetzt auch erstmal so bleiben, ohne Fenster zu.

        Viele Grüße
        Udo
        ----------
        Danke und Tschüß
        Udo
        • sag das doch gleich, dass die Mail per script erzeugt wurde, dann ist es ganz einfach

          ohne das GUI scripting Zeug
          Show Plain Text
          1. tell application "Mail"
          2.   set newMessage to make new outgoing message with properties {visible:true, subject:"hans@wurst.de", content:"Nix als Laberei"}
          3.   tell newMessage
          4.     make new to recipient at end of to recipients with properties {name:"Paul", address:"paul@klee.de"}
          5.   end tell
          6.   save newMessage
          7.   close front window
          8. end tell


          oder setze visible auf false, dann wird gar kein Fenster geöffnet
          ----------
          Gruss

          Stefan
          • Sei froh, dass du nicht direkt neben mir sitzt....

            ... dafür hast du dir einen dicken Knutscher verdient! )

            Vielen Dank, das macht jetzt vieles einfacher.

            Tschüß
            Udo
            ----------
            Danke und Tschüß
            Udo