Here's an updated version of the same code as above, but using a single function to handle all 3 types of Windows messages. I'm sure there's a Windows constant for the 2 numbers I used in the Switch statement for $iMsg, but I wasn't able to find out what it was. The 273 is used to activate the button control function, which also works on combobox controls, the 274 is the GUI messages for things like the sysmenu and the close button. If anyone knows the variables for those 2 numbers, please let me know.
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
GUIRegisterMsg($WM_COMMAND, "_WM_EXTRACTOR")
GUIRegisterMsg($WM_SYSCOMMAND, "_WM_EXTRACTOR")
GUIRegisterMsg($WM_HSCROLL, "_WM_EXTRACTOR")
$GUI = GUICreate("Test GUI", 200, 200, -1, -1, BitOR($WS_THICKFRAME, $gui_ss_default_gui))
$Button = GUICtrlCreateButton("Test", 20, 20)
$Button2 = GUICtrlCreateButton(" Another Test ", 20, 100)
$Slider = GUICtrlCreateSlider(20, 60, 150)
$hSlider = GUICtrlGetHandle($Slider)
GUISetState()
While 1
$msg = GUIGetMsg()
Switch $msg
Case $Button
MsgBox(0, "", "You pressed the button marked TEST")
Case $Button2
MsgBox(0, "", "You pressed the button marked 'Another Test'")
EndSwitch
WEnd
Func _WM_EXTRACTOR($hWnd, $iMsg, $wParam, $lParam)
Local $nNotifyCode = BitShift($wParam, 16)
Local $nID = BitAND($wParam, 0x0000FFFF)
Local $hCtrl = $lParam
#forceref $hWnd, $iMsg, $wParam, $lParam
Switch $iMsg
Case $WM_HSCROLL
Switch $lParam
Case $hSlider
ConsoleWrite("+Slider moved to: " & GUICtrlRead($Slider) & @LF)
EndSwitch
Case $WM_VSCROLL
Case 273
Switch $nID
Case $Button
ConsoleWrite(">Button Test pressed" & @LF)
Case $Button2
ConsoleWrite(">Button Another Test pressed" & @LF)
Case Else
MsgBox(0, "MY_WM_COMMAND", "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)
EndSwitch
Case 274
Switch $wParam
Case 0xf060
ConsoleWrite("!Exit pressed" & @LF)
Exit
Case 0xF120
ConsoleWrite("!Restore window" & @LF)
Case 0xF020
ConsoleWrite("!Minimize Window" & @LF)
Case 0xF093
ConsoleWrite("!System menu pressed" & @LF)
Case 0xF010
ConsoleWrite("!System menu Move Option pressed" & @LF)
Return 0
Case 0xF000
ConsoleWrite("!System menu Size Option pressed" & @LF)
Return 0
Case 0xF002 ; This and the following case statements are only valid when the GUI is resizable
ConsoleWrite("!Right side of GUI clicked" & @LF)
Return 0
Case 0xf001
ConsoleWrite("!Left side of GUI clicked" & @LF)
Return 0
Case 0xF008
ConsoleWrite("!Lower Right corner of GUI clicked" & @LF)
Return 0
Case 0xF007
ConsoleWrite("!Lower Left corner of GUI clicked" & @LF)
Return 0
Case 0xF006
ConsoleWrite("!Bottom side of GUI clicked" & @LF)
Return 0
Case Else
MsgBox(0, "MY_WM_COMMAND", "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)
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>_WM_EXTRACTOR