Multi-Tab AutoIT Script Examples

SSMSNewTabIwa.au3

  • #include <MsgBoxConstants.au3>
  • local $paramCount = $CmdLine[0]
  • local $systemName = $CmdLine[1]
  • local $domainUserName = $CmdLine[2]
  • local $password = $CmdLine[3]
  • local $ssmsPid = $CmdLine[4]
  • if $paramCount = 4 Then
    • openNewTab($ssmsPid, $systemName, $domainUserName, $password)
  • EndIf
  • Func openNewTab($p_ssmsPid, $p_systemName, $p_domainUserName, $p_password)
    • Opt("WinTitleMatchMode", 2)
    • local $ssmsWindows = WinList("Microsoft SQL Server Management Studio")
    • for $i=1 To $ssmsWindows[0][0]
      • If $ssmsPid=WinGetProcess($ssmsWindows[$i][1]) Then
        • local $delay = 5
        • WinActivate($ssmsWindows[$i][1])
        • WinWaitActive($ssmsWindows[$i][1])
        • Send('!f')
        • Sleep($delay)
        • Send('e')
        • Sleep($delay)
        • Send('+{TAB}')
        • Sleep($delay)
        • Send('+d')
        • Sleep($delay)
        • Send('{TAB}')
        • Sleep($delay)
        • Send($systemName)
        • Sleep($delay)
        • Send('{TAB}')
        • Sleep($delay)
        • Send('+w')
        • Sleep($delay)
        • Send('{ENTER}')
      • EndIf
    • Next
  • EndFunc

SSMSNewTabSql.au3

  • #include <MsgBoxConstants.au3>
  • local $paramCount = $CmdLine[0]
  • local $systemName = $CmdLine[1]
  • local $domainUserName = $CmdLine[2]
  • local $password = $CmdLine[3]
  • local $ssmsPid = $CmdLine[4]
  • if $paramCount = 4 Then
    • openNewTab($ssmsPid, $systemName, $domainUserName, $password)
  • EndIf
  • Func openNewTab($p_ssmsPid, $p_systemName, $p_domainUserName, $p_password)
    • Opt("WinTitleMatchMode", 2)
    • local $ssmsWindows = WinList("Microsoft SQL Server Management Studio")
    • for $i=1 To $ssmsWindows[0][0]
      • If $ssmsPid=WinGetProcess($ssmsWindows[$i][1]) Then
        • local $delay = 5
        • WinActivate($ssmsWindows[$i][1])
        • WinWaitActive($ssmsWindows[$i][1])
        • Send('!f')
        • Sleep($delay)
        • Send('e')
        • Sleep($delay)
        • Send('+{TAB}')
        • Sleep($delay)
        • Send('+d')
        • Sleep($delay)
        • Send('{TAB}')
        • Sleep($delay)
        • Send($systemName)
        • Sleep($delay)
        • Send('{TAB}')
        • Sleep($delay)
        • Send('+s')
        • Sleep($delay)
        • Send('{TAB}')
        • Sleep($delay)
        • Send($domainUserName)
        • Sleep($delay)
        • Send('{TAB}')
        • Sleep($delay)
        • Send($password)
        • Sleep($delay)
        • Send('{ENTER}')
      • EndIf
    • Next
  • EndFunc