Jump to content

Paste Special Using Visual LISP Sendkeys


Recommended Posts

Posted

I often copy over Excel spreadsheets into AutoCAD using the Paste Special -> Paste Link -> Microsoft Excel Worksheet option. I have been messing around with the code for a while, but I cannot find anyway to bypass the paste special menu option. My only remaining thought is to make use of the sendkeys function, but I haven't ever used it, and I am unsure how to use it within a dialogue box. Does anyone have any suggestions?

Posted

Since LISP runs in the AutoCAD GUI processor thread, only sequential evaluation is possible, therefore when the PASTESPEC command is issued, AutoLISP evaluation would cease until the active command completes and focus returns to the AutoLISP program.

 

You may be able to achieve this using AutoHotkey/WinAutomation/Jitbit etc.

Posted

This was posted by irneb somewhere:

; (SendKeys "{ENTER}") ;Sends the Enter key to the active window
; (SendKeys "{ESCAPE}") ;Sends the Esc key to the active window
(vl-load-com)
(defun SendKeys (keys / ws) ; irneb
 (setq ws (vlax-get-or-create-object "WScript.Shell"))
 (vlax-invoke-method ws 'SendKeys keys)
(vlax-release-object ws)
)

Maybe it could help, but I have no idea how its used although I tried something (not related to your problem):

; Working about this idea (NOT WORKING YET):
_$ (vl-string->list "_.CIRCLE")
(95 46 67 73 82 67 76 69)
_$ (mapcar 'chr (vl-string->list "_.CIRCLE"))
("_" "." "C" "I" "R" "C" "L" "E")

(mapcar '(lambda (x) (SendKeys (strcat "{" x "}"))) (mapcar 'chr (vl-string->list "CIRCLE")))
(SendKeys "{ENTER}")

Posted
Since LISP runs in the AutoCAD GUI processor thread, only sequential evaluation is possible, therefore when the PASTESPEC command is issued, AutoLISP evaluation would cease until the active command completes and focus returns to the AutoLISP program.

 

You may be able to achieve this using AutoHotkey/WinAutomation/Jitbit etc.

Thanks Lee, that was very informative! Do you happen to know if there is any equivalent function to paste special in Visual LISP (I can't find any, but I wasn't sure if there was some undocumented one). If not, I'll start to look into the AutoHotKey type of options.
Posted
Do you happen to know if there is any equivalent function to paste special in Visual LISP.

 

Not that I know of; I would say that you would need to build the OLE object and any supporting dictionaries if pursuing this route.

Posted
Google "LM:sendkeys" for some examples. ;)

Insane stuff, Lee! :o

I did not knew that LM:sendkeys exist.

 

Do you know if are possible key combinations, such as: [Ctrl+C] [Ctrl+V] [Ctrl+A] for example replicating "COPYCLIP" command ?

Posted

Thanks!

This opens some possibilities, like running a code just by copying to clipboard from external text editor:

(defun C:test ( ) (LM:sendkeys "^v~") (princ))

Sample code to be copied to clipboard:

(defun ItsWorking ( / ) 
(alert "Its working!") 
(princ)
) 
(ItsWorking)

I think I'll figure something else as this is fairly new for me. :)

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...