broncos15 Posted November 16, 2016 Posted November 16, 2016 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? Quote
Lee Mac Posted November 16, 2016 Posted November 16, 2016 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. Quote
Grrr Posted November 16, 2016 Posted November 16, 2016 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}") Quote
broncos15 Posted November 16, 2016 Author Posted November 16, 2016 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. Quote
Lee Mac Posted November 16, 2016 Posted November 16, 2016 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. Quote
Lee Mac Posted November 16, 2016 Posted November 16, 2016 Maybe it could help, but I have no idea how its used Google "LM:sendkeys" for some examples. Quote
Grrr Posted November 17, 2016 Posted November 17, 2016 Google "LM:sendkeys" for some examples. Insane stuff, Lee! 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 ? Quote
Lee Mac Posted November 17, 2016 Posted November 17, 2016 Insane stuff, Lee! I did not knew that LM:sendkeys exist. Thanks! Do you know if are possible key combinations, such as: [Ctrl+C] [Ctrl+V] [Ctrl+A] for example replicating "COPYCLIP" command ? I believe so - see this example: http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/creating-button-to-paste-text-to-command-line-having-trouble/td-p/4814695 Quote
Grrr Posted November 17, 2016 Posted November 17, 2016 I believe so - see this example: http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/creating-button-to-paste-text-to-command-line-having-trouble/td-p/4814695 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. 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.