MJLM 发表于 2022-7-5 22:22:55

Problem with lisp routine - co

I have this routine which I found on this or an other forum.
 
 

(defun ctc ( text / htmlfile result )         (vl-load-com)   ;;Caller's sole responsibility is to pass a   ;;text string. Anything else? Pie in face.   ;;Attribution: Reformatted version of   ;;post by XShrimp at theswamp.org.   ;;   ;;See http://tinyurl.com/2ngf4r.   (setq result       (vlax-invoke         (vlax-get               (vlax-get                   (setq htmlfile (vlax-create-object "htmlfile"))                  'ParentWindow               )            'ClipBoardData         )          'SetData         "Text"         text       )   )   (vlax-release-object htmlfile)   text)
 
It basically copies a string into the clipboard. However I just updated to windows 8.1 64bit and it doesn't work. I tried it at work too and it doesn't work on windows 7 64 bit either. Any ideas why or how to resolve the issue?
Any other routine that works for someone in windows 8.1 64 bit?
 
Thank you

hanhphuc 发表于 2022-7-5 23:26:48

sorry i'm not using Win8 x64,
i just try to translate your
XSrimp's code to vb script, then invoke the tmp.vbs see whether working?

(defun c:test (/ scr f tmp)(setq f (open (setq tmp (strcat (getvar "TEMPPREFIX") "tmp.vbs")) "w")) (foreach $ '("Set htmlfile = CreateObject(\"htmlfile\") "       "Text = htmlfile.ParentWindow.ClipboardData.GetData(\"text\")"       "MsgBox Text"       ) ;_ end of setq   (write-line $ f)   ) ;_ end of foreach (close f) (setq scr (vlax-create-object "wscript.shell")) (vlax-invoke scr 'run (strcat "cscript " tmp)) (vlax-release-object scr) (startapp "notepad" tmp) ) ;_ end of defun
 
This another test whether clipboard text can be retrieve?

(defun get_cb ( / scr txt) ; (setq scr (vlax-create-object "ScriptControl")) (vlax-put scr 'language "vbs") (vlax-invoke-method scr 'ExecuteStatement "Set htmlfile = CreateObject(\"htmlfile\")Text = htmlfile.ParentWindow.ClipboardData.GetData(\"text\")") (setq txt (vlax-invoke-method scr 'eval "Text")) (vlax-release-object scr) txt ) ;_ end of defun
after evaluate the code try this,
(initially make sure you get something "text" copied)

(alert (get_cb)) ;
if none of this help, then you need to refer MSDN support or other VB expert
页: [1]
查看完整版本: Problem with lisp routine - co