Jump to content
Sign in to follow this  
gottygolly

Why are my buttons blinking?

Recommended Posts

gottygolly

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:

$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 by gottygolly

Share this post


Link to post
Share on other sites
lorenkinzel

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 by lorenkinzel

Share this post


Link to post
Share on other sites
gottygolly

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.

Share this post


Link to post
Share on other sites
FireFox

Slow down the changes you do to your controls, put a timer for that.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
gottygolly

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:

#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 by gottygolly

Share this post


Link to post
Share on other sites
FireFox

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 by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

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  

×