3 Replies Latest reply on Nov 13, 2018 11:39 AM by kendall_hiles

    Can I set a keybinding to call a subroutine?

    mjohnson

      In a script I'm working, I'd like to set a keybinding to perform an immediate action or call a subroutine, which doesn't appear to be covered in the automation reference. the automation reference refers to menu commands and external scripts. What I want to do is set a key that, when pressed, toggles a variable in the currently-executing script between true and false.

        • 1. Re: Can I set a keybinding to call a subroutine?
          varunk

          Why do you want to do this?  In other words, what is the original goal?

          • 2. Re: Can I set a keybinding to call a subroutine?
            kendall_hiles

            Like Varun, I would like to know what the use case is but, if this is Xpedition you could try setting and using a Global Variable.  You could change that with a key binding that calls a script that switches that Global variable:

             

                 Scripting.Globals("MyWhackyUseCase") = True

             

             

            your script:

             

                 If Scripting.Globals("MyWhackyUseCase") = True then

                      code

                      code

                      code

                 else

                      different code

                      different code

                      different code

                 end if

             

             

            In the beginning of your script, you will probably need to set the Global to your default value.

            If this is a script for Dx it may or may not work, I'm pretty sure Dx has a Scripting.Globals but, not 100% positive. I do not write many scripts for Dx.

             

            -kendall

            • 3. Re: Can I set a keybinding to call a subroutine?
              kendall_hiles

              It has come to my attention that your question may be how to add a key binding that calls a file:

              keybind.png

               

              You can make the ctrl_3.vbs script do whatever you want.

               

              -kendall