4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

RLoginスクリプトをキーボードショートカットで実行

Last updated at Posted at 2017-10-04

RLoginスクリプトをキーボードショートカットで実行

RLoginにはスクリプト機能がある。
通常はマウスで「ファイル」メニュー→「スクリプトを実行」でスクリプトを選択し実行する。
これは少々面倒くさい。ここでは、キーボートショートカットでスクリプトを実行する方法を紹介する。

手順

(1)コマンド作業をスクリプト化

私はLinuxでCUIアプリケーションを使うことが多いため、そのコマンドをスクリプト化している。
例としてechoするだけのスクリプトをあげておく。

sample1.txt
Document.Open();
wait(CONNECT);
sopen(OPEN_LOCK);

sputs("echo sample1\n");
swait(5, "#");

sclose();
exit(0);

(2)メニューにスクリプトを登録

編集メニューにはスクリプトの関数機能であるfunctionを登録することができる。
登録するスクリプトは以下のようになる。

menu.txt
function sample1(){
    include("sample1.txt");
}

function sample2(){
    include("sample2.txt");
}

function sample3(){
    shellexec("sample3.bat");
}

menu(0, "サンプル1", "sample1");
menu(1, "サンプル2", "sample2");
menu(2, "サンプル3", "sample3");

shellexec()を使用することでバッチファイルをRLoginから実行することもできる。
この時点でスクリプトの実行を試すには「ファイル」メニュー→「スクリプトの実行」でmenu.txtを選択する。
exe_script.PNG
これでメニューにfunctionが登録される。
menu.PNG
sample1.txtを実行するには「編集」メニューから「サンプル1」を実行する。

(3)RLoginのキーカスタマイズ

「キーボード」のところで設定。
key_setting.PNG
これによりAlt+1, Alt+2などにメニューの機能を割り当てることができる。
割り当て後にはメニューにショートカットが表示される。
exec_menu.PNG

(4)実行

Alt+1 でサンプル1を実行。
Alt+2 でサンプル2を実行。
result.PNG

(5)エントリースクリプトの設定

エントリースクリプトに作成したmenu.txtを指定しておく。
接続時にスクリプトが実行されるため、接続のたびに実行しなおす必要がなくなり便利。
enrty_script.PNG

4
4
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
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?