Q: How to get the active window's title with AutoHotKey? I wrote this short test code, but it didn't work. What am I doing wrong?
F12::
WinGetTitle, Title, A ;
MsgBox, "%Title%"

The displayed result was ""

A: The best practice would probably be to use WinGetActiveTitle:  
F12::
   WinGetActiveTitle, Title
   MsgBox, The active window is "%Title%".
return


A: I removed a ; and added return and this worked...
F12::
WinGetTitle, title, A
MsgBox, "%title%"
return


A: If you do not put in a return it will run down your whole file.
Probably something not running through later in it.
Don't think the ; will affect it.
Anything after a ; is omitted from code as a comment. 

A: Using WinGetActiveTitle or WinGetTitle will do.
Note the output of WinGetTitle contains more than the window title.
You might want to remove the ending part with the program name e.g." - Google Chrome".
WinGetActiveTitle, Title
StringGetPos,pos,Title,%A_space%-,R
if (pos != -1)
    Title := SubStr(Title,1,pos)


A: In AutoHotKey 2 you can use this:
title := WinGetTitle("A")  ; "A" matches "Active" window

In AutoHotKey 1 you can use:
WinGetActiveTitle, title

