Sign in to follow this  
Followers 0
Wb-FreeKill

CUICtrlsetdata wont work

6 posts in this topic

I want the GUICtrlsetData to set "push!" for the random button, but it aint working..

for testing it sets the same data for the Label, and it works fine..

btw, can i change the color of a button?

#include <GUIConstants.au3>

HotkeySet("{ESC}", "myexit")

$gui = GUICreate("mirror", @DeskTopWidth + 5, @DesktopHeight, 0, 0,);$WS_EX_TOPMOST + $WS_BORDER + $WS_POPUP, $WS_EX_TOOLWINDOW)

$L = 320
$S = 200



$b1 = GUICtrlCreateButton("", $L, $S, 50, 50)
$b2 = GUICtrlCreateButton("", $L+50,  $S, 50, 50)
$b3 = GUICtrlCreateButton("", $L+100, $S, 50, 50)
$b4 = GUICtrlCreateButton("", $L+150, $S, 50, 50)
$b5 = GUICtrlCreateButton("", $L+200, $S, 50, 50)
$b6 = GUICtrlCreateButton("", $L+250, $S, 50, 50)
$b7 = GUICtrlCreateButton("", $L+300, $S, 50, 50)
$b8 = GUICtrlCreateButton("", $L+350, $S, 50, 50)


$1 = GUICtrlCreateButton("", $L, $S+50, 50, 50)
$2 = GUICtrlCreateButton("", $L+50,  $S+50, 50, 50)
$3 = GUICtrlCreateButton("", $L+100, $S+50, 50, 50)
$4 = GUICtrlCreateButton("", $L+150, $S+50, 50, 50)
$5 = GUICtrlCreateButton("", $L+200, $S+50, 50, 50)
$6 = GUICtrlCreateButton("", $L+250, $S+50, 50, 50)
$7 = GUICtrlCreateButton("", $L+300, $S+50, 50, 50)
$8 = GUICtrlCreateButton("", $L+350, $S+50, 50, 50)

$9 = GUICtrlCreateButton("", $L, $S+100, 50, 50)
$10 = GUICtrlCreateButton("", $L+50,  $S+100, 50, 50)
$11 = GUICtrlCreateButton("", $L+100, $S+100, 50, 50)
$12 = GUICtrlCreateButton("", $L+150, $S+100, 50, 50)
$13 = GUICtrlCreateButton("", $L+200, $S+100, 50, 50)
$14 = GUICtrlCreateButton("", $L+250, $S+100, 50, 50)
$15 = GUICtrlCreateButton("", $L+300, $S+100, 50, 50)
$16 = GUICtrlCreateButton("", $L+350, $S+100, 50, 50)

$17 = GUICtrlCreateButton("", $L, $S+150, 50, 50)
$18 = GUICtrlCreateButton("", $L+50,  $S+150, 50, 50)
$19 = GUICtrlCreateButton("", $L+100, $S+150, 50, 50)
$20 = GUICtrlCreateButton("", $L+150, $S+150, 50, 50)
$21 = GUICtrlCreateButton("", $L+200, $S+150, 50, 50)
$22 = GUICtrlCreateButton("", $L+250, $S+150, 50, 50)
$23 = GUICtrlCreateButton("", $L+300, $S+150, 50, 50)
$24 = GUICtrlCreateButton("", $L+350, $S+150, 50, 50)

$25 = GUICtrlCreateButton("", $L, $S+200, 50, 50)
$26 = GUICtrlCreateButton("", $L+50,  $S+200, 50, 50)
$27 = GUICtrlCreateButton("", $L+100, $S+200, 50, 50)
$28 = GUICtrlCreateButton("", $L+150, $S+200, 50, 50)
$29 = GUICtrlCreateButton("", $L+200, $S+200, 50, 50)
$30 = GUICtrlCreateButton("", $L+250, $S+200, 50, 50)
$31 = GUICtrlCreateButton("", $L+300, $S+200, 50, 50)
$32 = GUICtrlCreateButton("", $L+350, $S+200, 50, 50)

