26 August 2019
- Last edited 26 August 2019
Hi, this is not an issue I'm reporting, just something potentially useful. I've compiled a more complete plugin for AutoHotkey, and although I still need to address some IPC functionality (i.e. InitializePipesModule, which is either not completely functional yet or I am not providing a correct parameter to it in my experiments so far), the plugin is largely quite useful to me. If there is interest - I realize there may not be, as AutoHotkey is relatively unknown - I will prepare a NuGet package for it.
As an aside, I think it might be useful to have a place on the forum or elsewhere for users to share their plugins.
I'm concentrating here on the use of the AutoHotkey "SendMessage" command to control a Windows application by way of Windows messages. (A companion command, "PostMessage", does not wait for a return as "SendMessage" does.)
The workflow below opens Notepad, saves its Window ID (or "hwnd" as it's usually known in AutoHotkey) in a global variable "NotepadPtr" by overriding the Data Port and selecting the mapped variable. The AHK file "send1.ahk" is then loaded. Its contents are:
WinWait Untitled - Notepad
SendMessage, 0xC, 0, "Controlled by Intellibot", , ahk_id %hwnd%; 0XC is WM_SETTEXT
Then the function "ChangeNotepadTitle" is called, passing "NotepadPtr" to it (and the function does exactly what the function name suggests - here it changes it from the Notepad default to "Controlled by Intellibot"). Although "NotepadPtr" is an integer, AHK will treat it as a string, so the type difference does not matter. The function "Reset" is called - this is necessary because the file loaded will persist unless this is done, resulting (if "Reset" is NOT called) in a "duplicate function" error the next time the script is called. Reset will unload the file so it can be run more than once.
The new functions list for the plugin is as shown: