Jump to content

Radio Button - Double Click?


Recommended Posts

I wrote a small script for a few end users- it is a menu that launches programs for them. I used a Radio button control next to each app they launch. When they single click, everything works great....

When they double click... oh why do they double click.... things get jumbled up :D

I have been poking around for a solution to my problem.

Any ideas how to have autoit only accept a single click on the radio button? If they double click, tripple, etc... the extra clicks are ignored for a few moments?

My autoit gui looks for the radio button selections through a While / Case / Select / Wend statement.

Hope this explains enough, and here is a little code to help show what I mean

...
While 1
    $msg = GuiGetMsg()
    
    Select
        Case $msg = $radio1 And BitAND(GUICtrlRead($radio1), $GUI_CHECKED) = $GUI_CHECKED
                ;application
                    BlockInput(0)
                    launch($appname)

...
;a few more $msg for diff apps here
...

        Case $msg = $GUI_EVENT_CLOSE
                    BlockInput(0)
                    SplashOff()
                    _Exiter()
    EndSelect
Wend

thanks!

Jeff

Link to comment
Share on other sites

#include <GUIConstantsEx.au3>
Opt('MustDeclareVars', 1)

Global $hGUI, $hTmp
Global $aRadio[5]
Global $iMsg, $i

$hGUI = GUICreate('Test', 100, 200)

For $i = 0 To 4
    $aRadio[$i] = GUICtrlCreateRadio('Radio &' & $i+1, 20, 20+$i*25)
    $hTmp = GUICtrlGetHandle(-1)
    _SetClassLong($hTmp, -26, BitAND(_GetClassLong($hTmp, -26), BitNOT(8))) ; -26 = GCL_STYLE, 8 = CS_DBLCLKS.
Next

GUISetState()

While 1
    $iMsg = GUIGetMsg()
    
    Switch $iMsg
        Case $aRadio[0] To $aRadio[4]
            For $i = 0 To 4
                If $iMsg = $aRadio[$i] Then ExitLoop
            Next
            
            GUICtrlSetState($aRadio[$i], $GUI_DISABLE)
            AdlibEnable('_EnableControl', 1000)
            ConsoleWrite(ControlGetText($hGUI, '', $aRadio[$i]) & @LF)
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd

GUIDelete()
Exit


Func _GetClassLong($hwnd, $iIndex)
    Local $aRet
    
    $aRet = DllCall('user32.dll', 'uint', 'GetClassLong', 'hwnd', $hwnd, 'int', $iIndex)
    If @error Then Return SetError(1, 0, 0)
    Return $aRet[0]
EndFunc


Func _SetClassLong($hwnd, $iIndex, $iNewVal)
    Local $aRet
    
    $aRet = DllCall('user32.dll', 'uint', 'SetClassLong', 'hwnd', $hwnd, 'int', $iIndex, 'int', $iNewVal)
    If @error Then Return SetError(1, 0, 0)
    Return $aRet[0]
EndFunc


Func _EnableControl()
    AdlibDisable()
    For $i = 0 To 4
        GUICtrlSetState($aRadio[$i], $GUI_ENABLE)
    Next
EndFunc

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

  • Recently Browsing   0 members

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