gottygolly Posted March 14, 2014 Share Posted March 14, 2014 (edited) I was messing around and thought I try out some stuff with colors and managed to make a thing where the background in the gui is kind of glowing. My problem though is if it goes too fast the buttons start to blink, is this the result of the script trying to run really fast or is there an error some where else? Code: expandcollapse popup$gui = GUICreate("",200,200) $hex = 0x000000 $go = GUICtrlCreateButton("Go Button",100,0,70,30) $go2 = GUICtrlCreateButton("Go GUI",0,0,70,30) $label = GUICtrlCreateLabel("",0,50,500,500) $button1 = GUICtrlCreateButton("Button",0,150,100,30) GUICtrlSetFont($label,15,700) GUICtrlSetFont($button1,15,700) GUICtrlSetColor($button1,0xAAAAAA) GUISetState() while 1 $msg = GUIGetMsg(1) Switch $msg[1] Case $gui Switch $msg[0] Case -3 Exit Case $go first() Case $go2 first2() EndSwitch EndSwitch WEnd Func first() while 1 If GUICtrlRead($label) < 200 Then $hex = $hex + Dec(0x000005) GUICtrlSetData($label,$hex) GUICtrlSetBkColor($button1,$hex) Sleep(200) Switch GUIGetMsg() Case -3 Exit EndSwitch Else second() ExitLoop EndIf WEnd EndFunc Func second() while 1 $hex = $hex - Dec(0x000005) GUICtrlSetData($label,$hex) GUICtrlSetBkColor($button1,$hex) Sleep(200) If GUICtrlRead($label) = 0 Then first() ExitLoop EndIf Switch GUIGetMsg() Case -3 Exit EndSwitch WEnd EndFunc Func first2() while 1 If GUICtrlRead($label) < 200 Then $hex = $hex + Dec(0x000001) GUICtrlSetData($label,$hex) GUISetBkColor($hex) ;Sleep(200) Switch GUIGetMsg() Case -3 Exit EndSwitch Else second2() ExitLoop EndIf WEnd EndFunc Func second2() while 1 $hex = $hex - Dec(0x000001) GUICtrlSetData($label,$hex) GUISetBkColor($hex) ;Sleep(200) If GUICtrlRead($label) = 0 Then first2() ExitLoop EndIf Switch GUIGetMsg() Case -3 Exit EndSwitch WEnd EndFunc Thanks Edited March 14, 2014 by gottygolly Link to comment Share on other sites More sharing options...
lorenkinzel Posted March 14, 2014 Share Posted March 14, 2014 (edited) Someone else will probably give you a better fix & explanation, but a good start is: #include <WindowsConstants.au3> $gui = GUICreate("",200,200, -1, -1, $GUI_SS_DEFAULT_GUI, $WS_EX_COMPOSITED) to calm it down a bit. Edit: the other issues I do not understand tonight. Cool glow effect, though. Edited March 14, 2014 by lorenkinzel Link to comment Share on other sites More sharing options...
gottygolly Posted March 14, 2014 Author Share Posted March 14, 2014 I tried what you posted but the button isn't showing up now and when I move my mouse on the screen it causes the buttons to spaze out. I think I found a good point with it though, I just made it Dec(0x000004) with Sleep(175) and that seemed to calm it down just right, but I would like to get it to go faster if I can. Thanks for the help. Link to comment Share on other sites More sharing options...
FireFox Posted March 14, 2014 Share Posted March 14, 2014 Slow down the changes you do to your controls, put a timer for that. Link to comment Share on other sites More sharing options...
gottygolly Posted March 14, 2014 Author Share Posted March 14, 2014 (edited) Not sure what you mean by that Firefox, I think I do but im not positive. I just moved the Sleep above the GUISetBkColor and that seemed to fix it. Code: expandcollapse popup#include <WindowsConstants.au3> $gui = GUICreate("",200,200) $hex = 0x000018 $go = GUICtrlCreateButton("Go Button",100,0,70,30) $go2 = GUICtrlCreateButton("Go GUI",0,0,70,30) $label = GUICtrlCreateLabel("",0,50,500,500) $button1 = GUICtrlCreateButton("Button",0,150,100,30) GUICtrlSetFont($label,15,700) GUICtrlSetFont($button1,15,700) GUICtrlSetColor($button1,0xAAAAAA) GUISetState() while 1 $msg = GUIGetMsg(1) Switch $msg[1] Case $gui Switch $msg[0] Case -3 Exit Case $go first() Case $go2 first2() EndSwitch EndSwitch WEnd Func first() while 1 If GUICtrlRead($label) < 150 Then $hex = $hex + Dec(0x000004) GUICtrlSetData($label,$hex) Sleep(50) GUICtrlSetBkColor($button1,$hex) Switch GUIGetMsg() Case -3 Exit EndSwitch Else second() ExitLoop EndIf WEnd EndFunc Func second() while 1 $hex = $hex - Dec(0x000004) GUICtrlSetData($label,$hex) Sleep(100) GUICtrlSetBkColor($button1,$hex) If GUICtrlRead($label) <= 25 Then first() ExitLoop EndIf Switch GUIGetMsg() Case -3 Exit EndSwitch WEnd EndFunc Func first2() while 1 If GUICtrlRead($label) < 150 Then $hex = $hex + Dec(0x000001) GUICtrlSetData($label,$hex) Sleep(5) GUISetBkColor($hex) Switch GUIGetMsg() Case -3 Exit EndSwitch Else second2() ExitLoop EndIf WEnd EndFunc Func second2() while 1 $hex = $hex - Dec(0x000001) GUICtrlSetData($label,$hex) Sleep(5) GUISetBkColor($hex) If GUICtrlRead($label) <= 25 Then first2() ExitLoop EndIf Switch GUIGetMsg() Case -3 Exit EndSwitch WEnd EndFunc Edited March 14, 2014 by gottygolly Link to comment Share on other sites More sharing options...
FireFox Posted March 14, 2014 Share Posted March 14, 2014 (edited) There are a lot of things to change in your script. Don't go in sub loops, because in this case the main loop will be stuck (and so your GUI to messages) until your subloop is running. Edit : I see you used GUIGetMsg in your subloops to avoid the freeze, but anyway : put everything in your main loop. What I mean by timers is TimerInit/TimerDiff. Br, FireFox. Edited March 14, 2014 by FireFox Link to comment Share on other sites More sharing options...
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