Reputation: 47595
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
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
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
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