Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

JavaScript for Automation (JXA)

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  
__S
基本的に個人のメモとして投稿してます
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away