Using Lee Mac's SendKeys Lisp function, I'm trying to send Ctrl+F9.
;; Send Keys - Lee Mac
;; A wrapper function for the SendKeys method of the WSH
;; Reference: http://msdn.microsoft.com/en-us/library/8c6yea83%28v=vs.85%29.aspx
(defun LM:sendkeys ( str / wsh rtn )
(if (setq wsh (vlax-create-object "wscript.shell"))
(progn
(setq rtn (vl-catch-all-apply 'vlax-invoke (list wsh 'sendkeys str)))
(vlax-release-object wsh)
rtn
)
)
)
(defun C:MeasReset ( ) (LM:sendkeys "^{F9}"))
But this always just results in a "nil" and a (separate) F9 press. I've tried "(^{F9})" and "^({F9})" but I can't seem to get the keys to press together.
Any ideas?
^F9 combination works fine for me which launches the Screencast app in recording mode.
When I did not have a command set for Ctrl+F9 I got the same response.
What does your CUI keyboard shortcuts show for Ctrl+F9?
I purposely changed Ctrl+9 to Ctrl+F9 which prompts you to hide the commandline and MeasReset works fine:
I purposely don't have Ctrl+F9 assigned, because I'm not trying to run a command... I'm trying to send Ctrl+F9 to the application.
I have a measuring tool in a statusbar panel in my ARX and Ctrl+F9 zeroes the measurement. Some users want to assign a different shortcut and I was trying to do it with Lisp to avoid having to issue a patch with a separate command for zeroing the tool.
That's what I get too.
Edit: IMHO the code works as expected. It toggles Screencasts. If I turn it off (not active in the background) it toggles snap on/off, which is also Ctrl+F9.
If you don't want to see nil, use (princ) at the end.
(defun C:MeasReset ( ) (LM:sendkeys "^{F9}") (princ))
That app of yours, it has to also have some command that does the job... ?
Well, I initially didn't do it as a command so it would be easier to use while using other commands (e.g., drawing lines). It would be simple to add a command to do it, but then I have to recompile, issue a patch etc., Or users have to wait for the next release. So I was just trying to see if I could Lisp a command to issue my keyboard shortcut, which could in turn be linked to a different shortcut that the user prefers.
Have you tried changing the CTRL+F9 key to an AutoCAD command using the CUI as I've posted?
If that works, then it's your application that's not accepting this shortcut.
If I set a Ctrl+F9 shortcut the outcome is focus dependant. If focus is on the main drawing window, Ctrl+F9 resets my tool (as intended), if the focus is on the command line window Ctrl+F9 executes the specified command.
With the LISP routine and a shortcut set, the LISP always executes the shortcut command.
In short it looks like adding a specific command to my app is the only way forward if my users want to have a different keyboard shortcut.
Can't find what you're looking for? Ask the community or share your knowledge.