Custom commands and shortcuts

Custom commands and shortcuts

damir_vidakovic
Enthusiast Enthusiast
484 Views
1 Reply
Message 1 of 2

Custom commands and shortcuts

damir_vidakovic
Enthusiast
Enthusiast

I am trying to implement a way for the user so he can define a shortcut for some different custom commands. 

I can implement it in a several ways, and it is not a problem in general. What I'm trying to find is a list of current shortcuts in AutoCAD, because I would like when user tries to set new shortcut for a custom command (e.g. CTRl+ something), that I tell him if this shortcut was used already, and for what. Is it possible to get current shortcuts from code?

---------------------
Damir Vidakovic
www.studioars.com
0 Likes
485 Views
1 Reply
Reply (1)
Message 2 of 2

moogalm
Autodesk Support
Autodesk Support

Hi

Command Key bindings are stored Shortcut Key node of CUIX

You can retrieve

 public static void GetShortCutKeys()
        {
            string mainCuiFile = (string)Application.GetSystemVariable("MENUNAME");
            mainCuiFile += ".cuix";
            var doc = Application.DocumentManager.MdiActiveDocument;
            var db = doc.Database;
            var ed = doc.Editor;
            CustomizationSection cs = new CustomizationSection(mainCuiFile);
            AcceleratorCollection acCollection = cs.MenuGroup.Accelerators;
            Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
            foreach (MenuAccelerator menuAcltr in acCollection)
            {
                ed.WriteMessage(String.Format("{0}\t:\t{1}",menuAcltr.ShortcutName(),menuAcltr.ShortcutKey()) + "\n");
                keyValuePairs.Add(menuAcltr.ShortcutName(), menuAcltr.ShortcutKey());
            }
           
        }
0 Likes