-
-
Save t2psyto/5e2491606f521bc3e5cd to your computer and use it in GitHub Desktop.
emacsclient のラッパスクリプトemacs.exe プロセスの有無と引数の有無に応じて startup_emacs.exe、startup_emacsclient.exe を起動。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' | |
' C:\gnupack_devel\emacsclientw.vbs | |
' | |
Set objShell = WScript.CreateObject("WScript.Shell") | |
Set fso = CreateObject("Scripting.FileSystemObject") | |
strComputer = "." | |
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") | |
Set colItems = objWMIService.ExecQuery("Select * From Win32_Process") | |
Dim emacsProcess | |
emacsProcess = null | |
For Each objItem in colItems | |
If InStr(objItem.CommandLine, "emacs.exe") Then | |
Set emacsProcess = objItem | |
End If | |
Next | |
If WScript.Arguments.Count >= 1 Then | |
ReDim args(WScript.Arguments.Count-1) | |
For i = 0 To WScript.Arguments.Count-1 | |
args(i) = WScript.Arguments(i) | |
Next | |
strArgs = """" & Join(args, """ """) & """" | |
If IsNull(emacsProcess) Then | |
objShell.Run("""" & fso.GetParentFolderName(WScript.ScriptFullName) & "\startup_emacs.exe"" " & strArgs) | |
Else | |
objShell.Run("""" & fso.GetParentFolderName(WScript.ScriptFullName) & "\startup_emacsclient.exe"" " & strArgs) | |
End If | |
Else | |
If IsNull(emacsProcess) Then | |
objShell.Run("""" & fso.GetParentFolderName(WScript.ScriptFullName) & "\startup_emacs.exe""") | |
Else | |
objShell.AppActivate("emacs ") | |
End If | |
End If |
プロセスID指定で「objShell.AppActivate emacsProcess.ProcessID」してもアクティブにならなかった。。
emacsウィンドウが最小化状態だとAppActivateしても前面に出てこない。。
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
gnupack用にstartup_emacs.exeを使うようにした。
ファイルが複数渡された場合、全部開くようにした。