stev379 Posted December 1, 2005 Posted December 1, 2005 Anybody have any suggestions or ideas for a better way to do this? It works great, but I'd prefer to shorten the code so it would get the same result on the screen without having so many lines of labels. I just haven't been able to figure out how to loop the labels without recreating a label with the same variable, but then the guictrldelete only gets the most recently created ctrl with that variable. expandcollapse popup#include <Constants.au3> #include <GUIConstants.au3> Opt("MustDeclareVars", 0); Turn on for final testing HotKeySet("{ESC}", "Terminate") $Main = GUICreate("Screensaver",@DesktopWidth,@DesktopHeight,0,0, $WS_POPUP) GUISetBkColor (0x000000) GuiSetState () $font="Terminal" _Rows1() ;Run until closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend Func _Rows1() $t = 0 $i = 0 $01 = Random(0, 1, 1) $02 = Random(0, 1, 1) $03 = Random(0, 1, 1) $04 = Random(0, 1, 1) $05 = Random(0, 1, 1) $06 = Random(0, 1, 1) $07 = Random(0, 1, 1) $08 = Random(0, 1, 1) $09 = Random(0, 1, 1) $10 = Random(0, 1, 1) $11 = Random(0, 1, 1) $12 = Random(0, 1, 1) $13 = Random(0, 1, 1) $14 = Random(0, 1, 1) $15 = Random(0, 1, 1) $16 = Random(0, 1, 1) $Label_01 = GUICtrlCreateLabel($01, 0, 0 , 12, 15) GUICtrlSetColor(-1,0xffffff) GUISetFont (12, 400, "", $font) $Label_02 = GUICtrlCreateLabel($02, 0, 0 , 12, 15) GUICtrlSetColor(-1,0xffffff) GUISetFont (12, 400, "", $font) $Label_03 = GUICtrlCreateLabel($03, 0, 0 , 12, 15) GUICtrlSetColor(-1,0xffffff) GUISetFont (12, 400, "", $font) $Label_04 = GUICtrlCreateLabel($04, 0, 0 , 12, 15) GUICtrlSetColor(-1,0xffffff) GUISetFont (12, 400, "", $font) $Label_05 = GUICtrlCreateLabel($05, 0, 0 , 12, 15) GUICtrlSetColor(-1,0xffffff) GUISetFont (12, 400, "", $font) $Label_06 = GUICtrlCreateLabel($06, 0, 0 , 12, 15) GUICtrlSetColor(-1,0xffffff) GUISetFont (12, 400, "", $font) $Label_07 = GUICtrlCreateLabel($07, 0, 0 , 12, 15) GUICtrlSetColor(-1,0xffffff) GUISetFont (12, 400, "", $font) $Label_08 = GUICtrlCreateLabel($08, 0, 0 , 12, 15) GUICtrlSetColor(-1,0xffffff) GUISetFont (12, 400, "", $font) $Label_09 = GUICtrlCreateLabel($09, 0, 0 , 12, 15) GUICtrlSetColor(-1,0xffffff) GUISetFont (12, 400, "", $font) $Label_10 = GUICtrlCreateLabel($10, 0, 0 , 12, 15) GUICtrlSetColor(-1,0xffffff) GUISetFont (12, 400, "", $font) $Label_11 = GUICtrlCreateLabel($11, 0, 0 , 12, 15) GUICtrlSetColor(-1,0xffffff) GUISetFont (12, 400, "", $font) $Label_12 = GUICtrlCreateLabel($12, 0, 0 , 12, 15) GUICtrlSetColor(-1,0xffffff) GUISetFont (12, 400, "", $font) $Label_13 = GUICtrlCreateLabel($13, 0, 0 , 12, 15) GUICtrlSetColor(-1,0xffffff) GUISetFont (12, 400, "", $font) $Label_14 = GUICtrlCreateLabel($14, 0, 0 , 12, 15) GUICtrlSetColor(-1,0xffffff) GUISetFont (12, 400, "", $font) $Label_15 = GUICtrlCreateLabel($15, 0, 0 , 12, 15) GUICtrlSetColor(-1,0xffffff) GUISetFont (12, 400, "", $font) $Label_16 = GUICtrlCreateLabel($16, 0, 0 , 12, 15) GUICtrlSetColor(-1,0xffffff) GUISetFont (12, 400, "", $font) $c = 0 While 1 Sleep(20) $01 = Random(0, 1, 1) $RW = Random(0, @DesktopWidth, 1) $RH = Random(0, @DesktopHeight, 1) GUICtrlDelete($Label_01) $Label_01 = GUICtrlCreateLabel($01, $RW, $RH, 12, 15) GUICtrlSetColor(-1,0xffffff) GUISetFont (12, 400, "", $font) Sleep(20) $02 = Random(0, 1, 1) $RW2 = Random(0, @DesktopWidth, 1) $RH2 = Random(0, @DesktopHeight, 1) GUICtrlDelete($Label_02) $Label_02 = GUICtrlCreateLabel($02, $RW2, $RH2, 12, 15) GUICtrlSetColor(-1,0xffffff) GUISetFont (12, 400, "", $font) Sleep(20) $03 = Random(0, 1, 1) $RW3 = Random(0, @DesktopWidth, 1) $RH3 = Random(0, @DesktopHeight, 1) GUICtrlDelete($Label_03) $Label_03 = GUICtrlCreateLabel($03, $RW3, $RH3, 12, 15) GUICtrlSetColor(-1,0xffffff) GUISetFont (12, 400, "", $font) Sleep(20) $04 = Random(0, 1, 1) $RW4 = Random(0, @DesktopWidth, 1) $RH4 = Random(0, @DesktopHeight, 1) GUICtrlDelete($Label_04) $Label_04 = GUICtrlCreateLabel($04, $RW4, $RH4, 12, 15) GUICtrlSetColor(-1,0xffffff) GUISetFont (12, 400, "", $font) Sleep(20) $05 = Random(0, 1, 1) $RW5 = Random(0, @DesktopWidth, 1) $RH5 = Random(0, @DesktopHeight, 1) GUICtrlDelete($Label_05) $Label_05 = GUICtrlCreateLabel($05, $RW5, $RH5, 12, 15) GUICtrlSetColor(-1,0xffffff) GUISetFont (12, 400, "", $font) Sleep(20) $06 = Random(0, 1, 1) $RW6 = Random(0, @DesktopWidth, 1) $RH6 = Random(0, @DesktopHeight, 1) GUICtrlDelete($Label_06) $Label_06 = GUICtrlCreateLabel($06, $RW6, $RH6, 12, 15) GUICtrlSetColor(-1,0xffffff) GUISetFont (12, 400, "", $font) Sleep(20) $07 = Random(0, 1, 1) $RW7 = Random(0, @DesktopWidth, 1) $RH7 = Random(0, @DesktopHeight, 1) GUICtrlDelete($Label_07) $Label_07 = GUICtrlCreateLabel($07, $RW7, $RH7, 12, 15) GUICtrlSetColor(-1,0xffffff) GUISetFont (12, 400, "", $font) Sleep(20) $08 = Random(0, 1, 1) $RW8 = Random(0, @DesktopWidth, 1) $RH8 = Random(0, @DesktopHeight, 1) GUICtrlDelete($Label_08) $Label_08 = GUICtrlCreateLabel($08, $RW8, $RH8, 12, 15) GUICtrlSetColor(-1,0xffffff) GUISetFont (12, 400, "", $font) Sleep(20) $09 = Random(0, 1, 1) $RW9 = Random(0, @DesktopWidth, 1) $RH9 = Random(0, @DesktopHeight, 1) GUICtrlDelete($Label_09) $Label_09 = GUICtrlCreateLabel($09, $RW9, $RH9, 12, 15) GUICtrlSetColor(-1,0xffffff) GUISetFont (12, 400, "", $font) Sleep(20) $10 = Random(0, 1, 1) $RW10 = Random(0, @DesktopWidth, 1) $RH10 = Random(0, @DesktopHeight, 1) GUICtrlDelete($Label_10) $Label_10 = GUICtrlCreateLabel($10, $RW10, $RH10, 12, 15) GUICtrlSetColor(-1,0xffffff) GUISetFont (12, 400, "", $font) Sleep(20) $11 = Random(0, 1, 1) $RW11 = Random(0, @DesktopWidth, 1) $RH11 = Random(0, @DesktopHeight, 1) GUICtrlDelete($Label_11) $Label_11 = GUICtrlCreateLabel($11, $RW11, $RH11, 12, 15) GUICtrlSetColor(-1,0xffffff) GUISetFont (12, 400, "", $font) Sleep(20) $12 = Random(0, 1, 1) $RW12 = Random(0, @DesktopWidth, 1) $RH12 = Random(0, @DesktopHeight, 1) GUICtrlDelete($Label_12) $Label_12 = GUICtrlCreateLabel($12, $RW12, $RH12, 12, 15) GUICtrlSetColor(-1,0xffffff) GUISetFont (12, 400, "", $font) Sleep(20) $13 = Random(0, 1, 1) $RW13 = Random(0, @DesktopWidth, 1) $RH13 = Random(0, @DesktopHeight, 1) GUICtrlDelete($Label_13) $Label_13 = GUICtrlCreateLabel($13, $RW13, $RH13, 12, 15) GUICtrlSetColor(-1,0xffffff) GUISetFont (12, 400, "", $font) Sleep(20) $14 = Random(0, 1, 1) $RW14 = Random(0, @DesktopWidth, 1) $RH14 = Random(0, @DesktopHeight, 1) GUICtrlDelete($Label_14) $Label_14 = GUICtrlCreateLabel($14, $RW14, $RH14, 12, 15) GUICtrlSetColor(-1,0xffffff) GUISetFont (12, 400, "", $font) Sleep(20) $15 = Random(0, 1, 1) $RW15 = Random(0, @DesktopWidth, 1) $RH15 = Random(0, @DesktopHeight, 1) GUICtrlDelete($Label_15) $Label_15 = GUICtrlCreateLabel($15, $RW15, $RH15, 12, 15) GUICtrlSetColor(-1,0xffffff) GUISetFont (12, 400, "", $font) Sleep(20) $16 = Random(0, 1, 1) $RW16 = Random(0, @DesktopWidth, 1) $RH16 = Random(0, @DesktopHeight, 1) GUICtrlDelete($Label_16) $Label_16 = GUICtrlCreateLabel($16, $RW16, $RH16, 12, 15) GUICtrlSetColor(-1,0xffffff) GUISetFont (12, 400, "", $font) $c = $c + 1 #cs If $c = 2 Then GUICtrlDelete($Label_01) GUICtrlDelete($Label_02) GUICtrlDelete($Label_03) GUICtrlDelete($Label_04) GUICtrlDelete($Label_05) GUICtrlDelete($Label_06) GUICtrlDelete($Label_07) GUICtrlDelete($Label_08) GUICtrlDelete($Label_09) GUICtrlDelete($Label_10) GUICtrlDelete($Label_11) GUICtrlDelete($Label_12) GUICtrlDelete($Label_13) GUICtrlDelete($Label_14) GUICtrlDelete($Label_15) GUICtrlDelete($Label_16) _Rows2() EndIf #ce WEnd EndFunc;==>_Rows1() Func Terminate() Exit 0 EndFunc Func _Msg($Msgs) MsgBox(0, $Msgs, $Msgs) EndFunc
w0uter Posted December 1, 2005 Posted December 1, 2005 (edited) like this? edit1: ripped even more edit2: small bugfix where numbers where cut off at the sides opt("MustDeclareVars", 1); Turn on for final testing HotKeySet("{ESC}", "Terminate") GUICreate("Screensaver", @DesktopWidth, @DesktopHeight, 0, 0, 0x80000000) GUISetBkColor(0) GUISetFont(12, 400, "", "Terminal") GUISetState() Dim $a_rray[15] While 1 For $i = 0 To 14 GUICtrlDelete($a_rray[$i]) Sleep(20) $a_rray[$i] = GUICtrlCreateLabel(Random(0, 1, 1), Random(0, @DesktopWidth-12, 1), Random(0, @DesktopHeight-15, 1), 12, 15) GUICtrlSetColor(-1, 0xFFFFFF) Next WEnd Func Terminate() Exit EndFunc ;==>Terminate Edited December 1, 2005 by w0uter My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll
stev379 Posted December 1, 2005 Author Posted December 1, 2005 (edited) No argument here! Well done. I wasn't far off with some of my array attemps, but it prolly would've taken a good while to get you where you got that quickly. Thanks big time!! Edited December 1, 2005 by stev379
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now