「hmLJ」の例題 外部プロセスの呼び出し概要秀丸マクロから外部プロセスを呼び出す手段自体は提供されていますが、 外部プロセスを呼び出し、結果を文字列で受け取るすでに存在する外部のプロセスを呼び出して処理をする、といったシーンは現在もそれなりに存在します。 #L = loaddll( hidemarudir + "\\" + "hmLJ.dll" ); #_ = dllfunc(#L, "SetStrVar", "g_str_command", "dir"); #_ = dllfunc(#L, "DoFile", currentmacrodirectory + "\\outprocess.lua"); // 外部ファイルの実行 $output = dllfuncstr(#L, "GetStrVar", "output"); // 結果を取得 message($output); freedll( #L ); endmacro; 外部の「.lua」ファイルを用意上記マクロと同じディレクトリに、outprocess.luaというファイルを用意しましょう。 -- os.shell_execute は対象プログラムの出力文字が返ってくる。 -- なお、結果の文字列ではなく、外部プロセス側のリターンコードを受け取る場合には、os.executeで実行してください。 function os.shell_execute(str_command) local handle = io.popen(str_command) local result = handle:read("*a") handle:close() return result end output = os.shell_execute(g_str_command) hm.debuginfo(output) |