I know this is a MEP forum but if it can help anyone this is a sample command in C# that will create a button in a addin tab that will simulate the click on connect into, then you can assign this button to a shortcut command... You will need to understand a bit of revit API and programming but there are plenty of tutorials out there.
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using System.Windows.Automation;
namespace RTG.Addin.DISCIPLINAS.HID;
[Transaction(TransactionMode.Manual)]
public class ConnectInto26 : IExternalCommand
{
private UIApplication Uiapp;
private UIDocument Uidoc;
private Document Doc;
private View VistaAtiva;
public Result Execute(ExternalCommandData commandData,ref string message,ElementSet elements)
{
Uiapp = commandData.Application;
Uidoc = Uiapp.ActiveUIDocument;
Doc = Uidoc.Document;
VistaAtiva = Doc.ActiveView;
using (Transaction tx = new(Doc,"Transaction"))
try
{
tx.Start();
try
{
ClickConnectInto(Uiapp);
}
catch
{
}
tx.Commit();
tx.Dispose();
}
catch
{
tx.RollBack();
}
return Result.Succeeded;
}
public static bool ClickConnectInto(UIApplication uiapp,int timeoutMs = 3000)
{
var hwnd = uiapp.MainWindowHandle;
if (hwnd == IntPtr.Zero) return false;
var main = AutomationElement.FromHandle(hwnd);
if (main == null) return false;
var t0 = Environment.TickCount;
while (Environment.TickCount - t0 < timeoutMs)
{
var connectBtn = main.FindFirst(
TreeScope.Descendants,
new AndCondition(
new PropertyCondition(AutomationElement.ControlTypeProperty,ControlType.Button),
new PropertyCondition(AutomationElement.NameProperty,"Connect\r\nInto",PropertyConditionFlags.IgnoreCase)
));
if (connectBtn != null)
{
if (connectBtn.GetCurrentPattern(InvokePattern.Pattern) is InvokePattern invoke)
{
invoke.Invoke();
return true;
}
return false;
}
Thread.Sleep(100); // wait a bit and retry
}
return false;
}
}