I had some really confusing problems trying to do post message. I found, not surprisingly I suppose, that if AutoHotKey tries to post a message to a window which has administrator privileges then it will fail. I trapped the error message, but that didn't tell me anything.
The solution, of course, is to run Autohotkey with administrator privileges. (as administrator either by right clicking when starting it or setting the .exe to have administrator privileges by defaut).
I thought I should post this here as I have taken about 2 days to find this out.
It is obvious when you think retrospectively about it, but many things are like that.