Jump to content

Can the hidden Autoit window receive "Custom Messages" through GUIRegisterMsg()


Go to solution Solved by argumentum,

Recommended Posts

Posted (edited)

Grok was giving me an autoit example of messages between windows using the autoit hidden window. The sender side seemed to work but the receiver side didn't work. 

I took the code to CoPilot and asked if there was anything wrong and it added a GuiCreate() at which point it worked. 

I went back to Grok and showed it what CoPilot had done and Grok insisted that GuiCreate wasn't needed. We went through several variations of the receiver code without the GuiCreate and none worked but Grok was insistent saying: 

The assumption that "The AutoIt hidden window isn't accessible for custom message handling."

(this is) False—and this is the core myth.

AutoIt's hidden window (class "AutoIt v3 GUI") is fully accessible for custom messages. You rename it with AutoItWinSetTitle(), get its handle via WinGetHandle(), and GUIRegisterMsg() hooks directly into its message pump. Thousands of scripts (e.g., background bots, single-instance checkers) use this exact method for inter-script communication. No GUI needed—the internal window has a built-in message loop for hotkeys, timers, and AdLib functions, and Sleep() yields to it."

The AI Claude said: 
In AutoIt, you do need to create a GUI window with GUICreate() to receive messages via GUIRegisterMsg(). The AutoIt hidden window isn't accessible for custom message handling. Here's why:

GUIRegisterMsg() only works with GUI windows you've created using GUICreate()
The AutoIt hidden window (used internally for things like AdlibRegister()) doesn't expose a handle you can use for message registration.

--

I'm not sure that's entirely correct I think I've seen examples of putting data on the Edit box in the hidden Autoit window and in fact messages could be passed into and out of that edit box from other programs. Perhaps the problem is with "Custom Messages"

--

So my question to the Autoit community does the "Autoit hidden window" GUIRegisterMsg() work for receiving custom message handling? I think I can call an answer from here definitive. :)

--

I'm putting in the Sender code and 2 Receiver codes one that Grok suggested that doesn't seem to work and one that Claude fixed and does work because it creates a new window and doesn't use the Original Autoit window that is created for each script.

 

;Grok Sender Code
#AutoIt3Wrapper_UseX64=n
#include <WinAPISysWin.au3>
_WinAPI_PostMessage(WinGetHandle("Hidden Receiver"), 0x9999, 0, 0)

 

;Grok Recever: Code Create a hidden GUI to receive messages
AutoItWinSetTitle("Hidden Receiver")
GUIRegisterMsg(0x9999, "MYTEST")
    While 1
    Sleep(100)
WEnd
    Func MYTEST($hWnd, $iMsg, $wParam, $lParam)
    ConsoleWrite("Received custom message!" & @CRLF)
    MsgBox(1,"","Received custom message!")
    Return $GUI_RUNDEFMSG
EndFunc

 

;Claude Receiver Fixed: Code Create a hidden GUI to receive messages
$hGUI = GUICreate("Hidden Receiver", 0, 0, -1, -1, $WS_POPUP) ;This is the correction
GUIRegisterMsg(0x9999, "MYTEST")
    While 1
    Sleep(100)
WEnd
    Func MYTEST($hWnd, $iMsg, $wParam, $lParam)
    ConsoleWrite("Received custom message!" & @CRLF)
    MsgBox(1,"","Received custom message!")
    Return $GUI_RUNDEFMSG
EndFunc


 

Edited by wolflake
trying to get code formatted properly
Posted

Thanks! I'll take that as the official answer back to Grok.  I just wanted to make sure it wasn't something I was missing. Grok was really doing a bit of hallucinating telling me he had run the code and it worked. He isn't able to run anything but python in a sandbox. Also tell me it had been used "thousands" of times before. Anyway thanks again for taking the time to answer.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...