Jump to content

Get a Return Value from checkbox?


Recommended Posts

I have a check box, that when checked I want it to give me a returned value, 0 = checked, 1 = not check. So with that I can further base other functions. But I've looked through the Help Functions and its all way to in depth for me to grab anything from.

If someone could please explain this to me id greatly appreciate it. Thanks again

~Acid Alchamy~

Link to comment
Share on other sites

From the help file

For Checkbox, Radio control several states can be returned as $GUI_FOCUS and $GUI_CHECKED,. So use i.e. BitAnd(GUICtrlRead($Item),$GUI_CHECKED) to test if the control is checked.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I tried running this setup with a dummy function under "Script" like Send("{F2}") and nothing happened.

So am I even close to going about this the right way, or can you maybe shed some light on my situation here. Because once I get this one minor function right, the rest should be cake and all should be well.

Thanks again,

~Acid Alchamy~

#include 
#include 
#include 

Opt('MustDeclareVars', 1)
HotKeySet("{NUMPAD0}", "Script")

Example1()
Script()
gcs()
; example 1
Func Example1()
Local $msg
Local $gcs

GUICreate("Acid Alchamy", 300, 200); will create a dialog box that when displayed is centered
GUISetState(@SW_SHOW) ; will display an empty dialog box
GUICtrlCreateButton("GCScript", 0, 0, 300)
$getcords = GUICtrlCreateCheckbox("GCS: 891:543", 10, 50, 130, 20)
; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
GUIDelete()
EndFunc ;==>Example1

Func gcs()
Local $gcs
If BitAnd(GUICtrlRead($getcords),$GUI_CHECKED) Then
HotKeySet("{NUMPAD0}", "Script")
EndIf
EndFunc
Func Script()
;//my function
EndFunc
Link to comment
Share on other sites

Im only getting further and further lost =/

can someone please make maybe an example?

or just correct what i had posted above. Because I seem to be missing this terribly and pretty much just confusing myself. Its a shame I know..

Link to comment
Share on other sites

#include <GUIConstantsEx.au3>

HotKeySet("{NUMPAD0}", "")

GUICreate("Acid Alchamy", 300, 200)
GUICtrlCreateButton("GCScript", 0, 0, 300)
$getcords = GUICtrlCreateCheckbox("GCS: 891:543", 10, 50, 130, 20)
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

If IsChecked($getcords) Then HotKeySet("{NUMPAD0}", "Script")
GUIDelete()

Func Script()
    ;//my function
EndFunc   ;==>Script

Func IsChecked($control)
    Return BitAnd(GUICtrlRead($control),$GUI_CHECKED) = $GUI_CHECKED
EndFunc

Link to comment
Share on other sites

But where in that is the part where it would come back,

If

Checked

Then

....my next function....

I guess thats sorta what im trying to ask for. Sorry if im making this complicated, but i truly appreciate your help. thanks Zedna

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