AnsweredAssumed Answered

Running a subroutine with key combination

Question asked by Head1 on Oct 18, 2010
Latest reply on Oct 8, 2018 by mjohnson

Hello everybody,

 

During my short automation experience I have encountered small code  that runs
a program  by typing a combination of Control + another key. ( or Alt)

Example:
' ----------------------------------------------------------
Scripting.AddTypeLibrary("MGCSDD.KeyBindings")

 

Dim docKeyBindTableObj


Set docKeyBindTableObj = pcbApp.Gui.Bindings("Document")

 

Call docKeyBindTableObj.AddKeyBinding("Ctrl+M", _
"run C:\Temp\some_program.txt",BindCommand,BindAccelerator)
' -----------------------------------------------------------
This works fine.


What I am looking for is RUNNING A SUBROUTINE with a key combination,

while the subroutine is written next to the line that runs it. ( Not a stand alone .exe program)

 

Example:

 

Call docKeyBindTableObj.AddKeyBinding("Ctrl+M", "My_sub",BindCommand,BindAccelerator)  ' Probably wrong syntax

' -------------------------------------------------------
Sub My_sub()

   Do_something ,,
   ..
   ..
End sub 
' -------------------------------------------------------

Whenever I try this I get an error.
My sintax is probably wrong.

 

Thanks for helping.

         Head1.

Outcomes