关于剪切板操作的三个函数

(defun ClearClipBoard ()
  (startapp "cmd /c \"echo off | clip\"")
)                                        ; (clearclipboard)

(defun _SetClipBoardText (text / htmlfile result)
  ;;  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 <a href=\"http://tinyurl.com/2ngf4r.\" target=\"_blank\">http://tinyurl.com/2ngf4r.</a>

  (setq        result
         (vlax-invoke
           (vlax-get
             (vlax-get
               (setq htmlfile (vlax-create-object "htmlfile"))
               'ParentWindow
             )
             'ClipBoardData
           )
           'SetData
           "Text"
           text
         )
  )
  (vlax-release-object htmlfile)
  text
)                                        ;( _SetClipBoardText "testing")

(defun _GetClipBoardText (/ htmlfile result)
  ;;  Attribution: Reformatted version of
  ;;  post by Patrick_35 at theswamp.org.
  ;;
  ;;  See <a href=\"http://tinyurl.com/2ngf4r.\" target=\"_blank\">http://tinyurl.com/2ngf4r.</a>
  (setq        result
         (vlax-invoke
           (vlax-get
             (vlax-get
               (setq htmlfile (vlax-create-object "htmlfile"))
               'ParentWindow
             )
             'ClipBoardData
           )
           'GetData
           "Text"
         )
  )
  (vlax-release-object htmlfile)
  result
)                                        ;(setq test (_GetClipBoardText))

猜你喜欢

转载自www.cnblogs.com/mjgw/p/12459495.html