Applescript onayından nasıl kurtulurum?


2

Ben bir OS X acemi duyuyorum .

Açılışta çalışmak üzere ayarlanmış bir Applescript'im var ve otomatik olarak çalışmak yerine, komut dosyasını bir çalışma onayıyla tetiklemeliyim:

"Press Run to run this script, or Quit to quit"

Uygulamanın sorunsuz çalışabilmesi için bu durumdan nasıl kurtulurum?

Aşağıdaki dosya bir uygulama olarak kaydedildi.

tell application "Finder"
    activate
    tell application "Finder" to set pathToSound to (((path to me) & "Contents:Resources:TardisTakeoff.m4a") as string) as alias

    tell application "QuickTime Player" to play (open pathToSound)
end tell

tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 107
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)
tell application "System Events"
    key code 113
end tell
delay (0.1)

quit me

1
AppleScript betiğinin içeriğini ve onu nasıl kaydettiğiniz, örneğin bir komut dosyası , uygulama paketi veya uygulama olarak eklemeniz daha yararlı olabilir mi? İkincisi, kullanıcının çalışması için gereken giriş kodunu gerektirmediğini varsayarak otomatik işlemler için daha iyidir .
user3439894

Nasıl bir sorumu içine böyle bir dosya katıştırırım
Nosa Lawani

Düzenle bağlantısını tıklayarak kodu AppleScript'ten sorunuzu kopyalayıp yapıştırabilirsiniz . Yapıştırdıktan sonra, kodu vurgulayın ve araç çubuğundaki Kod örneği düğmesine (kaşlı ayraçlar) basın. Orijinal olarak nasıl kaydettiğinizi belirtmeyi de unutmayın; örneğin, bir komut dosyası , uygulama paketi veya uygulama .
user3439894

Yanıtlar:


2

Komut dosyanızı Komut Dosyası Düzenleyici'de açın. Farklı Kaydet ... yapın (Seçenek tuşunu basılı tutun ve Dosya menüsünde "Çoğalt" "Farklı Kaydet ..." olarak değişir).

Komut dosyanızı bir uygulama olarak kaydettiğinizde, "Başlangıç ​​Ekranını Göster" yazan kutunun işaretli olmadığından emin olun. Ekran görüntüsüme bakın.

Hepsi bu kadar. Eski komut dosyanız "Başlangıç ​​ekranını göster" seçeneği işaretliyken kaydedildi. Şimdi bu seçeneğin ne yaptığını biliyorsun!

AppleScript Başlangıç ​​Ekranı olmadan uygulama olarak kaydetme


Teşekkürler, komut dosyası kendi başına bir uygulama olarak kaydedilmedi, ancak daha büyük bir uygulama klasörünün bir parçası olarak kaydedildi. Ayrıntılı cevabınız nedeniyle, uygulamayı açarak sorunu çözebildim. Başlangıç ​​ekranını gördükten sonra, dosyaya bastım ve programın başlangıç ​​ekranını işaretlemedim. Teşekkürler
Nosa Lawani,

Bu seçeneğin uygulama paketinde nerede kaydedildiğini merak ediyorum, dosyayı kopyalamak ve orijinali silmek yerine sadece bu satırı değiştirebiliyorsunuz ...
DonielF

AppleScript'imi başlangıç ​​ekranı gösterecek şekilde ayarlamamama rağmen, bu onay iletişim kutusunu alıyorum.
iconoclast

Komut dosyasını başlatırken ctrl tuşunun basılı tutulması bu açılır pencerenin gösterilmesine neden oluyor gibi görünüyor . Ctrl içeren bir klavye kısayoluna bağlı bir makro varsa, buna neden olur.
şahin

1

Bu, sorunuzun cevabı değil, kodunuzu nasıl geliştireceğinizin bir örneği .

Kodunuzu inceledikten sonra , System Events anahtar kodunu ve gecikmesini çevreleyen 240 kod satırı, toplamda 3 tekrar ifadesi kullanılarak 14 kod satırında yoğunlaştırılabilir . Kur bir tekrarı 10 kez her biri için açıklama anahtar kodunu ve tekrar 3 kez onu çevreleyen beyanı.

Örnek:

repeat 3 times
    repeat 10 times
        tell application "System Events"
            key code 107
        end tell
        delay (0.1)
    end repeat
    repeat 10 times
        tell application "System Events"
            key code 113
        end tell
        delay (0.1)
    end repeat
end repeat
Sitemizi kullandığınızda şunları okuyup anladığınızı kabul etmiş olursunuz: Çerez Politikası ve Gizlilik Politikası.
Licensed under cc by-sa 3.0 with attribution required.