2018年11月9日金曜日

PPxをランチャとして使う⑧Enterで空欄コマンド


入力欄に何も入力せず、Enterを押したときの挙動にコマンドを割り当てる。
「何も入力しない」をどうやって取得するかだが、引数を受け取ったか否かを判別するスクリプトを作り、それに%edittextを引数として与えることで判別する。
ランチャをすべての操作の起点に据える場合、この操作は最速になる。なのでもっとも日常的に使う頻度が高いコマンドを割り当てるべきだろう。僕はPPCをアクティブにする*focusを割り当てている。

以下をScriptフォルダに保存。

isThisEmpty.js

//!*script

// 引数があれば0を。なければ1を返す
if (PPx.Arguments.Length < 1){
  PPx.Result  = 1;
} else {
  PPx.Result  = 0;
}

以下のようにして使う。

*if %*script(%0\Script\isThisEmpty.js,%E) %: *focus %: *stop


これまでの設定まとめ



  • PPtrayを起動
  • isThidFolder.jsとisThisFIle.jsをScriptフォルダに作成
  • isThisEmpty.jsをScriptフォルダに作成
  • subdirlist.jsをScriptフォルダに作成
  • ファイルパスをまとめたl_cmd.txtをPPxフォルダに作成
  • フォルダパスをまとめたl_dir.txtをPPxフォルダに作成


X_flst = 3,2 ; エントリ補完結果一覧 0:無 1:有 2:OS版 3~5:動的,0:先頭 1:部分

A_exec = { ; エイリアス
NeeView = D:\bin\NeeView\NeeView.exe
aimp = D:\bin\AIMP4\AIMP.exe
xyzzy = D:\bin\xyzzy\xyzzy.exe
weather = *ppv http://wttr.in/kyoto.png
}

K_tray = { ; PPtrayホットキー(キー指定 不可,V_xx 形式を推奨)
^' ' ,*if %*findwindowtitle("PPlauncher") %: *focus !"PPlauncher" %: *stop
 *string o,name=%"PPlauncher"%eh%E %:
 *if %*script(%0\Script\isThisEmpty.js,%so"name") %: *focus %: *stop
 *if %*script(%0\Script\isThisFolder.js,%so"name") %: *ppc -r %so"name" %: *stop
 *if %*script(%0\Script\isThisFile.js,%so"name") %: *execute,"%so"name"" %: *stop
 *execute,%so"name"
}

K_edit = { ; 一行編集/PPe兼用
^\RIGHT ,%Os *string o,dir=%*edittext %:
 *string o,result=%'temp'%\result.txt %:
 *script %0\Script\subdirlist.js,"%so"dir"","%so"result"" %:
 *completelist /file:"%so"result" %:
 *replace ""
^\LEFT ,%Os *string o,dir=%*name(D,"%*edittext") %:
 *string o,result=%'temp'%\result.txt %:
 *script %0\Script\subdirlist.js,"%so"dir"","%so"result"" %:
 *completelist /file:"%so"result" %:
 *replace ""
^W ,*execute ,%Ob browser  "http://google.jp/search?q=%*edittext&ie=utf-8&oe=utf-8" %: %k"&F4"
F12 ,*ppcust %: %k"&F4"
ESC ,%k"&F4"
FIRSTEVENT ,*completelist /set /file:%0l_cmd.txt %: *completelist /set /file:%0l_dir.txt
}

0 件のコメント:

コメントを投稿