Phillip Senn
Phillip Senn

Reputation: 47595

Window title in AutoHotKeys

In AutoHotKeys, how do I write an if/then statement that says:

::create::
IF(Window.Title == 'Microsoft SQL Server Management Studio') {
   SendInput CREATE TABLE dbo.xxx({Enter}
   SendInput xxxID Int Identity(101,1) CONSTRAINT xxxID Primary Key{Enter}
}

Upvotes: 0

Views: 1304

Answers (3)

Phillip Senn
Phillip Senn

Reputation: 47595

#IfWinActive Microsoft SQL Server Management Studio 
::create:: 
SendInput CREATE TABLE dbo.xxx({Enter} 
SendInput xxxID Int Identity(101,1) CONSTRAINT xxxID Primary Key{Enter} 
return

Upvotes: 0

Zusukar
Zusukar

Reputation: 382

I think you would be best served by the IfWinActive command. Below is an example that is triggered when you press Win+C

#c::
  IfWinActive, Microsoft SQL Server Management Studio
    Send, CREATE TABLE dbo.xxx({Enter}xxxID Int Identity(101,1) CONSTRAINT xxxID Primary Key{Enter}
return

Upvotes: 2

ApathyS
ApathyS

Reputation: 43

There are many different ways of getting a window title but I would say the best option is to use The WinGetTitle command:

WinGetTitle, Window_Title, A ;A is for the active window
If (Window_Title = "Microsoft SQL Server Management Studio") {
}

Upvotes: 4

Related Questions