TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: mikd on January 08, 2004, 09:30:08 AM

Title: How to check the hotkey?
Post by: mikd on January 08, 2004, 09:30:08 AM
Has anybody ideas how to check does any autocad command or loaded applications use the hotkey?
For example "CO" is used by "COPY" but how to check it without reading acad.pgp?
Title: How to check the hotkey?
Post by: SMadsen on January 08, 2004, 09:35:13 AM
Hey mikd,
Welcome to the forums.

Nope, no ideas (although I do have an idea that it can't be done).
If you're looking for "can CO be called to invoke a command or a loaded app", you could search the acad.pgp and run through the atoms-family searching for C:CO.
Sorry for the vaque answer.
Title: How to check the hotkey?
Post by: hendie on January 08, 2004, 09:35:14 AM
check the help under
Quote
shortcuts (aliases) for commands, table listing of
Title: How to check the hotkey?
Post by: daron on January 08, 2004, 09:37:09 AM
CO as COPY is just an alias to the actual command. You can set it with the pgp file or you could write lisp routines that shorten the name of many functions. Autocad is programmed to know what to look for. Other than that, I don't understand your question.
Title: How to check the hotkey?
Post by: mikd on January 08, 2004, 10:11:17 AM
Thanks all
I have idea that for some my routines user be able to change the shortcut by own and programm should notify if it already used.
Title: How to check the hotkey?
Post by: Mark on January 08, 2004, 10:15:40 AM
So you are planning on reading the pgp file?
Title: How to check the hotkey?
Post by: daron on January 08, 2004, 10:18:16 AM
The best way I've found to do what I think you're trying to say is, type the command before writing it. If you don't get "Unknown command "cmd-name". Press F1 for help." then you need to consider a different name.

BTW, where are you hailing from. Your English is difficult to read.
Title: How to check the hotkey?
Post by: ELOQUINTET on January 08, 2004, 10:44:22 AM
or if you have express tools just use alias editor. like daron i'm not sure what you're asking...
Title: How to check the hotkey?
Post by: mikd on January 08, 2004, 10:46:40 AM
Sorry for my English,
I am from Kazakhstan
I plan there steps:

- aks user about shortcut
- check it if it doesn't use write tmp.lsp with this shortcut
- and load this file

But if this shotcut use any other routine last one doesn't work...
As a poor solution I can create a list file of shortcut for all loaded routines read the pgp file... I don't like this it may work too slow
Title: How to check the hotkey?
Post by: SMadsen on January 08, 2004, 10:58:38 AM
You could set up a command reactor that reports unknown commands. Only problem is how to stop commands that do exist  :D

Running through all items in the atoms-family that starts with C: is pretty fast and so is reading the .pgp file (just remember to close it after reading). I wouldn't worry about speed.

If your users are using A2K4, remember to look up the .pgp belonging to their profiles.
Title: How to check the hotkey?
Post by: daron on January 08, 2004, 11:02:52 AM
Kazakhstan, huh. So your primary language is Russian?
Title: How to check the hotkey?
Post by: Keith™ on January 08, 2004, 11:07:32 AM
For the LISP counterparts you could test the existence of a command by using this syntax...

(= nil lispcommand)

Exmaple ...

(= nil C:CO)

If there is a command C:CO then it will return nil, if it does exist then it will return T and you will know the lisp command exists.

I am not sure about PGP aliases
Title: How to check the hotkey?
Post by: daron on January 08, 2004, 11:12:29 AM
This is what I got when I tried it
Quote
Command: (= nil C:C)
T
Command: (= nil C:MOVE)
T
Command: (= nil C:WHATSITALLABOUT)
T
Command: (= nil C:ESA)
nil

Title: How to check the hotkey?
Post by: deegeecees on January 08, 2004, 11:17:42 AM
try this:

at the command prompt, type   (atoms-family 1)
this will give you a list of strings of all defined functions, is that what you are asking?
Title: How to check the hotkey?
Post by: Keith™ on January 08, 2004, 11:26:02 AM
oops I was thinking faster than I was typing and forgot a few words...

the fact is....
If the return value is T then the the command name equals NIL and as such does not exist.

If the return value is NIL, then the command does exist because it is already set to a value...
Title: How to check the hotkey?
Post by: mikd on January 08, 2004, 11:48:01 AM
Dear Ladies and Gentlemen thank you very much for your support!
- The statement (= nil C:SOMETHING) return T if there is AutoCAD command or aliases
- The nice line (atoms-family 1) return the names of all lisp (and maybe arx) functions with “C:bla-bla” and without it.
All of there a check more carefully and post result.
Great! Thank you very much!
Title: How to check the hotkey?
Post by: SMadsen on January 08, 2004, 11:50:46 AM
Here's one that could be used to locate a shortcut in the pgp file. If found, it returns the shortcut, otherwise nil:

(doesThisShortcutReallyExist? "CO")
"CO"

(doesThisShortcutReallyExist? "COPYCAT")
nil

Oh, you might want to change the function name :)

Code: [Select]
(defun doesThisShortcutReallyExist? (shortcut / chrlst ln pgp pgpfo pos)
  (cond ((setq pgp (findfile "acad.pgp"))
         (setq pgpfo (open pgp "r"))
         (while (setq ln (read-line pgpfo))
           (and (/= (substr ln 1 1) ";")
                (setq pos (vl-string-position (ascii ",") ln))
                (setq chrlst (cons (substr ln 1 pos) chrlst))
           )
         )
         (close pgpfo)
        )
  )
  (car (member shortcut chrlst))
)
Title: How to check the hotkey?
Post by: SMadsen on January 08, 2004, 11:58:06 AM
And to search in the atoms list:

(doesThisCommandExistAsALoadedApplication? "APO")
"C:APO"

(doesThisCommandExistAsALoadedApplication? "APOOH")
nil

Code: [Select]
(defun doesThisCommandExistAsALoadedApplication? (cmd)
  (car (member (strcat "C:" cmd) (atoms-family 1)))
)
Title: How to check the hotkey?
Post by: deegeecees on January 08, 2004, 12:05:51 PM
Mikd,
Your welcome. If you or your administrator installed AutoCAD with the help sections included, I know that from version 2000 on, there is a "Developers Help" section that has a vast amount of information to help you along on your path to enlightenment in the world of AutoCAD. I know that finding something such as "atoms-family" is a bit of a stretch, but take some time out to peruse this volume as it will enrich your life as well as your soul.
Title: How to check the hotkey?
Post by: kerryb on January 08, 2004, 05:14:50 PM
If you have Express Tools :

ALIASEDIT  at the command line gives a listing of PGP commands.