Your code does work properly for me.
However, unless you've used "SetTitleMatchMode", your condition will be true if you have any window title that starts with "a".
"DetectHiddenText" may also be affecting the return value of WinExist.
Troubleshoot your problem by starting with a more unique title, like this
#k::
if WinExist("gob.txt - Notepad") {
Sendinput test
}
return
Test that this code works as expected when you do have "gob.txt" open in notepad. Then test when you don't have the file open. Experiment with different settings for SetTitleMatchMode. Hopefully, you will eventually be able to isolate where the problem is. I can't do it because I don't know what windows you have open on your system.
It also helps to clear out other code that could be affecting your test by right-clicking on the AutoHotKey icon on the task bar and choosing "Edit this script" and including only the code you are testing.
Good luck