satishrajdev Posted December 12, 2016 Posted December 12, 2016 Hi, I'm trying to send string to clipboard using following function but its not working for me. I have searched for other functions but finding the same function of MP's everywhere. http://www.cadtutor.net/forum/showthread.php?80784-Need-Lisp-code-for-pick-the-text-in-drawing-and-save-in-clipboard http://www.theswamp.org/index.php?topic=21764.msg263322#msg263322 Kindly help me out of this. Regards, Satish. (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 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 ) Quote
Roy_043 Posted December 12, 2016 Posted December 12, 2016 Have you perhaps uninstalled MS Internet Explorer? Quote
satishrajdev Posted December 13, 2016 Author Posted December 13, 2016 No. Its there still I'm facing this problem. Quote
stevesfr Posted December 13, 2016 Posted December 13, 2016 do you have (vl-load-com) installed/loaded ? Quote
Roy_043 Posted December 13, 2016 Posted December 13, 2016 @satishrajdev: If Steve's comment does not help: How do you determine that it does not work, is there an error message? Quote
satishrajdev Posted December 13, 2016 Author Posted December 13, 2016 do you have (vl-load-com) installed/loaded ? Yes. I have done that in my main code @satishrajdev:If Steve's comment does not help: How do you determine that it does not work, is there an error message? It just returns "" and if I check from cntl+V it doesn't matches. Quote
Roy_043 Posted December 13, 2016 Posted December 13, 2016 From the return value I conclude that you are using the function like this?: (_SETCLIPBOARDTEXT "") Do you want to clear all clipboard data?: (defun _ClearClipBoard ( / htmlfile) (vlax-invoke (vlax-get (vlax-get (setq htmlfile (vlax-create-object "htmlfile")) 'ParentWindow ) 'ClipBoardData ) 'ClearData ) (vlax-release-object htmlfile) T ) Quote
tombu Posted December 13, 2016 Posted December 13, 2016 Hi, I'm trying to send string to clipboard using following function but its not working for me. I have searched for other functions but finding the same function of MP's everywhere. http://www.cadtutor.net/forum/showthread.php?80784-Need-Lisp-code-for-pick-the-text-in-drawing-and-save-in-clipboard http://www.theswamp.org/index.php?topic=21764.msg263322#msg263322 Kindly help me out of this. Regards, Satish. Tested with Windows 7 64bit Command: (_SETCLIPBOARDTEXT "Cool!") "Cool!" It pasted fine in a document. What version of Windows are you using? ttechnik's post: https://www.theswamp.org/index.php?topic=21764.msg541448#msg541448 he code is correct. In W2k.... But in W8 not work. Quote
stevesfr Posted December 13, 2016 Posted December 13, 2016 I'm guessing that the command y'all are trying to use is not valid in older Acad versions !! It won't work in AC2008 for example. what version of AC is the OP using ??? Quote
hanhphuc Posted December 13, 2016 Posted December 13, 2016 if setdata failed, would getdata failed too? catch exception? (defun cdata (/ cb html) (if (vl-catch-all-error-p (setq cb (vl-catch-all-apply 'vlax-invoke (list ( '((doc) (foreach x '(parentwindow clipboarddata) (if (not (vl-catch-all-error-p (setq doc (vl-catch-all-apply 'vlax-get (list doc x))))) doc ) ) ) (setq html (vlax-create-object "htmlfile")) ) 'getdata "text" ) ) ) ) "" cb ) ) running in vbscript, see any error? copy this code in notepad then save as "cp.vbs" This vbs source but no longer exists Set objHTML = CreateObject("htmlfile") ClipboardText = objHTML.ParentWindow.ClipboardData.GetData("text") MsgBox ClipboardText example saved in D directory locate & double click the saved "cp.vbs" file to run or you cand invoke using lisp (command "shell" "cscript D:\\cp.vbs") ;or (command "shell" "explorer \"D:\\cp.vbs\"") Try searching msdn documentations many good resources Quote
Roy_043 Posted December 13, 2016 Posted December 13, 2016 Often programs will put several versions of copied data on the clipboard. Only changing the text on the clipboard will *not* remove the other data. This may be the root of the OP's confusion. So a more reliable version of _SETCLIPBOARDTEXT would clear all data first (see my previous post). Quote
satishrajdev Posted December 14, 2016 Author Posted December 14, 2016 From the return value I conclude that you are using the function like this?: (_SETCLIPBOARDTEXT "") You are right, If I do this it returns string After that when I do ctrl+V I don't get "Sat123" text and that's my main concern. _$ (_SETCLIPBOARDTEXT "Sat123") "Sat123" Tested with Windows 7 64bitCommand: (_SETCLIPBOARDTEXT "Cool!") "Cool!" It pasted fine in a document. When I do ctrl+V after the expression I don't get "Cool!" What version of Windows are you using? ttechnik's post: https://www.theswamp.org/index.php?topic=21764.msg541448#msg541448 he code is correct. In W2k.... But in W8 not work. I'm Using Windows 7 64bit. I'm guessing that the command y'all are trying to use is not valid in older Acad versions !!It won't work in AC2008 for example. what version of AC is the OP using ??? I'm aware about that, But I'm using AutoCAD 2013. and We have AutoCAD 2014 to 2016 as well. I tried in all version but no luck. Quote
Roy_043 Posted December 14, 2016 Posted December 14, 2016 To check what I have suggested in my previous post use the _GetClipBoardText function instead of Crl+V to read the text from the clipboard. Quote
Recommended Posts
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.