Jump to content
Sign in to follow this  
Fabry

I can't press Enter on a color button

Recommended Posts

Try to press enter to choose the color:

#include <GUIConstants.au3>
$coloreA = 0xff0000
$Form12 = GUICreate("Choose color", 292, 133, 399, 254)
$Buttonn1 = GUICtrlCreateButton("&A", 24, 40, 97, 73, 0)
GUICtrlSetFont(-1, 32, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, $coloreA)
GUICtrlSetState(-1, $GUI_FOCUS)
$Buttonn2 = GUICtrlCreateButton("&B", 160, 40, 97, 73, 0)
GUICtrlSetFont(-1, 32, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0x00ff00)
GUICtrlCreateLabel("Choose the color", 32, 8, 100, 17)
GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $Buttonn1
            $squadra = 'A'
            ExitLoop
        Case $Buttonn2
            $squadra = 'B'
            ExitLoop
    EndSwitch
WEnd
GUIDelete($Form12)
MsgBox(0, 'Color', $squadra)

;-------------example 2
$coloreA = 0xff0000
$Form12 = GUICreate("Choose color", 292, 133, 399, 254)
$Buttonn1 = GUICtrlCreateButton("&A", 24, 40, 97, 73, 0)
GUICtrlSetFont(-1, 32, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, $coloreA)
GUICtrlSetState(-1, $GUI_FOCUS)
$Buttonn2 = GUICtrlCreateButton("&B", 160, 40, 97, 73, 0)
GUICtrlSetFont(-1, 32, 400, 0, "MS Sans Serif")
;~ GUICtrlSetBkColor(-1,0x00ff00)
GUICtrlCreateLabel("Choose the color", 32, 8, 100, 17)
GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $Buttonn1
            $squadra = 'A'
            ExitLoop
        Case $Buttonn2
            $squadra = 'B'
            ExitLoop
    EndSwitch
WEnd
GUIDelete($Form12)
MsgBox(0, 'Color', $squadra)

A lan chat (Multilanguage)LanMuleFile transferTank gameTank 2 an online game[center]L'esperienza è il nome che tutti danno ai propri errori.Experience is the name everyone gives to their mistakes.Oscar Wilde[/center]

Share this post


Link to post
Share on other sites

#include <GUIConstantsEx.au3>

;-------------example 2
$coloreA = 0xff0000
$Form12 = GUICreate("Choose color", 292, 133, 399, 254)
$Buttonn1 = GUICtrlCreateButton("&A", 24, 40, 97, 73, $BS_DEFPUSHBUTTON)
GUICtrlSetFont(-1, 32, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, $coloreA)
GUICtrlSetState(-1, $GUI_FOCUS)
$Buttonn2 = GUICtrlCreateButton("&B", 160, 40, 97, 73, 0)
GUICtrlSetFont(-1, 32, 400, 0, "MS Sans Serif")
;~ GUICtrlSetBkColor(-1,0x00ff00)
GUICtrlCreateLabel("Choose the color", 32, 8, 100, 17)
GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $Buttonn1
            $squadra = 'A'
            ExitLoop
        Case $Buttonn2
            $squadra = 'B'
            ExitLoop
    EndSwitch
WEnd
GUIDelete($Form12)
MsgBox(0, 'Color', $squadra)


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

I would press the color button in the first example. At the moment I found it to press {SPACE}.

Absolutely no idea what that means.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

I would press the color button in the first example. At the moment I found it to press {SPACE}.

You will have to capture the {ENTER} in some other way, default way to push a button is {SPACE}, not {ENTER}.

Correct me if i am wrong.

Share this post


Link to post
Share on other sites

I wonder if anyone bothered to try the script I posted, let alone read the style definition for $BS_DEFPUSHBUTTON that I added to the script.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
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
Sign in to follow this  

×
×
  • Create New...