$33 = GUICtrlCreateButton("", $L, $S+250, 50, 50)
$34 = GUICtrlCreateButton("", $L+50,  $S+250, 50, 50)
$35 = GUICtrlCreateButton("", $L+100, $S+250, 50, 50)
$36 = GUICtrlCreateButton("", $L+150, $S+250, 50, 50)
$37 = GUICtrlCreateButton("", $L+200, $S+250, 50, 50)
$38 = GUICtrlCreateButton("", $L+250, $S+250, 50, 50)
$39 = GUICtrlCreateButton("", $L+300, $S+250, 50, 50)
$40 = GUICtrlCreateButton("", $L+350, $S+250, 50, 50)

$41 = GUICtrlCreateButton("", $L, $S+300, 50, 50)
$42 = GUICtrlCreateButton("", $L+50,  $S+300, 50, 50)
$43 = GUICtrlCreateButton("", $L+100, $S+300, 50, 50)
$44 = GUICtrlCreateButton("", $L+150, $S+300, 50, 50)
$45 = GUICtrlCreateButton("", $L+200, $S+300, 50, 50)
$46 = GUICtrlCreateButton("", $L+250, $S+300, 50, 50)
$47 = GUICtrlCreateButton("", $L+300, $S+300, 50, 50)
$48 = GUICtrlCreateButton("", $L+350, $S+300, 50, 50)



$i = GUICtrlCreateLabel("", 100, 50, 100, 20)

GUISetState()

WinSetOnTop("mirror", "", 1)
GUISetBkColor(0xBBBBBB, $gui)

While 1
$msg = GUIGetMsg()
Sleep (700)

$Random =  Random ( 1, 48) 
$Round = Round ( $Random , 0)
$x = "$" & $Round 

GUIctrlsetdata($x, "PUSH!")
GUIctrlsetdata($i, $x)

sleep(500)

GUIctrlsetdata($x, "")
Wend


Func myexit()
  Exit
EndFunc

Share this post


Link to post
Share on other sites



First: You can have numbers as variables? I thought a variable like $23 would error. Guess I was wrong.

Second:

$x = "$" & $Round

That doesn't set $x to the value of the variable. It sets $x to a string that has a dollar sign and a random number. If you want to randomly choose one of those variables, use Eval()

Something like this:

$x = Eval($Round)

Share this post


Link to post
Share on other sites

First: You can have numbers as variables? I thought a variable like $23 would error. Guess I was wrong.

Second:

$x = "$" & $Round

That doesn't set $x to the value of the variable. It sets $x to a string that has a dollar sign and a random number. If you want to randomly choose one of those variables, use Eval()

Something like this:

$x = Eval($Round)

<{POST_SNAPBACK}>

thx man..

Share this post


Link to post
Share on other sites

No prob. Oh and since I didn't answer it before, no you can't set the color of a button. You can set it to display an image, but I think that's the best you'll get.

Share this post


Link to post
Share on other sites

No prob. Oh and since I didn't answer it before, no you can't set the color of a button. You can set it to display an image, but I think that's the best you'll get.

<{POST_SNAPBACK}>

okay, that would be fine too..

hmm, i want to make a little game, just for fun..

When the "push!" butten shows, i want to ba able to push that button, at do something specific. But only when its "active" how can i do that? :lmao:

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)

Dim $button[57] , $L = 320 , $S = 200 , $gui = GUICreate("mirror?", @DeskTopWidth + 5, @DesktopHeight) , $count
GUISetOnEvent($GUI_EVENT_CLOSE , "myexit")


For $x_loop = 1 to 8
For $y_loop = 1 to 7
$count = $count + 1
$button[$count] = GUICtrlCreateButton($count , $L + ($x_loop * 50) , $S + ($y_loop * 50) , 50 , 50)
GUICtrlSetOnEvent( $button[$count] , "_msg")
Next
Next



$label = GUICtrlCreateLabel("", 100, 50, 100, 20)

GUISetState()

While 1
;$x = Eval ( Random( 1, 56, 1) );<<<<<<<<<<use eval :)

$x = $button[Random( 1, 56, 1)]
GUIctrlsetdata($x, "PUSH!")
GUIctrlsetdata($label, $x)
sleep(500)
Wend



Func _msg()
$msg = @GUI_CTRLID

For $b_loop = 1 to 56
If $msg = $button[$b_loop] then
WinSetTitle ($gui , "" , "Button #" & $b_loop)
endif
next
endfunc

Func myexit()
  Exit
EndFunc

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  
Followers 0