Jump to content

An improved GUICtrlSetOnEvent


tarretarretarre
 Share

Recommended Posts

Inspired from

I created a UDF that I have been using to replace GUICtrlSetOnEvent, not using Opt("GUIOnEventMode").

AutoIt's GUICtrlSetOnEvent function only supports mouse clicks without parameters at this moment, this UDF works on the same premise but gives the user some more flexibility, in just 61 lines of code.

Here is an example of what A callback will look like

Func MyCallBackFunction(Const $wParam, ByRef $iCtrlId, ByRef $uData, ByRef $hWnd)

    Switch $wParam
        Case $WM_HOVERIN
            ConsoleWrite("Entering control; attached data = " & $uData & @CRLF)
        Case $WM_HOVEROUT
            ConsoleWrite("Leaving control" & @CRLF)
        Case $WM_LBUTTONDOWN
            ConsoleWrite("Left mousebutton DOWN" & @CRLF)
        Case $WM_LBUTTONUP
            ConsoleWrite("Left mousebutton UP" & @CRLF)
        Case $WM_MBUTTONDOWN
            ConsoleWrite("Middle mousebutton DOWN" & @CRLF)
        Case $WM_MBUTTONUP
            ConsoleWrite("Middle mousebutton UP" & @CRLF)
        Case $WM_RBUTTONDOWN
            ConsoleWrite("Right mousebutton DOWN" & @CRLF)
        Case $WM_RBUTTONUP
            ConsoleWrite("Right mousebutton UP" & @CRLF)
    EndSwitch

EndFunc

 

More examples can be found in the zip file.

Good 2 know

  1. GuiDelete($hWnd) used together with $WM_LBUTTONUP will cause the AutoIt script to crash
  2. $WM_HOVERIN and $WM_HOVEROUT ARE NOT real Windows Message codes and will only work with with this UDF
  3. Your callback functions MUST have 4 parameters assigned to it.

That's about it.

Feel free to pitch some improvements.

/Tarre

 

_GuiCtrlSetOnEvent.zip

Edited by tarretarretarre
as
Link to comment
Share on other sites

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
 Share

×
×
  • Create New...