Jump to content
Sign in to follow this  
dimchik

Checkbox Background blinks rapidly

Recommended Posts

dimchik

In this code i am trying to create automated program installer for adobe so I check if program already installed and if yes i set background of checkbox to red.

And when I do it it blinks very fast.

#include <GuiConstants.au3>

;#include <GuiCombo.au3>

#Include <GuiStatusBar.au3>

;#include <GUIConstants.au3>

#include <array.au3>

Opt('MustDeclareVars', 1)

Dim $a_check[50], $msg, $ret, $s_attr, $allocated, $Status, $GUI

Dim $input, $group, $a_attr, $Combo, $button, $btn_exit, $i, $var6regkey

$GUI = GUICreate("Software Installation", 500, 500)

$var6regkey=RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Adobe\Adobe Acrobat\6.0\Installer", "ENU_GUID") ;key to identify adobe 6 version

$group = GUICtrlCreateGroup("Software options", 10, 20, 480, 445)

$a_attr = StringSplit("A,D,H,RO,RW,S,E,Drives,NB,NB,NB,NB", ",")

$a_check[0] = 9

$a_check[1] = GUICtrlCreateCheckbox("Adobe Acrobat 6.0 Stnd", 15, 35, 150, 20)

GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group

$button = GUICtrlCreateButton("Install", 240, 335, 120, 40)

$btn_exit = GUICtrlCreateButton("Exit", 240, 380, 120, 40)

$i=3

GUISetState()

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE Or $msg = $btn_exit

Exit

case $msg=$button

call("install")

Case BitAND(GUICtrlRead($a_check[1]), $GUI_CHECKED)

call("adobe6stndcolor")

EndSelect

WEnd

Exit

Func adobe6stndcolor() ;checks if adobe stnd installed and if yes makes checkbox red

select

case $var6regkey="{AC76BA86-1033-0000-BA7E-000000000001}"

GUICtrlSetBkColor($a_check[1], 0xff3030)

EndSelect

EndFunc

Func install()

EndFunc

Share this post


Link to post
Share on other sites
stampy

From what I can tell, you are checking the checkbox on every loop, then if its checked setting the color on every loop. Might want to check / set color only if it's changed.

Share this post


Link to post
Share on other sites
Achilles

#include <GuiConstants.au3>
;#include <GuiCombo.au3>
#Include <GuiStatusBar.au3>
;#include <GUIConstants.au3>
#include <array.au3>
Opt('MustDeclareVars', 1)

Dim $a_check[50], $msg, $ret, $s_attr, $allocated, $Status, $GUI
Dim $input, $group, $a_attr, $Combo, $button, $btn_exit, $i, $var6regkey

$GUI = GUICreate("Software Installation", 500, 500)
$var6regkey=RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Adobe\Adobe Acrobat\6.0\Installer", "ENU_GUID");key to identify adobe 6 version
$group = GUICtrlCreateGroup("Software options", 10, 20, 480, 445)
$a_attr = StringSplit("A,D,H,RO,RW,S,E,Drives,NB,NB,NB,NB", ",")
$a_check[0] = 9
$a_check[1] = GUICtrlCreateCheckbox("Adobe Acrobat 6.0 Stnd", 15, 35, 150, 20)

GUICtrlCreateGroup("", -99, -99, 1, 1);close group
$button = GUICtrlCreateButton("Install", 240, 335, 120, 40)
$btn_exit = GUICtrlCreateButton("Exit", 240, 380, 120, 40)
$i=3
Dim $highlighted = False; <-- Added this part
GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE Or $msg = $btn_exit
            Exit
        case $msg=$button
            call("install")
        Case BitAND(GUICtrlRead($a_check[1]), $GUI_CHECKED)
            call("adobe6stndcolor")
        EndSelect
WEnd

Exit

Func adobe6stndcolor();checks if adobe stnd installed and if yes makes checkbox red
    select
        case $var6regkey="{AC76BA86-1033-0000-BA7E-000000000001}"
            If $highlighted = False then 
                GUICtrlSetBkColor($a_check[1], 0xff3030)
                $highlighted = True 
        EndIf 

    EndSelect
EndFunc

Func install()
EndFunc
Once the checkbox was selected it would continue to set the box to red even though it was already red. This way it works... However I don't think it is very efficient because it is still constantly checking to see if the boolean $highlighted is false, but unless you know how to use GuiRegisterMsg() there's no way (I think) to fix that...

Edited by Piano_Man

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites
dimchik

I introduced sleep(100) delay before end of the loop for gui it should slow down blinking drasticly but it slows down the program respons to the close or exit.

Share this post


Link to post
Share on other sites
Achilles

I introduced sleep(100) delay before end of the loop for gui it should slow down blinking drasticly but it slows down the program respons to the close or exit.

Did you try what I posted? I think it worked well, and you wouldn't get the problem of the program being unresponsive...

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

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  

×