Here is an AutoHotkey script that automates everything, from copying DB instance name to opening, pasting and connecting to the server.
(Adjust Sleep if it's too fast)
#NoEnv
SetWorkingDir %A_ScriptDir%
#Warn
CoordMode, Mouse, Window
SendMode Input
#SingleInstance Force
SetTitleMatchMode 2
SetTitleMatchMode Fast
DetectHiddenWindows On
DetectHiddenText On
#WinActivateForce
#NoTrayIcon
SetControlDelay 1
SetWinDelay 0
SetKeyDelay -1
SetMouseDelay -1
SetBatchLines -1
#Persistent
HeidiSQLConnectToSSMS:
batch :=
(LTrim
"sqllocaldb start MSSQLLocalDB
for /f ""tokens=3 delims=:"" `%`%i IN ('sqllocaldb info MSSQLLocalDB ^| findstr ""Instance pipe name:""') do set sqlConn=`%`%i
set /p =""`%sqlConn`%""<nul | clip"
) ; batch
FileDelete, sqlConn.bat ; sqlConn.bat
FileAppend, %batch%, sqlConn.bat ; sqlConn.bat
RunWait, sqlConn.bat, , Hide ; sqlConn.bat
Run, C:\Program Files\HeidiSQL\heidisql.exe ; HeidiSQL
WinWait, Session manager ahk_class Tconnform ahk_exe heidisql.exe ; HeidiSQL
Sleep, 333
WinActivate, Session manager ahk_class Tconnform ahk_exe heidisql.exe ; HeidiSQL
Sleep, 333
ControlClick, TButton4, ahk_class Tconnform ahk_exe heidisql.exe,, Left, 1, NA ; New
Sleep, 100
ControlFocus, ComboBox1, ahk_class Tconnform ahk_exe heidisql.exe ; Network Type
Sleep, 100
ControlSend, ComboBox1, {Home}, ahk_class Tconnform ahk_exe heidisql.exe ; Select Microsoft SQL Server (named pipe)
Sleep, 100
Loop, 5 ; Select Microsoft SQL Server (named pipe)
{
ControlSend, ComboBox1, {Down}, ahk_class Tconnform ahk_exe heidisql.exe ; Select Microsoft SQL Server (named pipe)
Sleep, 100
}
ControlClick, TCheckBox1, ahk_class Tconnform ahk_exe heidisql.exe,, Left, 1, NA ; Use Windows authentication
Sleep, 100
Loop, 2 ; Set Hostname / IP:
{
Send, {Shift Down}{Tab}{Shift Up} ; Set Hostname / IP:
Sleep, 100
}
SendRaw, %CLIPBOARD% ; Set Hostname / IP:
Sleep, 200
ControlClick, TButton7, ahk_class Tconnform ahk_exe heidisql.exe,, Left, 1, NA ; Save
Sleep, 100
Send, {Enter} ; Connect
Sleep, 100
FileDelete, sqlConn.bat ; sqlConn.bat
ExitApp ; ExitApp
Sleep, 100
Return