2 Replies Latest reply on Nov 8, 2013 2:12 AM by peter_festesen

    keybind a toolbar function to an accelerator key

    andreas.rehn

      I'm looking for a solution, how to bind a tool bar built-in function to an accelerator key. I want to key bind the hover snap function to "Ctrl+Shift+s".

      Does anybody know how to do this.

      By the way, is there a reference for all built-in function ID's?

       

      Thanks!

        • 1. Re: keybind a toolbar function to an accelerator key
          peter_festesen

          Hi Andreas - for the Function ID list, please use the attached script.

           

          /Peter

          • 2. Re: keybind a toolbar function to an accelerator key
            peter_festesen

            Solution Update

             

            Here is a way to get it done.

            Firstly, it seesm that we cannot 'push a toolbar button' with automation. If someone has gotten that to work, please post.

             

            I tried this code snippet :

             

            **** -start- ****

             

            Set CustomBars = Application.Gui.CommandBars

            Set CustomBar = CustomBars("Snap")

                            For i = 1 to Custombar.controls.count

                                            Set button = Custombar.controls.item(i)

                                            If i = 5 then button.checked = True ' I get cannot set property of builtin button

                            Next 'i

             

            **** -end- ****

             

            Which fails with "Can't set property of builtin button"

             

            But I used another approach. First I used this ( I was only interested in the Hover Snap button (number 5) of the 'Snap' Toolbar)

             

            **** -start- ****

             

            Set CustomBars = Application.Gui.CommandBars

             

            Set CustomBar = CustomBars("Snap")

             

                            For i = 1 to Custombar.controls.count

             

                                            Set button = Custombar.controls.item(i)

             

                                            If i = 5 then MsgBox button.id

             

                            Next 'i

             

            **** -end- ****

            This will give you the function ID for the button. (59417 in my case)

             

            Now, you need to Setup the keybinding, which needs to point to a vbs file. There is an example in the Mentor installtion tree, at

             

            $SDD_HOME/Standard/examples\pcb\Automation\Scripts\

             

            Note : I tried to use the GuiProcessCommand directly in the keybind definition, but couldn't make it work. Again, if someone knows, please reply.

             

            I used this statement to link the keycommand Ctrl-Shift-s to call a vbs script instead.

             

            keyBindTables.AddKeyBinding "Ctrl+Shift+s", "run c:\scripts\ToggleHoverSnap.vbs", BindCommand, BindAccelerator

             

            The last step is to create the ToggleHoverSnap.vbs file, which only contains one single line :

             

            **** -start - ****

             

            Gui.ProcessCommand(59417)

             

            **** -end- ****

             

            Cheers,
            Peter