4
3

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.

EmEditorでPowerShellコマンドを実行し、入力補助機能として使用するためのマクロ

Last updated at Posted at 2016-09-17

サクラエディタでPowerShellコマンドを実行し、入力補助機能として使用するための3行マクロ
に感銘を受けたので、EmEditor版を作りました。

var Result = "<Error>\n";
var CommandText = document.selection.Text;
CommandText = CommandText.replace(/"/g,'\\"');
var WshShell = new ActiveXObject("WScript.Shell");
var ExecCmd = WshShell.Exec('powershell -command "' + CommandText + '"');
while (ExecCmd.Status == 0) {
	Sleep(10);
}
if (ExecCmd.ExitCode == 0) {
	Result = ExecCmd.StdOut.ReadAll();
}
document.selection.Text = Result;
document.selection.CharLeft(1);
document.selection.Delete(1);

JScriptでマクロが動くエディタであれば、EmEditorでなくても動くかもしれません。

4
3
1

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
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?