LoginSignup
2
2

More than 3 years have passed since last update.

JavaScript for Automation (JXA)

Posted at

java scriptでMacを自動化できる

アプリケーションの起動

function run(){
    var app = Application("apps");
}

引数を渡してiTuneで曲を再生

function run(argv){
    if(argv.length == 2){
        console.log(argv[0] + " : " + argv[1] + " を再生します");
        var app = Application("iTunes");
        app.playlists[argv[0]].tracks[argv[1]].play();
    }

    else{
        console.log("'プレイリスト' '曲名' を指定してください");
        }
}

scriptの実行

実行

osascript -l JavaScript sample.js

引数を渡して実行

osascript -l JavaScript sample.js testPlay hoge  
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2