Jump to content

GUICtrlSetImage is pressing the button..


Recommended Posts

post your code....

<{POST_SNAPBACK}>

#include <GuiConstants.au3>
;#include <Array.au3>
#include <Misc.au3>

AutoItSetOption("trayicondebug", 1)

GUICreate("MyGUI", 392, 323, (@DesktopWidth - 392) / 2, (@DesktopHeight - 323) / 2, $ws_overlappedwindow + $ws_visible + $ws_clipsiblings)
Dim $buttons[5]
$buttons[0] = ""
$buttons[1] = GUICtrlCreateButton("", 20, 30, 150, 110, $bs_bitmap)
GUICtrlSetImage($buttons[1], "darkred.bmp")
$buttons[2] = GUICtrlCreateButton("", 20, 170, 150, 110, $bs_bitmap)
GUICtrlSetImage($buttons[2], "darkblue.bmp")
$buttons[3] = GUICtrlCreateButton("", 210, 30, 150, 110, $bs_bitmap)
GUICtrlSetImage($buttons[3], "darkyellow.bmp")
$buttons[4] = GUICtrlCreateButton("", 210, 170, 150, 110, $bs_bitmap)
GUICtrlSetImage($buttons[4], "darkgreen.bmp")
GUISetState()
Global $count = 1
Global $count2 = 0
Global $color = ""

$random = ""
_play()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $gui_event_close
            ExitLoop
        Case $msg = $buttons[1]
            _getbuttons("red.bmp")
        Case $msg = $buttons[2]
            _getbuttons("blue.bmp")
        Case $buttons[3]
            _getbuttons("yellow.bmp")
        Case $buttons[4]
            _getbuttons("green.bmp")
    EndSelect
WEnd
Exit
#endregion --- GuiBuilder generated code End ---
Func _play()
    
    Do
        
        $count2 = $count2 + 1
        $r = Int(Random(1, 4))
        If $r = 1 Then
            $color = $color & "/" & "red.bmp"
        ElseIf $r = 2 Then
            $color = $color & "/" & "blue.bmp"
        ElseIf $r = 3 Then
            $color = $color & "/" & "yellow.bmp"
        ElseIf $r = 4 Then
            $color = $color & "/" & "green.bmp"
        EndIf
        $random = $random & "/" & $r
        $color_array = StringSplit($color, "/")
        $random_array = StringSplit($random, "/")
    ;_ArrayDisplay($color_array, $color)
    ;_ArrayDisplay($random_array, $random)
        
        
        For $b = 1 To $count2 + 1
            Sleep(500)
        ;;;;;GUICtrlSetState($buttons[$random_array[$b]],$GUI_DISABLE)
            GUICtrlSetImage($buttons[$random_array[$b]], "light" & $color_array[$b])
            Sleep(500)
            
            GUICtrlSetImage($buttons[$random_array[$b]], "dark" & $color_array[$b])
    ;;;;;;;;;;;GUICtrlSetState($buttons[$random_array[$b]],$GUI_ENABLE)
        Next
        
    Until $count2 = $count
    $count = $count + 1
    Return $count
    Return $count2
    Return $color
    Return $random
EndFunc  ;==>_play
Func _getbuttons($getcolor)
    
    $buttons[0] = $buttons[0] & "/"&$getcolor
    If $buttons[0] = $color Then
    MsgBox(0,$buttons[0],$color)    
        _play()
    
    Else
    MsgBox(0, "You Lose", "You matched the color "&_Iif ($count2 - 1 > 1, "s", "" )& $count2 - 1 & " times")    
    EndIf
    Return $buttons[0]
EndFunc
Edited by quick_sliver007

.

Link to comment
Share on other sites

Case $buttons[3]
            _getbuttons("yellow.bmp")
        Case $buttons[4]
            _getbuttons("green.bmp")

should be

Case $msg = $buttons[3]
            _getbuttons("yellow.bmp")
        Case $msg = $buttons[4]
            _getbuttons("green.bmp")

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Case $buttons[3]
            _getbuttons("yellow.bmp")
        Case $buttons[4]
            _getbuttons("green.bmp")

should be

Case $msg = $buttons[3]
            _getbuttons("yellow.bmp")
        Case $msg = $buttons[4]
            _getbuttons("green.bmp")

<{POST_SNAPBACK}>

LOL, :( I knew it had to be something dumb. Thanks man

.

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