Skip to content

Instantly share code, notes, and snippets.

@t2psyto
Forked from valda/emacsclientw.vbs
Last active August 29, 2015 14:22
Show Gist options
  • Select an option

  • Save t2psyto/5e2491606f521bc3e5cd to your computer and use it in GitHub Desktop.

Select an option

Save t2psyto/5e2491606f521bc3e5cd to your computer and use it in GitHub Desktop.
emacsclient のラッパスクリプトemacs.exe プロセスの有無と引数の有無に応じて startup_emacs.exe、startup_emacsclient.exe を起動。
'
' 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
@t2psyto

t2psyto commented Jun 2, 2015

Copy link
Copy Markdown
Author

プロセス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