; Add_Layer_with_ID.ahk ; ▽ 概要 ; 新規レイヤー作成時に inkscape:label(レイヤー名)と LayerID(svg:g id="名前")を ; 同じ名前にするマクロです。 ; ▽ 使い方 ; Add_Layer_with_ID.ahk を実行するとInkscapeの「レイヤーを追加」ダイアログを開くので、 ; 任意の名前を入力してください。 ; 何も入力せずにokした場合はInkscapeが自動で付ける名前(Layer#連番)に従います。 ; ただし、同ダイアログで「現在のレイヤーの背面」や「サブレイヤー」を選択した時には ; 正しく動作しないのでご注意ください。 ; ▽ 仕様 ; 現在アクティブなレイヤーに関わらず、常に最前面のレイヤーを作成します。 ; 背面レイヤーやサブレイヤーにする場合、レイヤーパレットかXMLエディタを使用して順序を ; 入れ替えなければなりません。 ; また、作成後のレイヤーを後でリネームしてもIDは変わりません。 ; 2回続けて(作成したレイヤーが空のまま)実行すると、遅延時間に関わらず高確率で失敗 ; (Inkscapeが強制終了)する場合があります。 ;SetKeyDelay, 40 Process, Exist, inkscape.exe If ErrorLevel <> 0 { SetTitleMatchMode, 2 WinActivate, - Inkscape WinGetTitle, caption, A StringReplace, str, caption, %A_Space%- Inkscape,, IfInString, str, %A_Space%(outline), StringReplace, str, str, %A_Space%(outline),, IfInString, str, \, SplitPath, str, str ;Editor = %str%: XML Editor (Shift+Ctrl+X) Editor = %str%: XMLエディタ(X) (Shift+Ctrl+X) IfWinNotExist, %Editor% { Send, +^x ;WinWaitActive, XML Editor (Shift+Ctrl+X) WinWaitActive, XMLエディタ(X) (Shift+Ctrl+X) WinGetTitle, Editor, A } SetTitleMatchMode, 1 WinActivate, %caption% Send, !z+{Tab}{Home}!la Loop{ Sleep, 1000 ;IfWinNotExist, Add Layer IfWinNotExist, レイヤーを追加 { Sleep, 500 break } } BlockInput, Send WinActivate, %Editor% Sleep, 40 Send, {Click, 53, 72}^{End}{Space}{Tab}^{End}{Space}^a^c Sleep, 40 FoundPos := RegExMatch(Clipboard, "svg\d+\s\t") If (FoundPos = 1) { ;MsgBox,16,,error. id = "svg2" Send, ^{Tab 2}^{End}{Space}{Tab}^{End}{Space}^a^c ClipWait Sleep, 500 } Send, +{Tab 3}^{Home}{Space}^a^v Sleep, 40 Send, ^{Enter} WinActivate, %caption% Send, !z+{Tab}{Down} } else{ MsgBox, 16, error, Inkscapeが起動していません。`nスクリプトを終了します。 ExitApp } BlockInput, Off return