Jump to content

Sense the Changes


star2
 Share

Recommended Posts

ok here's my GUI

#include <guiconstants.au3>
GUICreate ("test" , 150 , 100)
$check = GUICtrlCreateCheckbox ("check-1" , 10 , 20)
$apply = GUICtrlCreateButton ("Apply" , 10 , 60 , 130)
GUICtrlSetState (-1 , $gui_disable)

$chk_1 = IniRead("test.ini" , "checks","chk_1",0)
If $chk_1 = 1 Then
    GUICtrlSetState ($check , $GUI_CHECKED)
ElseIf $chk_1 = 4 Then
    GUICtrlSetState ($check , $GUI_UNCHECKED)
EndIf

GUISetState ()

While 1
    $msg = GUIGetMsg ()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
        If GUICtrlRead ($check) <> $chk_1 Then
            GUICtrlSetState ($apply , $gui_enable)
        Else
            GUICtrlSetState ($apply , $gui_disable)
        EndIf
        If $msg = $apply Then
            If BitAND(GUICtrlRead($check),$GUI_CHECKED) = 1 THen
                IniWrite ("test.ini","checks","chk_1",1)
                GUICtrlSetState ($apply , $gui_disable)
            Else
                IniWrite ("test.ini","checks","chk_1",4)
                GUICtrlSetState ($apply , $gui_disable)
            EndIf
        EndIf
WEnd

I really don't know what am I missing?

all what I want is to make the script senses any changes on the checkbox

and also the button is always flickering

can anyone help?

ini___au3_files.zip

Edited by star2

[quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u]

Link to comment
Share on other sites

I put a small Sleep(10) in and it did less flicking but still some. I would guess you just check it too offen.

Edit:

#include <guiconstants.au3>
GUICreate ("test" , 150 , 100)
$check = GUICtrlCreateCheckbox ("check-1" , 10 , 20)
$apply = GUICtrlCreateButton ("Apply" , 10 , 60 , 130)
GUICtrlSetState (-1 , $gui_disable)

$chk_1 = IniRead("test.ini" , "checks","chk_1",0)
If $chk_1 = 1 Then
    GUICtrlSetState ($check , $GUI_CHECKED)
ElseIf $chk_1 = 4 Then
    GUICtrlSetState ($check , $GUI_UNCHECKED)
EndIf

GUISetState ()

While 1
    $msg = GUIGetMsg ()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
        If GUICtrlRead ($check) <> $chk_1 Then
            GUICtrlSetState ($apply , $gui_enable)
        Else
            GUICtrlSetState ($apply , $gui_disable)
        EndIf
        If $msg = $apply Then
            If BitAND(GUICtrlRead($check),$GUI_CHECKED) = 1 THen
                IniWrite ("test.ini","checks","chk_1",1)
                GUICtrlSetState ($apply , $gui_disable)
            Else
                IniWrite ("test.ini","checks","chk_1",4)
                GUICtrlSetState ($apply , $gui_disable)
            EndIf
        EndIf
    Sleep(10)
WEnd
Edited by Mr. Zero
Link to comment
Share on other sites

ok thanks

I don't think this is a good way to solve the flickering problem

but the problem is to make the script sense changes

Edited by star2

[quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u]

Link to comment
Share on other sites

  • Developers

try this version:

#include <guiconstants.au3>
GUICreate("test", 150, 100)
$check = GUICtrlCreateCheckbox("check-1", 10, 20)
$apply = GUICtrlCreateButton("Apply", 10, 60, 130)
GUICtrlSetState(-1, $gui_disable)
$chk_1 = Number(IniRead("test.ini", "checks", "chk_1", 1))
If $chk_1 = 1 Then
    GUICtrlSetState($check, $GUI_CHECKED)
ElseIf $chk_1 = 4 Then
    GUICtrlSetState($check, $GUI_UNCHECKED)
EndIf
GUISetState()
While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    If GUICtrlRead($check) <> $chk_1 Then
        If Bitand(GUICtrlGetState($apply),$gui_enable) <> $gui_enable Then GUICtrlSetState($apply, $gui_enable)
    Else
        If Bitand(GUICtrlGetState($apply),$gui_disable) <> $gui_disable Then GUICtrlSetState($apply, $gui_disable)
    EndIf
    If $msg = $apply Then
        If BitAND(GUICtrlRead($check), $GUI_CHECKED) = 1 Then
            IniWrite("test.ini", "checks", "chk_1", 1)
            GUICtrlSetState($apply, $gui_disable)
        Else
            IniWrite("test.ini", "checks", "chk_1", 4)
            GUICtrlSetState($apply, $gui_disable)
        EndIf
    EndIf
WEnd

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

try this version:

it stopped the flickering but I think I'm not explaining the problem currectly

after pressing the apply button some data will be written in the ini file and the button should be diabled

but if there was a change in the state of the checkbox the apply button state should be enable

what I mean is

the script should feel the changes and act according to it

with any change of the checkbox the apply button should be enabled

after pressing the apply button the button itself should be disabled

[quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u]

Link to comment
Share on other sites

  • Developers

you also need to update the var $chk_1 :)

#include <guiconstants.au3>
GUICreate("test", 150, 100)
$check = GUICtrlCreateCheckbox("check-1", 10, 20)
$apply = GUICtrlCreateButton("Apply", 10, 60, 130)
GUICtrlSetState(-1, $gui_disable)
$chk_1 = Number(IniRead("test.ini", "checks", "chk_1", 1))
If $chk_1 = 1 Then
    GUICtrlSetState($check, $GUI_CHECKED)
ElseIf $chk_1 = 4 Then
    GUICtrlSetState($check, $GUI_UNCHECKED)
EndIf
GUISetState()
While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    If GUICtrlRead($check) <> $chk_1 Then
        If Bitand(GUICtrlGetState($apply),$gui_enable) <> $gui_enable Then GUICtrlSetState($apply, $gui_enable)
    Else
        If Bitand(GUICtrlGetState($apply),$gui_disable) <> $gui_disable Then GUICtrlSetState($apply, $gui_disable)
    EndIf
    If $msg = $apply Then
        If BitAND(GUICtrlRead($check), $GUI_CHECKED) = $GUI_CHECKED Then
            IniWrite("test.ini", "checks", "chk_1", 1)
            $chk_1 = 1
        Else
            IniWrite("test.ini", "checks", "chk_1", 4)
            $chk_1 = 4 
        EndIf
        $rc = GUICtrlSetState($apply, $gui_disable)
    EndIf
WEnd
Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

u've got me Jos

thanks alot !!

[quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u]

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...