Hi,
You can run those commands by using the command ID (Call pcbAppObj.Gui.ProcessCommand(CommandId,True))
It seems though that .AddKeyBinding does not support running a commandID but you can bind to a script that runs Gui.processcommand(..)
Script to toggle hover snap mode:
'-------------------------------------------------------------------------
'Internal script connect to expedition pcb and get pcbAppObj and pcbDocObj
'-------------------------------------------------------------------------
Dim pcbAppObj 'Application object
Dim pcbDocObj 'Document object
Scripting.AddTypeLibrary("MGCPCB.ExpeditionPCBApplication")' Get the application object.
Set pcbAppObj = Application' Get the active document
Set pcbDocObj = pcbAppObj.ActiveDocument' License the document
ValidateServer(pcbDocObj)
'-------------------------------------------------------------------------
'call GetToolbarCommandId("Snap",5) 'get command id to enter in code
Call pcbAppObj.Gui.ProcessCommand(59417,True)
'=============================================================
Function GetToolbarCommandId(ToolbarName,ButtonLocation)
'=============================================================Dim stdToolBar : Set stdToolBar = Gui.CommandBars(ToolbarName)
if stdToolBar is nothing then
Msgbox "Could not find '" & ToolbarName & "' toolbar.",0+16
elsedim stdTBCtrls : Set stdTBCtrls = stdToolBar.Controls
if stdTBCtrls is nothing then
Msgbox "Error getting controls on '" & ToolbarName & "' toolbar.",0+16
elsefor i = 1 to stdTBCtrls.count
if i = ButtonLocation then
msgbox stdTBCtrls.item(i).id
exit for
end ifnext
end if
end ifend function
'=============================================================
'=============================================================
' Validate server function
'=============================================================
Private Function ValidateServer(doc)Dim key, licenseServer, licenseToken
' Ask Expedition’s document for the key
key = doc.Validate(0)' Get license server
Set licenseServer = CreateObject("MGCPCBAutomationLicensing.Application")' Ask the license server for the license token
licenseToken = licenseServer.GetToken(key)' Release license server
Set licenseServer = nothing' Turn off error messages. Validate may fail if the token is incorrect
On Error Resume Next
Err.Clear' Ask the document to validate the license token
doc.Validate(licenseToken)
If Err Then
ValidateServer = 0
Else
ValidateServer = 1
End IfEnd Function
'=============================================================