Jump to content

Problem with checkbox


Recommended Posts

Hi,

Need help with Checkboxes:

Description:

When a checkbox get "checked" a InputBox opens. <- work

When a checkbox get unchecked it should NOT open a Inputbox, but when i unheck the checkbox the damn Inputbox opens

My Code:

$Herooff = GuiCtrlCreateCheckbox("Hero", 30, 240, 130);checkbox

Case $msg = $Herooff
                $InputHerooff = InputBox("Hero", "Hero?")
                Iniwrite("off.ini", "Truppen", "Hero", $InputHerooff)

It is not the whole Code... only a little part.

Link to comment
Share on other sites

the Case statement *imprettysure* only means if it is Checked\Unchecked (both) so maybe try

if $msg = $Herooff then

$InputHerooff = InputBox("Hero", "Hero?")

Iniwrite("off.ini", "Truppen", "Hero", $InputHerooff)

endif

OR

if $herooff = '4' then ;meaning if it is OFF;

$InputHerooff = InputBox("Hero", "Hero?")

Iniwrite("off.ini", "Truppen", "Hero", $InputHerooff)

endif

OR

if $herooff = '1' then ;meaning if it is ON;

$InputHerooff = InputBox("Hero", "Hero?")

Iniwrite("off.ini", "Truppen", "Hero", $InputHerooff)

endif

Link to comment
Share on other sites

sorry bout that, no it is not P:

Link to comment
Share on other sites

@bob00037

KillingEye would understand if you put codes for scripts :

if $msg = $Herooff then
$InputHerooff = InputBox("Hero", "Hero?")
Iniwrite("off.ini", "Truppen", "Hero", $InputHerooff)
endif

OR

if $herooff = '4' then;meaning if it is OFF;
$InputHerooff = InputBox("Hero", "Hero?")
Iniwrite("off.ini", "Truppen", "Hero", $InputHerooff)
endif

OR

if $herooff = '1' then;meaning if it is ON;
$InputHerooff = InputBox("Hero", "Hero?")
Iniwrite("off.ini", "Truppen", "Hero", $InputHerooff)
endif

Cheers, FireFox.

Link to comment
Share on other sites

yeha thats what i ment lol, i should sstart using code brakets more... andyway you cloud try those NOT THE 'OR' lol and if neither work then idk

Link to comment
Share on other sites

$msg will = $herooff when it is checked or unchecked (because in a GUI you might want it to show elements when checked, and hide elements when unchecked

$hereoff is always going to be constant, as it's the controlID. So checking it against other values won't do anything

GUICtrlRead($Herooff) will tell you if it's checked or not.

It will equal 1 if checked, 0 if unchecked.

Case $msg = $Herooff AND GUICtrlRead($Herooff)=1
                $InputHerooff = InputBox("Hero", "Hero?")
                Iniwrite("off.ini", "Truppen", "Hero", $InputHerooff)
Edited by TurionAltec
Link to comment
Share on other sites

lol no problem

ps i thought unchecked = 4 and checked =1 thats what my msgbox(0,'',guictrlread()) says

Link to comment
Share on other sites

lol no problem

ps i thought unchecked = 4 and checked =1 thats what my msgbox(0,'',guictrlread()) says

You're right!

I shouldn't have been so sloppy. Plus it could be reporting if it has focus, so we should do a BitAnd.

If we include <GUIConstantsEx.au3>:

$GUI_UNCHECKED=4

$GUI_CHECKED =1

So we could code it in as:

Case $msg = $Herooff AND BitAnd(GUICtrlRead($Herooff),$GUI_CHECKED)=$GUI_CHECKED
                $InputHerooff = InputBox("Hero", "Hero?")
                Iniwrite("off.ini", "Truppen", "Hero", $InputHerooff)
Link to comment
Share on other sites

looks good to me :)

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...