Jump to content

Problem with lisp routine - copy to clipboard does not work on Windows 8.1


MJLM

Recommended Posts

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 [url]http://tinyurl.com/2ngf4r[/url].

   (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

Edited by MJLM
Link to comment
Share on other sites

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

Edited by hanhphuc
scr variable localized
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...