Opt("SendAttachMode", 0) ;0=don't attach, 1=do attach Opt("SendCapslockMode", 1) ;1=store and restore, 0=don't Opt("SendKeyDelay", 5) ;5 milliseconds Opt("SendKeyDownDelay", 1) ;1 millisecond Opt("TCPTimeout",100) ;100 milliseconds Opt("TrayAutoPause",1) ;0=no pause, 1=Pause Opt("TrayIconDebug", 0) ;0=no info, 1=debug line info Opt("TrayIconHide", 0) ;0=show, 1=hide tray icon Opt("TrayMenuMode",0) ;0=append, 1=no default menu, 2=no automatic check, 4=menuitemID not return Opt("TrayOnEventMode",0) ;0=disable, 1=enable Opt("WinDetectHiddenText", 0) ;0=don't detect, 1=do detect Opt("WinSearchChildren", 1) ;0=no, 1=search children also Opt("WinTextMatchMode", 1) ;1=complete, 2=quick Opt("WinTitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to - 4=Nocase Opt("WinWaitDelay", 250) ;250 milliseconds Function Reference GUIRegisterMsg Register a user defined function for a known Windows Message ID (WM_MSG). GUIRegisterMsg ( msgID, "function" ) Parameters msgID A Windows Message ID (see Appendix: Windows Message Codes). function The name of the user function to call when the message appears or an empty string "" to unregister a message. Return Value Success: 1 Failure: 0 Remarks !!! To make the user function workable you have to define it with maximum 4 function parameters otherwise the function won't be called !!! i.e: Func MyUserFunction($hWndGUI, $MsgID, $WParam, $LParam) EndFunc Or Func MyUserFunction($hWndGUI, $MsgID) EndFunc When the user function is called then these 4 parameters have the following values: Position Parameter Meaning 1 hWnd The Window handle of the GUI in which the message appears. 2 Msg The Windows message ID. 3 wParam The first message parameter as hex value. 4 lParam The second message parameter as hex value. Up to 256 user functions can be registered for message ID's. By default after finishing the user function the AutoIt internal message handler will be proceed. That won't be if your Return a value (See WM_COMMAND in example) or if you use the keyword 'Return' without any value. By using 'Return' without any return value the AutoIt internal message handler (if there is one for this message) will NOT be proceed! !!! If you want AutoIt to run it's internal handler for a message, return the variable $GUI_RUNDEFMSG (in GUIConstantsEx.au3) from the function (see also examples) !!! I.e. if you want to return earlier than the user function ends and also proceed the AutoIt internal message handler. Warning: blocking of running user functions which executes window messages with commands such as "Msgbox()" can lead to unexpected behavior, the return to the system should be as fast as possible !!! Some controls consume internally specific Windows Message ID, so registrating them will have no effect, e.g; WM_CHAR, WM_KEYDOWN, WM_KEYUP are consumed by an edit control. Related GUICtrlGetHandle Example ; ******************************************************* ; Example - Create an ownerdrawn/colored button ; ******************************************************* #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> Example() Func Example() Local Const $BS_OWNERDRAW = 0x0000000B Local $hGUI, $nButton, $nButton2, $GUIMsg $hGUI = GUICreate("My Ownerdrawn Created Button", 300, 200) $nButton = GUICtrlCreateButton("", 90, 50, 120, 30) GUICtrlSetStyle($nButton, BitOR($WS_TABSTOP, $BS_NOTIFY, $BS_OWNERDRAW)) ; Set the ownerdrawn flag $nButton2 = GUICtrlCreateButton("Normal Button", 90, 110, 120, 30) GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND") ; WM_DRAWITEM has to registered before showing GUI otherwise the initial drawing isn't done GUIRegisterMsg($WM_DRAWITEM, "MY_WM_DRAWITEM") GUISetState() While 1 $GUIMsg = GUIGetMsg() Switch $GUIMsg Case $GUI_EVENT_CLOSE ExitLoop Case $nButton ; Normally should not run through cause of our MY_WM_COMMAND function MsgBox(0, "Info", "Button pressed") Case $nButton2 ; Normally should not run through cause of our MY_WM_COMMAND function MsgBox(0, "Info", "Button2 pressed") EndSwitch WEnd EndFunc ;==>Example ; React on a button click Func MY_WM_COMMAND($hWnd, $Msg, $wParam, $lParam) $nNotifyCode = BitShift($wParam, 16) $nID = BitAND($wParam, 0x0000FFFF) $hCtrl = $lParam If $nID <> 2 And $nNotifyCode = 0 Then ; Check for IDCANCEL - 2 ; Ownerdrawn buttons don't send something by pressing ENTER ; So IDOK - 1 comes up, now check for the control that has the current focus If $nID = 1 Then $hFocus = DllCall("user32.dll", "hwnd", "GetFocus") $nCtrlID = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $hFocus[0]) PostButtonClick($hWnd, $nCtrlID[0]) 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) EndIf Return 0 ; Only workout clicking on the button EndIf ; Proceed the default Autoit3 internal message commands. ; You also can complete let the line out. ; !!! But only 'Return' (without any value) will not proceed ; the default Autoit3-message in the future !!! Return $GUI_RUNDEFMSG EndFunc ;==>MY_WM_COMMAND ; RePost a WM_COMMAND message to a ctrl in a gui window Func PostButtonClick($hWnd, $nCtrlID) DllCall("user32.dll", "int", "PostMessage", _ "hwnd", $hWnd, _ "int", $WM_COMMAND, _ "int", BitAND($nCtrlID, 0x0000FFFF), _ "hwnd", GUICtrlGetHandle($nCtrlID)) EndFunc ;==>PostButtonClick ; Draw the button Func MY_WM_DRAWITEM($hWnd, $Msg, $wParam, $lParam) Local $stDrawItem = DllStructCreate("uint;uint;uint;uint;uint;uint;uint;int[4];dword", $lParam) Local Const $ODT_BUTTON = 4 . 'Return' without any return value the AutoIt internal message handler (if there is one for this message) will NOT be proceed! !!! If you want AutoIt to run it's internal handler for. the default Autoit3 internal message commands. ; You also can complete let the line out. ; !!! But only 'Return' (without any value) will not proceed ; the default Autoit3 -message. examples) !!! I.e. if you want to return earlier than the user function ends and also proceed the AutoIt internal message handler. Warning: blocking of running user functions which executes window