Jump to content

my GUI is almost complete but cant get Checkbox to work


Recommended Posts

I have a gui i set up that writes values to an .ini file for a program i created. here's my code

#include <GUIConstants.au3>
; == GUI generated with Koda ==
$Form1 = GUICreate("Mp3Copy Configuration", 643, 481, 185, 125)
$List1 = GUICtrlCreateList("FlashDrive", 16, 56, 169, 136, -1, $WS_EX_CLIENTEDGE)
gUICtrlSetData(3,"FTP|BT")
$Input1 = GUICtrlCreateInput("", 464, 128, 153, 37, -1, $WS_EX_CLIENTEDGE)
$Input2 = GUICtrlCreateInput("", 344, 232, 273, 37, -1, $WS_EX_CLIENTEDGE)
$Input3 = GUICtrlCreateInput("", 344, 320, 273, 37, -1, $WS_EX_CLIENTEDGE)
$Input4 = GUICtrlCreateInput("", 344, 400, 273, 37, -1, $WS_EX_CLIENTEDGE)
$Combo1 = GUICtrlCreateCombo("File", 16, 264, 177, 21)
gUICtrlSetData(8,"Album")
$okbutton = GUICtrlCreateButton("Save", 16, 360, 113, 81)
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
GUICtrlCreateLabel("Select Send Method", 16, 24, 240, 33)
GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
GUICtrlCreateLabel("Select Copy Method", 16, 224, 239, 33)
GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
GUICtrlCreateLabel("Enter Wait Time (in milliseconds)", 232, 96, 391, 33)
GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
GUICtrlCreateLabel("Enter File Path", 440, 192, 177, 33)
GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
GUICtrlCreateLabel("Enter FTP Site (ex. ftp://USER:PASS@SITE)", 208, 288, 414, 28)
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
GUICtrlCreateLabel("Enter Bluetooth Site", 384, 368, 237, 33)
GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
$RRCheckbox = GUICtrlCreateCheckbox("Click Here if Running Inside RR", 328, 24, 313, 41)
GUICtrlSetState(16, $GUI_unchecked)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        case $msg = $okbutton
            ExitLoop
        case $msg = $Input1
            $time= GUICtrlRead(4)
            iniwrite("C:\Program Files\Mp3copy\mp3copy.ini","mp3copy","WaitTimeTrack",$time)
        case $msg = $Input2
            $dirpath= GUICtrlRead(5)
            iniwrite("C:\Program Files\Mp3copy\mp3copy.ini","mp3copy","DestinationSite",$dirpath)
        case $msg = $input3
            $ftppath= GUICtrlRead(6)
            iniwrite("C:\Program Files\Mp3copy\mp3copy.ini","mp3copy","ftpsite",$ftppath)
        case $msg = $Input4
            $btpath= guictrlread(7)
            iniwrite("C:\Program Files\Mp3copy\mp3copy.ini","mp3copy","BTSite",$btpath)
        case $msg = $Combo1
            $copymethod= guictrlread(8)
            iniwrite("C:\Program Files\Mp3copy\mp3copy.ini","mp3copy","CopyMethod",$copymethod)
        Case $msg = $List1
            $Sendmethod= GUICtrlRead(3)
            iniwrite("C:\Program Files\Mp3copy\mp3copy.ini","mp3copy","Sendmethod",$Sendmethod)
        case $msg = $RRCheckbox
            $Sendconfirm = BitAnd(GUICtrlRead($RRCheckbox),$GUI_CHECKED)
            if $Sendconfirm = 1 Then
                iniwrite("C:\Program Files\Mp3copy\mp3copy.ini","mp3copy","Sendmethod","True")
            Else
                iniwrite("C:\Program Files\Mp3copy\mp3copy.ini","mp3copy","Sendmethod","False")
            Endif
    EndSelect
WEnd
Exit

Only thing thats not working is the checkbox. Different ways i tried the checkbox either always sent the true message to the .ini or no message at all. How do i make script check if the checkbox is checked or not and send the correct iniwrite based on that find?

Link to comment
Share on other sites

one more question regarding checkbox's.

How do i tell the .exe to read the .ini file and precheck the box if the correct value is found. I understand iniread but i dont understand how to set the box to check itself. I've tried guictrlsetdata(16,$gui_checked) Doesnt work

Link to comment
Share on other sites

Hi,

try it this way:

#include <GUIConstants.au3>
HotKeySet("1", "check")
HotKeySet("2", "uncheck")

GUICreate("My GUI Checkbox")  ; will create a dialog box that when displayed is centered

$checkCN = GUICtrlCreateCheckbox ("CHECKBOX 1", 10, 10, 120, 20)

GUISetState ()       ; will display an  dialog box with 1 checkbox

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

Func check()
    GUICtrlSetState($checkCN, $GUI_CHECKED)
EndFunc

Func uncheck()
    GUICtrlSetState($checkCN, $GUI_UNCHECKED)
EndFunc

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

I'm doing the same thing in a program I am writing.

How I do it:

Global $r_Ini_alogout = IniRead($INI, "Data", "ALogout", "") ; the "" will either be 0 or 1

$LOG = GUICtrlCreateCheckbox("Auto-logout", 152, 64, 81, 17)
If $r_Ini_alogout = 1 Then
    GUICtrlSetState($LOG, $GUI_CHECKED) ; this checks the checkbox on startup if "1"
EndIf

Pretty simple when you think about it. :D

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