vim OLE issue

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

vim OLE issue

Bruce Who
Hi,

Lately I'm trying to use vim as an external editor in my application. I choose the OLE way to do this:
       
        from win32com.client.dynamic import Dispatch
        VimInst = Dispatch('Vim.Application')

But I have a issues: if there are already vim running. This VimInst is one of the open ones. How to create a new vim instance?
               
    Any help would be appreciated!

Best regards,

               Bruce Who
                   2005-07-29
Reply | Threaded
Open this post in threaded view
|

RE: vim OLE issue

Suresh Govindachar`

Bruce Who Sent on Thursday, July 28, 2005

> Lately I'm trying to use vim as an external editor in
> my application. I choose the OLE way to do this:
>
> from win32com.client.dynamic import Dispatch
> VimInst = Dispatch('Vim.Application')
>
> But I have a issues: if there are already vim running.
> This VimInst is one of the open ones. How to create a
> new vim instance?
>
>     Any help would be appreciated!
 
I don't have an answer for you, but do have a question:  
Can your method be used for making Vim be the editor
for Microsoft Outlook (and for Outlook Express)?
If so, how?

Thanks,

--Suresh

Reply | Threaded
Open this post in threaded view
|

RE: vim OLE issue

Gareth Oakes
In reply to this post by Bruce Who
> I don't have an answer for you, but do have a question:  
> Can your method be used for making Vim be the editor for
> Microsoft Outlook (and for Outlook Express)?
> If so, how?

I'm interested in the answer also :)  We are forced to use Outlook at my
workplace here.. :(

In the meantime I'm using a hacky approach, I think I found in the
vimtips.  I downloaded "clipbrd.vim" and a VBScript (shortcut to
Ctrl+Alt+P).  Basically it copy/pastes your email direct to vim in the
clipboard register.  When you save and quit the clipboard register is
pasted back over the top of your email.  Kludgy but works well enough
most of the time.

Here's the VBScript I use:

set oShell = CreateObject("WScript.Shell")
WScript.Sleep 100
oShell.SendKeys"^a"
WScript.Sleep 100
oShell.SendKeys"^c"
oShell.SendKeys"^{Home}"

vimLocation =
oShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Vim\Gvim\path")
vimCommand = """" + vimLocation + """ +ClipBrd +only"
ReturnCode = oShell.run (vimCommand,0,True)

WScript.Sleep 100
oShell.SendKeys"^a"
WScript.Sleep 100
oShell.SendKeys"^v"
oShell.SendKeys"^{Home}"

----------[CUT]----------

Cheers,
Gareth
Reply | Threaded
Open this post in threaded view
|

Re: vim OLE issue

Pete Johns
On Fri, 2005-07-29 at 03:40:11 -0400, Gareth Oakes sent:
>> I don't have an answer for you, but do have a question:  
>> Can your method be used for making Vim be the editor for
>> Microsoft Outlook (and for Outlook Express)?
>> If so, how?
>
>I'm interested in the answer also :)  We are forced to use Outlook at my
>workplace here.. :(
>
I, too, am forced to use Outlook at work. Cubicle Vim works well
for me: <http://sourceforge.net/projects/cubiclevim>.

Hope this helps;


--paj
--
Pete Johns                                          ICQ: 61363909
http://www.johnsy.com/          MSN: johnsyweb[at]hotmail[dot]com
Tel/Fax: +447092119833       AIM / Jabber / Skype / Y!: johnsyweb
Reply | Threaded
Open this post in threaded view
|

RE: vim OLE issue

Strohhaecker, Bernd
In reply to this post by Bruce Who
> From: Pete Johns, Sent: Friday, July 29, 2005 9:56 AM
> ...
> I, too, am forced to use Outlook at work. Cubicle Vim works well
> for me: <http://sourceforge.net/projects/cubiclevim>.

Me, too :-(

Because I've had some problems with cubiclevim - IIRC with attached files -
I now use an Outlook VBA macro to read my emails with Vim.

For writing emails I simply use copy & paste.

I've manually added two Buttons "EditWithVim" one in Explorer, one in Inspector.

Works fine for me here with a German Outlook 2000.

Regards, Bernd
--

'
' Edit eMail with VIM
'

Option Explicit

Private Declare Function GetTempFileName Lib "kernel32" Alias _
   "GetTempFileNameA" (ByVal lpszPath As String, ByVal lpPrefixString As String, _
   ByVal wUnique As Long, ByVal lpTempFileName As String) As Long

Private Const tmpPath As String = "C:\TEMP\"

Sub EditWithVim()
   Dim myitem As MailItem
   Dim Vim As Object
   Dim ToSend As String
   Dim tmpFile As String
   Dim handle As Integer
   
   Set myitem = Nothing
   If Not Application.ActiveWindow Is Nothing Then
      Select Case Application.ActiveWindow.Class
         Case olExplorer
            If Application.ActiveWindow.Selection.Count > 0 Then
               Set myitem = Application.ActiveWindow.Selection.item(1)
            End If
         Case olInspector
            If Not Application.ActiveInspector Is Nothing Then
               Set myitem = Application.ActiveInspector.CurrentItem
            End If
      End Select
   End If
   
   If Not myitem Is Nothing Then
      tmpFile = Space(256)
      If GetTempFileName(tmpPath, "viM", 0, tmpFile) <> 0 Then
         tmpFile = Left$(tmpFile, InStr(1, tmpFile, Chr$(0)) - 1)

         handle = FreeFile
         Open tmpFile For Output As #handle
         'Print #handle, "From: "; myitem.SenderName; " ["; GetReplyToAddress(myitem); "]"
         'Print #handle, "Date: "; myitem.SentOn
         'Print #handle, "To: "; myitem.To
         'Print #handle, "Subject: "; myitem.Subject, vbCrLf
         Print #handle, myitem.Body
         Close #handle
         
         Set Vim = CreateObject("Vim.Application")
         Vim.SetForeground
         ToSend = ":vi " & tmpFile & vbCrLf & ":set ft=mail" & vbCrLf
         Vim.SendKeys ToSend
         Set Vim = Nothing
      End If
   End If
End Sub

Reply | Threaded
Open this post in threaded view
|

Re: vim OLE issue

A.J.Mechelynck
In reply to this post by Bruce Who
----- Original Message -----
From: "Bruce Who" <[hidden email]>
To: "vim" <[hidden email]>
Sent: Friday, July 29, 2005 4:46 AM
Subject: vim OLE issue


> Hi,
>
> Lately I'm trying to use vim as an external editor in my application. I
> choose the OLE way to do this:
>
> from win32com.client.dynamic import Dispatch
> VimInst = Dispatch('Vim.Application')
>
> But I have a issues: if there are already vim running. This VimInst is one
> of the open ones. How to create a new vim instance?
>
>    Any help would be appreciated!
>
> Best regards,
>
>               Bruce Who
>                   2005-07-29

IIUC, the OLE mechanism doesn't allow you to choose to which instance of
gvim your messages go. You get the first OLE-enabled instance of gvim.

A workaround would be to compile a non-OLE version of gvim, give both
versions different names, register the OLE version using the --register
command-line argument, and do all your editing with the non-OLE version
until or unless you need the OLE capability.


Best regards,
Tony.


Reply | Threaded
Open this post in threaded view
|

Re: vim OLE issue

Bruce Who
Hi,Tony:

>From: "Tony Mechelynck" <[hidden email]>
>
>IIUC, the OLE mechanism doesn't allow you to choose to which
>instance of gvim your messages go. You get the first OLE-enabled
>instance of gvim.
>
>A workaround would be to compile a non-OLE version of gvim, give
>both versions different names, register the OLE version using the
>--register command-line argument, and do all your editing with the
>non-OLE version until or unless you need the OLE capability.
>

Thanks, but that doesn't work for me. I use gvim as a external editor for
my application. I cannot claim the application's users to use non-OLE
version of gvim or OLE version gvim.

_________________________________________________________________
?????=????????????????? MSN Hotmail??  http://www.hotmail.com