05. Home Pictureを設定する
2013-04-23


頻繁にdesktop pictureを手動切替される方向け。切り替えた後で「いつもの絵がいいかな」という場合のためにHome Pictureを設定、戻れるようにしました。
本スクリプトでは、「メモ書き倉庫」さんの「AppleScriptであれこれする」から以下のハンドラを拝借して外部参照しています。
本スクリプトを動作確認される前に、当該ハンドラを皆さんのマックにスクリプトとして保存する必要があります。
[URL]

拙作スクリプトは以下。selection物なのでアプリとした場合は01.のようにウィンドウツールバーやランチャーから使って下さい。

property HomePict : ""
--次のファイルパス指定を書き換えてください
property ExHandler : load script file "MyHD:MyScripts:library:getModifierKeys.scpt"

on setDTP(xxx)
tell application "System Events"
tell current desktop
if picture rotation = 1 then
set picture rotation to 0
end if
set picture to xxx
end tell
end tell
end setDTP

tell application "Finder"
if ExHandler's getModifierKeys() contains "shift" then
set HomePict to selection as alias
set ppp to name of HomePict
display dialog "Home Picture set to " & ppp giving up after 2
my setDTP(HomePict)

else
if (selection is not {}) then
set tgtpict to (selection as alias)
my setDTP(tgtpict)

else
set ppp to name of HomePict
display dialog "Back to Home Picture " & ppp giving up after 2
my setDTP(HomePict)

end if
end if
end tell

動作はスクリプトの内容順に、起動時に
・シフトキーを押しながら画像選択→Home Pictureとして設定
・単純に画像選択→通常のdesktop pictureとして設定
・何もファイル選択無し→Home Pictureへ復帰
エラー処理を全く入れていませんが、わかって使う分にはそれでいいかなと。
ハンドラを使うと、予備処理や繰り返し部分を外に出してスクリプトをわかり易く短縮できますね。
[applescript]
[mac]
[macintosh]

コメント(全0件)
コメントをする


記事を書く
powered by ASAHIネット