LoginSignup
2
2

More than 1 year has passed since last update.

Photoshopレイヤーネームを大きな文字で編集するKeyboard Maestroマクロ

Posted at

レイヤー名変更は老眼につらい仕様

Photoshopレイヤー名は、レイヤーパネルの文字部分をダブルクリックする、またはレイヤーメニュー>レイヤー名の変更で変えられますが、
スクリーンショット 2023-01-10 21.57.38.png
あまりにも小さい!ミスタイプしたまま人に渡すと恥ずかしい!
ということでなんとかできないかやってみました。Keyboard MaestroのカスタムHTMLプロンプトを使います。

こうなります

スクリーンショット 2023-01-10 22.01.58.png
入力してreturnで確定、escでキャンセルします。

KMマクロを作ろう

AppleScriptでレイヤー名取得

tell application id "com.adobe.photoshop" to name of current layer of current document

CustomHTMLPromptを書く

HTMLもCSSもJSXも初心者なので調べまくって書いたやつです。もちろん正しく書ける方は適宜直してください。

escでキャンセルしたかったので…ごちゃごちゃとjavascriptでイベント拾っています。なぜか?type="reset"だとうまく発動しなかった。

<!DOCTYPE html>
<html lang="ja-jp">
<head>
<meta charset="UTF-8">
<title>レイヤー名編集</title>
<style>
#textinput{
border:none;
border-radius:10px;
padding:5px 15px;
font-family:"ヒラギノ角ゴ Pro W3";
font-size:32px;
background-color:#f2f2f2;
width:95%;
}
</style>
<script type="text/javascript">
    document.addEventListener('keydown', function(e) {
    if(e.key === 'Escape'){
    window.KeyboardMaestro.Cancel('');
  }
})
const a = window.KeyboardMaestro.GetVariable('PSLayerName');
    function init1() {
        document.getElementById("textinput").value=a;
        document.getElementById("textinput").focus();
        document.getElementById("textinput").select();
    }
</script>
</head>
<body data-kmwindow="1000,90" onload="init1()">
<form>
<input type="text" id="textinput" name="PSLayerName">
<button type="submit" style="padding:0;border:0;" onclick="window.KeyboardMaestro.Submit()"></button>
</form>
</body>
</html>

inputのnameにKMのVariable書いとくとSubmitしたときに自動で格納されます。CustomHTMLPromptの歯車マークからFloatingとTransparentにチェックいれとくときれい。

戻り値で書き戻すか決めて、OKなら戻す

マクロのifで、The txt:

%HTMLResult%

Cancelなら何もせず、そうでないときにAppleScriptでPhotoshopのレイヤー名にセットします。

tell application id "com.adobe.photoshop"
	tell application "Keyboard Maestro Engine" to set myLN to getvariable "PSLayerName" as text
	set name of current layer of current document to myLN
end tell

マクロDLはこちら(2023/01/10時点のもの)
https://d.pr/f/1q6BUT

問題点

実行時、ウインドウモードだと浮いてるパネルが隠れます。アプリケーションフレームにくっつけて、アプリフレームで実行すればレイヤーパネルも見えたまま実行できます。

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