スクリーンショットの保存形式を調べる

スクリーンショットの保存形式を調べるAppleScriptです。

set aRes to adjustSaveFormat() of me

on adjustSaveFormat()
try
set aRes to do shell script "defaults read com.apple.screencapture type"
return aRes
on error
return false
end try
end adjustSaveFormat

スクリーンショットの保存形式を初期状態に戻す

スクリーンショットの保存形式を初期状態に戻すAppleScriptです。

set aRes to adjustSaveFormat() of me
if aResfalse then
do shell script "defaults delete com.apple.screencapture type && killall SystemUIServer"
display notification "Done!" with title "設定状態"
else
display notification "設定されていません" with title "設定状態"
end if

on adjustSaveFormat()
try
set aRes to do shell script "defaults read com.apple.screencapture type"
return aRes
on error
return false
end try
end adjustSaveFormat

スクリーンショットの保存形式を指定のものにする

スクリーンショットの保存形式を指定のものにするAppleScriptです。

set aRes to choose from list {"BMP", "GIF", "JPEG", "JPEG 2000", "Open EXR", "PDF", "PNG(デフォルト)", "TGA", "TIFF"} with title "保存形式"
if aRes = false then return

set aRes to aRes as string
if aRes = "BMP" then
changeSaveFormat("bmp") of me
else if aRes = "GIF" then
changeSaveFormat("gif") of me
else if aRes = "JPEG" then
changeSaveFormat("jpg") of me
else if aRes = "JPEG 2000" then
changeSaveFormat("jp2") of me
else if aRes = "Open EXR" then
changeSaveFormat("exr") of me
else if aRes = "PDF" then
changeSaveFormat("pdf") of me
else if aRes = "PNG(デフォルト)" then
--changeSaveFormat("png") of me
set aRes to adjustSaveFormat() of me
if aResfalse then
do shell script "defaults delete com.apple.screencapture type && killall SystemUIServer"
end if
else if aRes = "TGA" then
changeSaveFormat("tga") of me
else if aRes = "TIFF" then
changeSaveFormat("tiff") of me
end if

on changeSaveFormat(saveFormat)
try
do shell script "defaults write com.apple.screencapture type" & " " & saveFormat & " && killall SystemUIServer"
return true
on error
return false
end try
end changeSaveFormat

on adjustSaveFormat()
try
set aRes to do shell script "defaults read com.apple.screencapture type"
return aRes
on error
return false
end try
end adjustSaveFormat

macOS Catalina 10.15.4で動作を確認しています。

更新履歴

inserted by FC2 system