输入法 反应器
(vl-load-com)(VLR-editor-Reactor nil
'(
(:vlr-commandWillStart . command-will-start)
(:vlr-commandEnded . command-will-ENDED)
) )
(defun command-will-start (reactor command-list)
(cond
( (member (car command-list) '( "DDEDIT" "MTEDIT"))
(Vlax-Invoke-Method(Vlax-Get-Or-Create-Object "WScript.Shell")'Sendkeys "{CAPSLOCK}" )
)
)
)
(defun command-will-ENDED (reactor1 command-list1)
(cond
( (member (car command-list1) '("DDEDIT" "MTEDIT"))
(Vlax-Invoke-Method(Vlax-Get-Or-Create-Object "WScript.Shell")'Sendkeys "{CAPSLOCK}" )
(Vlax-Invoke-Method(Vlax-Get-Or-Create-Object "WScript.Sleep 2000") )
)
)
)
有什么方法能够检测目前的大小写状态呢? 要用API,lisp应该不好搞 使用 DynamicWrapperX 来调用系统API
(setq :VK_CAPITAL 20)
(setq $DWrapX(vlax-create-object "DynamicWrapperX"))
(vlax-invoke $DWrapX 'GetKeyState :VK_CAPITAL) elitefish 发表于 2016-4-18 15:03 static/image/common/back.gif
使用 DynamicWrapperX 来调用系统API
(setq :VK_CAPITAL 20)
看得不是很懂,api没了解过 可以参考下这篇文章
http://bbs.mjtd.com/forum.php?mod=viewthread&tid=85724&extra=page%3D1%26filter%3Dtypeid%26typeid%3D108%26typeid%3D108
elitefish 发表于 2016-4-18 15:16 static/image/common/back.gif
可以参考下这篇文章
http://bbs.mjtd.com/forum.php?mod=viewthread&tid=85724&extra=page%3D1%26filter% ...
看到了,错误: ActiveX 服务器返回错误: 未知名称: "GETKEYSTATE"。
调用(vlax-invoke wrap 'MessageBoxW hCAD "Hello,DynWrap" "Test for API" 2) 可以显示。
elitefish 发表于 2016-4-18 15:16 static/image/common/back.gif
可以参考下这篇文章
http://bbs.mjtd.com/forum.php?mod=viewthread&tid=85724&extra=page%3D1%26filter% ...
看到了,错误: ActiveX 服务器返回错误: 未知名称: "GETKEYSTATE"。
调用(vlax-invoke wrap 'MessageBoxW hCAD "Hello,DynWrap" "Test for API" 2) 可以显示。
漏了一句 申明
(vlax-invoke $DWrapX 'Register "user32.dll" "GetKeyState" "i=l" "r=n") elitefish 发表于 2016-4-18 15:57 static/image/common/back.gif
漏了一句 申明
(vlax-invoke $DWrapX 'Register "user32.dll" "GetKeyState" "i=l" "r=n")
谢谢,粗略的改了一下,不知是否有bug
(DEFUN getcaps()
(setq *APP (vlax-get-acad-object))
(setq *DOC (vla-get-ActiveDocument *APP))
(setq hCAD (vla-get-hwnd *APP))
(setq hDOC (vla-get-hwnd *DOC))
(setq wrap (vlax-create-object "DynamicWrapperX"))
; (vlax-invoke wrap 'Register "user32.dll" "MessageBoxW" "i=hwwu" "r=l")
; (vlax-invoke wrap'GetKeyState:VK_CAPITAL)
(vlax-invoke wrap 'Register "user32" "GetKeyState" "i=l" "r=l")
(vlax-invoke wrap'GetKeyState:VK_CAPITAL)
)
(DEFUN getIMS()
(setq *APP (vlax-get-acad-object))
(setq *DOC (vla-get-ActiveDocument *APP))
(setq hCAD (vla-get-hwnd *APP))
(setq hDOC (vla-get-hwnd *DOC))
(setq wrap (vlax-create-object "DynamicWrapperX"))
; (vlax-invoke wrap 'Register "user32.dll" "MessageBoxW" "i=hwwu" "r=l")
; (vlax-invoke wrap'GetKeyState:VK_CAPITAL)
(vlax-invoke wrap 'Register "user32" "GetKeyboardLayout" "i=l" "r=l")
(if (= (vlax-invoke wrap'GetKeyboardLayout 0 ) -534771708)
(setq ims "SOGOU")
(if (= (vlax-invoke wrap'GetKeyboardLayout 0 ) 67700740)
(setq ims "ENG")
)
)
ims
)
(DEFUN setims()
(setq *APP (vlax-get-acad-object))
(setq *DOC (vla-get-ActiveDocument *APP))
(setq hCAD (vla-get-hwnd *APP))
(setq hDOC (vla-get-hwnd *DOC))
(setq wrap (vlax-create-object "DynamicWrapperX"))
; (vlax-invoke wrap 'Register "user32.dll" "MessageBoxW" "i=hwwu" "r=l")
; (vlax-invoke wrap'GetKeyState:VK_CAPITAL)
(vlax-invoke wrap 'Register "user32" "GetKeyboardLayout" "i=l" "r=l")
(vlax-invoke wrap 'Register "user32" "ActivateKeyboardLayout" "i=l" "r=l")
(if (/= (vlax-invoke wrap'GetKeyboardLayout 0 ) -534771708)
(vlax-invoke wrap'ActivateKeyboardLayout -534771708 )
)
)
(vl-load-com)
(VLR-editor-Reactor nil
'(
(:vlr-commandWillStart . command-will-start)
(:vlr-commandEnded . command-will-ENDED)
) )
(defun command-will-start (reactor command-list)
(cond
( (member (car command-list) '( "DDEDIT" "MTEDIT""eattedit")) ;指令要大写
(IF(=(getcaps) 1)
(Vlax-Invoke-Method(Vlax-Get-Or-Create-Object "WScript.Shell")'Sendkeys "{CAPSLOCK}" )
)
(setims)
)
)
)
(defun command-will-ENDED (reactor1 command-list1)
(IF (=(getcaps) 0)
(Vlax-Invoke-Method(Vlax-Get-Or-Create-Object "WScript.Shell")'Sendkeys "{CAPSLOCK}" )
; (Vlax-Invoke-Method(Vlax-Get-Or-Create-Object "WScript.Sleep 500") )
)
) 暗夜贵族 发表于 2016-4-18 16:35 static/image/common/back.gif
谢谢,粗略的改了一下,不知是否有bug
(DEFUN getcaps()
加个锁定大写开关
(vlr-dwg-reactor
nil
'((:vlr-beginsave . SAVE) )
)
(DEFUN SAVE(OBJ REACT)
(IF (=(getcaps) 0)
(Vlax-Invoke-Method(Vlax-Get-Or-Create-Object "WScript.Shell")'Sendkeys "{CAPSLOCK}" )
)
)
页:
[1]
2