vim映射可以触发Autohotkey宏吗?


0

我想使用vim映射触发Autohotkey宏,这可能吗?例如,要在vim中创建正常模式的vim映射以输入CTRL-J,然后使用该映射来触发Autohotkey。

在vim中:

:nnoremap ,w <ctrl-j>

AutoHotkey的

^j:: do something

当我这样做时,CTRL-J在键盘上进行物理键入会成功触发Autohotkey宏,但vim映射不会。

Answers:


1

您可以使用ImageSearch,因为您知道VIM状态栏的坐标是INSERT,您可以使用SetTimer来检查每200毫秒是否发现INSERT(当然,您必须先捕获/创建图像)。如果可以找到,则可以将切换变量设置为true或false,并且可以将该切换变量与#If语句一起使用。

看起来像这样

Toggle:=false
SetTimer, Label, 200
Return

#If Toggle
; hotkeys/hotstrings etc
#If

label:
IfWinNotActive, ahk_exe gvim.exe
   {
    toggle:=false
    return
   }
ImageSearch.... ; 
If (ErrorLevel = 0) ; image found
   {
    toggle:=true
    return
   }
Return

我看到我误解了这个问题。我在上面留下了答案,因为它可能对将来的某个人有用,但是您希望VIM触发AutoHotkey。也许您可以使用:!<cmd>运行脚本?
lintalist '16

1

由于AutoHotkey侦听实际的键盘事件,并且不知道任何特定应用程序内部发生的事情,并且由于Vim的映射在触发时实际上并未发送新的键盘事件,因此不会。您可以创建仅针对Vim的AutoHotkey宏:

SetTitleMatchMode, RegEx
#IfWinActive, - G?VIM\d*$
:*?:`,w::
    do something
    return
#IfWinActive

但这具有无论Vim处于哪种模式都触发的缺点,因为AutoHotkey无法知道Vim是否处于正常模式。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.