SkinnyWhiteGuy Posted July 7, 2008 Posted July 7, 2008 I was planning on using GUIRegisterMsg to watch for a lot of events on a window (network stuff, related to Zatorg's ASock stuff), so I was doing my research to see if any errors might pop up. On reading the reference for GuiRegisterMsg, I came across this: Up to 256 user functions can be registered for message ID's. Reading it as is, in my mind, that means I can only have 256 unique functions being pointed to, but if I use the same function for a number of message ID's, I'm not limited. But, that would seem wrong to me, since then I could register every message under the sun, make them all point to one function, and then switch out from there, and with such a simple solution, I would figure that would be how AutoIt did it internally, and just wouldn't have a limit to begin with. Am I just over thinking this, or can I have more than 256 message ID's pointed at the same function and everything run just fine?
Airwolf Posted July 8, 2008 Posted July 8, 2008 I was confused too... so I just created a simple script with a GUI and registered all 446 IDs to a single function and the script runs without error (attached). I know the GUIRegisterMsg() function does not like MsgBoxes but I was just trying to prove a point.test2.au3 Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt
AdmiralAlkex Posted July 8, 2008 Posted July 8, 2008 (edited) I was confused too... so I just created a simple script with a GUI and registered all 446 IDs to a single function and the script runs without error (attached). I know the GUIRegisterMsg() function does not like MsgBoxes but I was just trying to prove a point.I wouldn't call that simple, this I call simple: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> GUICreate("Test",400,400) GUICtrlCreateButton("Test Button 1",10,10,380) GUICtrlCreateButton("Test Button 2",10,10,380) For $X = 0x0000 To 0x8000 GuiRegisterMsg($X, "MyFunction") Next GUISetState() Do Sleep(10) Until GUIGetMsg() = $GUI_EVENT_CLOSE Func MyFunction($hWnd, $Msg, $wParam, $lParam) $nNotifyCode = BitShift($wParam, 16) $nID = BitAND($wParam, 0x0000FFFF) $hCtrl = $lParam ConsoleWrite("GUIHWnd" & @TAB & ":" & $hWnd & @LF & _ "MsgID" & @TAB & ":" & $Msg & @LF & _ "wParam" & @TAB & ":" & $wParam & @LF & _ "lParam" & @TAB & ":" & $lParam & @LF & @LF & _ "WM_COMMAND - Infos:" & @LF & _ "-----------------------------" & @LF & _ "Code" & @TAB & ":" & $nNotifyCode & @LF & _ "CtrlID" & @TAB & ":" & $nID & @LF & _ "CtrlHWnd" & @TAB & ":" & $hCtrl & @CRLF & @CRLF) Return $GUI_RUNDEFMSG EndFunc Only a few thousand GuiRegisterMsg() and it still start in about 1 sec. Edit: Made it even simpler muttley Edited July 8, 2008 by AdmiralAlkex .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
Airwolf Posted July 8, 2008 Posted July 8, 2008 I wouldn't call that simple, this I call simpleNice. muttley I only used the IDs listed in the help file to make sure that if I did get an error that it was related to the GuiRegisterMsg()'s. It didn't take me long to build that list; I used the same type of For...Next loop to output the 446 lines in my example.You must be bored. LOL Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt
AdmiralAlkex Posted July 8, 2008 Posted July 8, 2008 You must be bored. LOLWho aren't? muttley .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
SkinnyWhiteGuy Posted July 8, 2008 Author Posted July 8, 2008 Well, it's one thing to register them all, I figured that might work. What I was wondering, was would anything after the 255th message actually work if you sent that message to that Gui? (And just as a side note, I'm only using messages above WM_USER for this). I might play with some of your examples, and see if I can include a test to show it working as it should. Maybe do _SendMessage() in a loop, going back over those same messages with a consolewrite...
Airwolf Posted July 8, 2008 Posted July 8, 2008 Well, it's one thing to register them all, I figured that might work. What I was wondering, was would anything after the 255th message actually work if you sent that message to that Gui? (And just as a side note, I'm only using messages above WM_USER for this).I might play with some of your examples, and see if I can include a test to show it working as it should. Maybe do _SendMessage() in a loop, going back over those same messages with a consolewrite...I was betting on the function having a check to verify that there are less than 256 connections before allowing the registration (and spitting out an error). It never hurts to do what you're proposing, though. Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt
SkinnyWhiteGuy Posted July 8, 2008 Author Posted July 8, 2008 Yeah, it sure doesn't.... #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <SendMessage.au3> GUICreate("Test",400,400) For $X = 0x0400 To 0x8000 GuiRegisterMsg($X, "MyFunction") Next Sleep(1000) For $X = 0x0400 To 0x8000 _SendMessage(WinGetHandle("Test"), $X) Next Func MyFunction($hWnd, $Msg, $wParam, $lParam) ConsoleWrite("GUIHWnd" & @TAB & ":" & $hWnd & @LF & _ "MsgID" & @TAB & ":0x0000" & Hex($Msg, 4) & @LF & _ "wParam" & @TAB & ":" & $wParam & @LF & _ "lParam" & @TAB & ":" & $lParam & @CRLF & @CRLF) EndFunc muttley
Airwolf Posted July 8, 2008 Posted July 8, 2008 Yeah, it sure doesn't.... #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <SendMessage.au3> GUICreate("Test",400,400) For $X = 0x0400 To 0x8000 GuiRegisterMsg($X, "MyFunction") Next Sleep(1000) For $X = 0x0400 To 0x8000 _SendMessage(WinGetHandle("Test"), $X) Next Func MyFunction($hWnd, $Msg, $wParam, $lParam) ConsoleWrite("GUIHWnd" & @TAB & ":" & $hWnd & @LF & _ "MsgID" & @TAB & ":0x0000" & Hex($Msg, 4) & @LF & _ "wParam" & @TAB & ":" & $wParam & @LF & _ "lParam" & @TAB & ":" & $lParam & @CRLF & @CRLF) EndFunc muttleyMight take a few hours to run , but it seems to work. Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt
AdmiralAlkex Posted July 8, 2008 Posted July 8, 2008 (edited) Try this script, I got 32768 answered messages in about 11.205 sec. That's almost to good to be true muttley #include <GUIConstantsEx.au3> #Include <SendMessage.au3> $Messages = 0 $GUI = GUICreate("Test",400,400) For $X = 0x8000 To 0xFFFF GuiRegisterMsg($X, "MyFunction") Next For $X = 0x8000 To 0xFFFF _SendMessage($GUI, $X) If @error = 0 Then $Messages +=1 Next ConsoleWrite("Messages answered to= " & $Messages & @CRLF) Func MyFunction($hWnd, $Msg, $wParam, $lParam) Return EndFunc Edited July 8, 2008 by AdmiralAlkex .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
SkinnyWhiteGuy Posted July 8, 2008 Author Posted July 8, 2008 The one I posted actually only took around 20 seconds to run all the way (Core 2 Duo, 2 GB RAM). Seems that, it works just as it reads.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now