Jump to content

I can't press Enter on a color button


Fabry
 Share

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]
Link to comment
Share on other sites

  • Moderators

#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.

Link to comment
Share on other sites

  • Moderators

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.

Link to comment
Share on other sites

  • Moderators

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.

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...