Jump to content
Sign in to follow this  
Matt

Decreasing Numbers

Recommended Posts

Matt

Morning all

I am a complete noob when it comes to AutoIT, so be gentle with me :unsure:

I am looking to be able to make a GUI and script with a decreasing number based on option chosen within the GUI. Basically, the user would have 20 points available, and based on thier chosen option, I would like this number to decrease as options are chosen.

I have looked through the forums, but cant seem to find anything related to what I would like to acheive. Would anyone be able to point me in the right direction please?

I am not looking for someone to do this for me, just someone to give me a few pointers as to what code I would need to use to accomplish this. I want to learn myself :P

Cheers in advance

Matt

Share this post


Link to post
Share on other sites
Matt

Hi again.

Thx for the reply. I am trying to write a client/server program for entertainers in a particular MMO. The code is:

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Opt("MustDeclareVars", 0)

buffgui()

Func buffGUI()

Local $exit_button, $msg

#Region ### START Koda GUI section ### Form=c:\documents and settings\matt\desktop\form_test1.kxf
$Form1 = GUICreate("Buffage V1.0", 814, 450, 463, 184)
GUISetIcon("C:\Program Files\StarWarsGalaxies\favicon.ico")
GUISetFont(10, 400, 0, "Arial")
$exit_button = GUICtrlCreateButton("Exit", 704, 416, 97, 25, 0)
GUICtrlSetFont(-1, 10, 800, 0, "Arial")
GUICtrlSetTip(-1, "Click to exit")
$send_button = GUICtrlCreateButton("Send", 600, 416, 97, 25, 0)
GUICtrlSetFont(-1, 10, 800, 0, "Arial")
GUICtrlSetTip(-1, "Click to request your buff")
$txt1_label = GUICtrlCreateLabel("Choose the buff you wish to recieve by using the drop down menu's and check boxes. ", 8, 40, 551, 20)
GUICtrlSetFont(-1, 10, 800, 0, "Arial")
$txt2_label = GUICtrlCreateLabel("When you have chosen your buff, click the send button to request your entertainer buff.", 8, 56, 556, 20)
GUICtrlSetFont(-1, 10, 800, 0, "Arial")
$title_label = GUICtrlCreateLabel("Buffage V1.0", 8, 8, 121, 26)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
$attributes_group = GUICtrlCreateGroup("Attributes - 1 Point", 8, 80, 177, 225)
GUICtrlSetFont(-1, 10, 800, 0, "Arial")
$agility_comb = GUICtrlCreateCombo("Agility", 32, 104, 129, 25)
GUICtrlSetData(-1, "Agility x 1|Agility x 2|Agility x 3|Agility x 4|Agility x 5")
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
$cons_combo = GUICtrlCreateCombo("Constitution", 32, 136, 129, 25)
GUICtrlSetData(-1, "Constitution x 1|Constitution x 2|Constitution x 3|Constitution x 4|Constitution x 5")
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
$luck_comb = GUICtrlCreateCombo("Luck", 32, 168, 129, 25)
GUICtrlSetData(-1, "Luck x 1|Luck x 2|Luck x 3|Luck x 4|Luck x 5")
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
$Strength_combo = GUICtrlCreateCombo("Strength", 32, 200, 129, 25)
GUICtrlSetData(-1, "Strength x 1|Strength x 2|Strength x 3|Strength x 4|Strength x 5")
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
$stam_combo = GUICtrlCreateCombo("Stamina", 32, 232, 129, 25)
GUICtrlSetData(-1, "Stamina x 1|Stamina x 2|Stamina x 3|Stamina x 4|Stamina x 5")
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
$pre_combo = GUICtrlCreateCombo("Precision", 32, 264, 129, 25)
GUICtrlSetData(-1, "Precision x 1|Precision x 2|Precision x 3|Precision x 4|Precision x 5")
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$armour_group = GUICtrlCreateGroup("Armour - 1 Point", 8, 320, 177, 97)
GUICtrlSetFont(-1, 10, 800, 0, "Arial")
$kinetic_comb = GUICtrlCreateCombo("Kinetic Armour", 32, 344, 145, 25)
GUICtrlSetData(-1, "Kinetic Armour x 1|Kinetic Armour x 2|Kinetic Armour x 3|Kinetic Armour x 4|Kinetic Armour x 5")
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
$energy_comb = GUICtrlCreateCombo("Energy Armour", 32, 376, 145, 25)
GUICtrlSetData(-1, "Energy Armour x 1|Energy Armour x 2|Energy Armour x 3|Energy Armour x 4|Energy Armour x 5")
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$combat_group = GUICtrlCreateGroup("Combat - 5 Points", 208, 80, 209, 97)
GUICtrlSetFont(-1, 10, 800, 0, "Arial")
$gb_label = GUICtrlCreateLabel("Glancing Blow", 232, 104, 87, 20)
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
$acr_label = GUICtrlCreateLabel("Action Cost Reduction", 232, 128, 134, 20)
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
$crit_label = GUICtrlCreateLabel("Critical Chance", 232, 152, 92, 20)
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
$gb_check = GUICtrlCreateCheckbox("", 376, 104, 17, 17)
$acr_check = GUICtrlCreateCheckbox("", 376, 128, 17, 17)
$crit_check = GUICtrlCreateCheckbox("", 376, 152, 17, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$misc_group = GUICtrlCreateGroup("Misc - 2 Points", 208, 192, 209, 225)
GUICtrlSetFont(-1, 10, 800, 0, "Arial")
$healer_combo = GUICtrlCreateCombo("Healer", 232, 280, 169, 25)
GUICtrlSetData(-1, "Healer x 1|Healer x 2|Healer x 3|Healer x 4|Healer x 5")
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
$flush_comb = GUICtrlCreateCombo("Flush With Success", 232, 216, 169, 25)
GUICtrlSetData(-1, "Flush With Success x 1|Flush With Success x 2|Flush With Success x 3|Flush With Success x 4|Flush With Success x 5")
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
$harvest_comb = GUICtrlCreateCombo("Harvest Fair", 232, 248, 169, 25)
GUICtrlSetData(-1, "Harvest Fair x 1|Harvest Fair x 2|Harvest Fair x 3|Harvest Fair x 4|Harvest Fair x 5")
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
$res_combo = GUICtrlCreateCombo("Resilience", 232, 312, 169, 25)
GUICtrlSetData(-1, "Resilience x 1|Resilience x 2|Resilience x 3|Resilience x 4|Resilience x 5")
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
$go_with_combo = GUICtrlCreateCombo("Go With The Flow", 232, 344, 169, 25)
GUICtrlSetData(-1, "Go With The Flow x 1|Go With The Flow x 2|Go With The Flow x 3|Go With The Flow x 4|Go With The Flow x 5")
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
$second_combo = GUICtrlCreateCombo("Second Chance", 232, 376, 169, 25)
GUICtrlSetData(-1, "Second Chance x 1|Second Chance x 2|Second Chance x 3|Second Chance x 4|Second Chance x 5")
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$trader_group = GUICtrlCreateGroup("Trader - 2 Points", 440, 80, 345, 225)
GUICtrlSetFont(-1, 10, 800, 0, "Arial")
$archi_combo = GUICtrlCreateCombo("Architecture", 464, 104, 145, 25)
GUICtrlSetData(-1, "Architecture x 1|Architecture x 2|Architecture x 3|Architecture x 4|Architecture x 5")
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
$fashion_combo = GUICtrlCreateCombo("Fashion", 624, 104, 145, 25)
GUICtrlSetData(-1, "Fashion x 1|Fashion x 2|Fashion x 3|Fashion x 4|Fashion x 5")
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
$booster_combo = GUICtrlCreateCombo("Booster Assy", 464, 136, 145, 25)
GUICtrlSetData(-1, "Booster Assy x 1|Booster Assy x 2|Booster Assy x 3|Booster Assy x 4|Booster Assy x 5")
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
$munitions_combo = GUICtrlCreateCombo("Munitions", 624, 136, 145, 25)
GUICtrlSetData(-1, "Munitions x 1|Munitions x 2|Munitions x 3|Munitions x 4|Munitions x 5")
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
$chassis_combo = GUICtrlCreateCombo("Chassis Assy", 464, 168, 145, 25)
GUICtrlSetData(-1, "Chassis Assy x 1|Chassis Assy x 2|Chassis Assy x 3|Chassis Assy x 4|Chassis Assy x 5")
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
$security_combo = GUICtrlCreateCombo("Security", 624, 168, 145, 25)
GUICtrlSetData(-1, "Security x 1|Security x 2|Security x 3|Security x 4|Security x 5")
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
$culinary_combo = GUICtrlCreateCombo("Culinary", 464, 200, 145, 25)
GUICtrlSetData(-1, "Culinary x 1|Culinary x 2|Culinary x 3|Culinary x 4|Culinary x 5")
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
$shield_combo = GUICtrlCreateCombo("Shield Assy", 624, 200, 145, 25)
GUICtrlSetData(-1, "Shield Assy x 1|Shield Assy x 2|Shield Assy x 3|Shield Assy x 4|Shield Assy x 5")
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
$Droid_combo = GUICtrlCreateCombo("Droid Tech", 464, 232, 145, 25)
GUICtrlSetData(-1, "Droid Tech x 1|Droid Tech x 2|Droid Tech x 3|Droid Tech x 4|Droid Tech x 5")
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
$power_combo = GUICtrlCreateCombo("Power Systems", 624, 232, 145, 25)
GUICtrlSetData(-1, "Power Systems x 1|Power Systems x 2|Power Systems x 3|Power Systems x 4|Power Systems x 5")
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
$engine_assy = GUICtrlCreateCombo("Engine Assy", 464, 264, 145, 25)
GUICtrlSetData(-1, "Engine Assy x 1|Engine Assy x 2|Engine Assy x 3|Engine Assy x 4|Engine Assy x 5")
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
$weapon_combo = GUICtrlCreateCombo("Weapon Systems", 624, 264, 145, 25)
GUICtrlSetData(-1, "Weapon Systems x 1|Weapon Systems x 2|Weapon Systems x 3|Weapon Systems x 4|Weapon Systems x 5")
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $exit_button
Exit
EndSelect
WEnd
EndFunc

Also, is there a way that I can start the GUI without the blue boxes over each of the combo boxes?

Cheers

Matt

Share this post


Link to post
Share on other sites
FireFox

@Matt

I dont understand what you mean...

Maybe :

$agility_comb = GUICtrlCreateCombo("Agility", 32, 104, 129, 25, $CBS_DROPDOWNLIST)

Cheers, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
Matt

Maybe :

$agility_comb = GUICtrlCreateCombo("Agility", 32, 104, 129, 25, $CBS_DROPDOWNLIST)
You star thats exactly what I wanted :P

Now, anyone able to help with the request in the OP?

Cheers

Matt

Share this post


Link to post
Share on other sites
weaponx

This ended up being a lot more complex than I thought it would. Good luck.

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.0.0
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

#include <GUIComboBox.au3>
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Opt("MustDeclareVars", 0)

Const $default_font = "Arial"
Const $bold = 600, $normal = 400
Global $aGroup1[6][2] = [["Agility",""],["Constitution",""],["Luck",""],["Strength",""],["Stamina",""],["Precision",""]]
Global $aGroup2[2][2] = [["Kinetic Armour",""],["Energy Armour",""]]
Global $aGroup3[6][2] = [["Healer",""],["Flush With Success",""],["Harvest Fair",""],["Resilience",""],["Go With The Flow",""],["Second Chance",""]]
Global $aGroup4a[6][2] = [["Architecture",""],["Booster Assy",""],["Chassis Assy",""],["Culinary",""],["Droid Tech",""],["Engine Assy",""]]
Global $aGroup4b[6][2] = [["Fashion",""],["Munitions",""],["Security",""],["Shield Assy",""],["Power Systems",""],["Weapon Systems",""]]
Global $Attribute_Total,$Armour_Total,$Combat_Total,$Misc_Total,$Trader_Total
Global $gb_check,$acr_check,$crit_check

buffgui()

Func buffGUI()

    Local $exit_button, $msg

    #Region ### START Koda GUI section ### Form=c:\documents and settings\matt\desktop\form_test1.kxf
    $Form1 = GUICreate("Buffage V1.0", 814, 470)
    GUISetIcon("C:\Program Files\StarWarsGalaxies\favicon.ico")
    GUISetFont(10, $normal, 0, $default_font)
    
    $update_button = GUICtrlCreateButton("Update Totals", 600, 380, 200, 25, 0)
    GUICtrlSetFont(-1, 10, $bold, 0, $default_font)
    
    $send_button = GUICtrlCreateButton("Send", 600, 416, 97, 25, 0)
    GUICtrlSetFont(-1, 10, $bold, 0, $default_font)
    GUICtrlSetTip(-1, "Click to request your buff")    
    
    $exit_button = GUICtrlCreateButton("Exit", 704, 416, 97, 25, 0)
    GUICtrlSetFont(-1, 10, $bold, 0, $default_font)
    GUICtrlSetTip(-1, "Click to exit")
    
    $txt1_label = GUICtrlCreateLabel("Choose the buff you wish to recieve by using the drop down menu's and check boxes. ", 8, 40, 551, 20)
    GUICtrlSetFont(-1, 10, $normal, 0, $default_font)
    $txt2_label = GUICtrlCreateLabel("When you have chosen your buff, click the send button to request your entertainer buff.", 8, 56, 556, 20)
    GUICtrlSetFont(-1, 10, $normal, 0, $default_font)
    $title_label = GUICtrlCreateLabel("Buffage V1.0", 8, 8, 121, 26)
    GUICtrlSetFont(-1, 14, $bold, 0, $default_font)
    
    ;GROUP - Attributes
    GUICtrlCreateGroup("Attributes - 1 Point", 8, 80, 177, 235)
    GUICtrlSetFont(-1, 10, $bold, 0, $default_font)
    
    For $X = 0 to Ubound($aGroup1)-1
        GUICtrlCreateLabel($aGroup1[$X][0], 30, 104+($X*32), 90, 25)
        ;GUICtrlSetBkColor(-1,0x445566)
        $aGroup1[$X][1] = GUICtrlCreateCombo(0, 120, 104+($X*32), 40, 25)
        PopulateDropdown(-1)
        GUICtrlSetFont(-1, 10, $normal, 0, $default_font)
    Next
    GUICtrlCreateLabel("TOTAL:",30,295,45,15)
    GUICtrlSetFont(-1, 8, $bold, 0, $default_font)
    ;GUICtrlSetBkColor(-1,0x445566)
    $Attribute_Total = GUICtrlCreateLabel("0",80,295,40,15)
    GUICtrlSetFont(-1, 8, $bold, 0, $default_font)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    
    ;GROUP - ARMOUR
    GUICtrlCreateGroup("Armour - 1 Point", 8, 330, 177, 107)
    GUICtrlSetFont(-1, 10, $bold, 0, $default_font)
    For $X = 0 to Ubound($aGroup2)-1
        GUICtrlCreateLabel($aGroup2[$X][0], 30, 350+($X*32), 90, 25)
        ;GUICtrlSetBkColor(-1,0x445566)
        $aGroup2[$X][1] = GUICtrlCreateCombo(0, 130, 350+($X*32), 40, 25)
        PopulateDropdown(-1)
        GUICtrlSetFont(-1, 10, $normal, 0, $default_font)
    Next
    GUICtrlCreateLabel("TOTAL:",30,415,45,15)
    GUICtrlSetFont(-1, 8, $bold, 0, $default_font)
    ;GUICtrlSetBkColor(-1,0x445566)
    $Armour_Total = GUICtrlCreateLabel("0",80,415,40,15)
    GUICtrlSetFont(-1, 8, $bold, 0, $default_font)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    
    ;GROUP - COMBAT
    GUICtrlCreateGroup("Combat - 5 Points", 208, 80, 209, 115)
    GUICtrlSetFont(-1, 10, $bold, 0, $default_font)
    $gb_label = GUICtrlCreateLabel("Glancing Blow", 232, 104, 87, 20)
    GUICtrlSetFont(-1, 10, $normal, 0, $default_font)
    $acr_label = GUICtrlCreateLabel("Action Cost Reduction", 232, 128, 134, 20)
    GUICtrlSetFont(-1, 10, $normal, 0, $default_font)
    $crit_label = GUICtrlCreateLabel("Critical Chance", 232, 152, 92, 20)
    GUICtrlSetFont(-1, 10, $normal, 0, $default_font)
    $gb_check = GUICtrlCreateCheckbox("", 376, 104, 17, 17)
    $acr_check = GUICtrlCreateCheckbox("", 376, 128, 17, 17)
    $crit_check = GUICtrlCreateCheckbox("", 376, 152, 17, 17)
    GUICtrlCreateLabel("TOTAL:",230,175,45,15)
    GUICtrlSetFont(-1, 8, $bold, 0, $default_font)
    ;GUICtrlSetBkColor(-1,0x445566)
    $Combat_Total = GUICtrlCreateLabel("0",280,175,40,15)
    GUICtrlSetFont(-1, 8, $bold, 0, $default_font)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    
    ;GROUP - MISC
    GUICtrlCreateGroup("Misc - 2 Points", 208, 210, 209, 227)
    GUICtrlSetFont(-1, 10, $bold, 0, $default_font)
    
    For $X = 0 to Ubound($aGroup3)-1
        GUICtrlCreateLabel($aGroup3[$X][0], 230, 230+($X*32), 120, 25)
        ;GUICtrlSetBkColor(-1,0x445566)
        $aGroup3[$X][1] = GUICtrlCreateCombo(0, 360, 230+($X*32), 40, 25)
        PopulateDropdown(-1)
        GUICtrlSetFont(-1, 10, $normal, 0, $default_font)
    Next
    GUICtrlCreateLabel("TOTAL:",230,415,45,15)
    GUICtrlSetFont(-1, 8, $bold, 0, $default_font)
    ;GUICtrlSetBkColor(-1,0x445566)
    $Misc_Total = GUICtrlCreateLabel("0",280,415,40,15)
    GUICtrlSetFont(-1, 8, $bold, 0, $default_font)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    
    ;GROUP - TRADER
    GUICtrlCreateGroup("Trader - 2 Points", 440, 80, 345, 235)
    GUICtrlSetFont(-1, 10, $bold, 0, $default_font)
    
    For $X = 0 to Ubound($aGroup4a)-1
        GUICtrlCreateLabel($aGroup4a[$X][0], 460, 104+($X*32), 100, 25)
        ;GUICtrlSetBkColor(-1,0x445566)
        $aGroup4a[$X][1] = GUICtrlCreateCombo(0, 560, 104+($X*32), 40, 25)
        PopulateDropdown(-1)
        GUICtrlSetFont(-1, 10, $normal, 0, $default_font)
    Next
    
    For $X = 0 to Ubound($aGroup4b)-1
        GUICtrlCreateLabel($aGroup4b[$X][0], 620, 104+($X*32), 120, 25)
        ;GUICtrlSetBkColor(-1,0x445566)
        $aGroup4b[$X][1] = GUICtrlCreateCombo(0, 740, 104+($X*32), 40, 25)
        PopulateDropdown(-1)
        GUICtrlSetFont(-1, 10, $normal, 0, $default_font)
    Next
    
    GUICtrlCreateLabel("TOTAL:",460,295,45,15)
    GUICtrlSetFont(-1, 8, $bold, 0, $default_font)
    ;GUICtrlSetBkColor(-1,0x445566)
    $Trader_Total = GUICtrlCreateLabel("0",510,295,40,15)
    GUICtrlSetFont(-1, 8, $bold, 0, $default_font)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $update_button
                CalculateTotals()
            Case $exit_button
                Exit
        EndSwitch
    WEnd
EndFunc

Func PopulateDropdown($hControl)
    For $Y = 1 to 5
        _GUICtrlComboBox_AddString($hControl, $Y)
    Next
EndFunc

Func CalculateTotals()
    $Total = 0
    For $X = 0 to Ubound($aGroup1)-1
        $Total += GUICtrlRead($aGroup1[$X][1])
    Next
    GUICtrlSetData($Attribute_Total,$Total)

    $Total = 0
    For $X = 0 to Ubound($aGroup2)-1
        $Total += GUICtrlRead($aGroup2[$X][1])
    Next
    GUICtrlSetData($Armour_Total,$Total)
    
    $Total = 0
    If IsChecked($gb_check) Then $Total += 1
    If IsChecked($acr_check) Then $Total += 1
    If IsChecked($crit_check) Then $Total += 1
    GUICtrlSetData($Combat_Total,$Total)

    $Total = 0
    For $X = 0 to Ubound($aGroup3)-1
        $Total += GUICtrlRead($aGroup3[$X][1])
    Next
    GUICtrlSetData($Misc_Total,$Total)
    
    $Total = 0
    For $X = 0 to Ubound($aGroup4a)-1
        $Total += GUICtrlRead($aGroup4a[$X][1])
    Next
    For $X = 0 to Ubound($aGroup4b)-1
        $Total += GUICtrlRead($aGroup4b[$X][1])
    Next
    GUICtrlSetData($Trader_Total,$Total)
EndFunc

Func IsChecked($hControl)
    Return BitAND(GUICtrlRead($hControl), $GUI_CHECKED) = $GUI_CHECKED
EndFunc

Share this post


Link to post
Share on other sites
Matt

That seems just what I was looking for matey, but could I be a pain in the arse, and ask how its done please? I am really eager to learn this stuff myself :P

Cheers

Matt

This ended up being a lot more complex than I thought it would. Good luck.

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.0.0
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

#include <GUIComboBox.au3>
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Opt("MustDeclareVars", 0)

Const $default_font = "Arial"
Const $bold = 600, $normal = 400
Global $aGroup1[6][2] = [["Agility",""],["Constitution",""],["Luck",""],["Strength",""],["Stamina",""],["Precision",""]]
Global $aGroup2[2][2] = [["Kinetic Armour",""],["Energy Armour",""]]
Global $aGroup3[6][2] = [["Healer",""],["Flush With Success",""],["Harvest Fair",""],["Resilience",""],["Go With The Flow",""],["Second Chance",""]]
Global $aGroup4a[6][2] = [["Architecture",""],["Booster Assy",""],["Chassis Assy",""],["Culinary",""],["Droid Tech",""],["Engine Assy",""]]
Global $aGroup4b[6][2] = [["Fashion",""],["Munitions",""],["Security",""],["Shield Assy",""],["Power Systems",""],["Weapon Systems",""]]
Global $Attribute_Total,$Armour_Total,$Combat_Total,$Misc_Total,$Trader_Total
Global $gb_check,$acr_check,$crit_check

buffgui()

Func buffGUI()

    Local $exit_button, $msg

    #Region ### START Koda GUI section ### Form=c:\documents and settings\matt\desktop\form_test1.kxf
    $Form1 = GUICreate("Buffage V1.0", 814, 470)
    GUISetIcon("C:\Program Files\StarWarsGalaxies\favicon.ico")
    GUISetFont(10, $normal, 0, $default_font)
    
    $update_button = GUICtrlCreateButton("Update Totals", 600, 380, 200, 25, 0)
    GUICtrlSetFont(-1, 10, $bold, 0, $default_font)
    
    $send_button = GUICtrlCreateButton("Send", 600, 416, 97, 25, 0)
    GUICtrlSetFont(-1, 10, $bold, 0, $default_font)
    GUICtrlSetTip(-1, "Click to request your buff")    
    
    $exit_button = GUICtrlCreateButton("Exit", 704, 416, 97, 25, 0)
    GUICtrlSetFont(-1, 10, $bold, 0, $default_font)
    GUICtrlSetTip(-1, "Click to exit")
    
    $txt1_label = GUICtrlCreateLabel("Choose the buff you wish to recieve by using the drop down menu's and check boxes. ", 8, 40, 551, 20)
    GUICtrlSetFont(-1, 10, $normal, 0, $default_font)
    $txt2_label = GUICtrlCreateLabel("When you have chosen your buff, click the send button to request your entertainer buff.", 8, 56, 556, 20)
    GUICtrlSetFont(-1, 10, $normal, 0, $default_font)
    $title_label = GUICtrlCreateLabel("Buffage V1.0", 8, 8, 121, 26)
    GUICtrlSetFont(-1, 14, $bold, 0, $default_font)
    
    ;GROUP - Attributes
    GUICtrlCreateGroup("Attributes - 1 Point", 8, 80, 177, 235)
    GUICtrlSetFont(-1, 10, $bold, 0, $default_font)
    
    For $X = 0 to Ubound($aGroup1)-1
        GUICtrlCreateLabel($aGroup1[$X][0], 30, 104+($X*32), 90, 25)
        ;GUICtrlSetBkColor(-1,0x445566)
        $aGroup1[$X][1] = GUICtrlCreateCombo(0, 120, 104+($X*32), 40, 25)
        PopulateDropdown(-1)
        GUICtrlSetFont(-1, 10, $normal, 0, $default_font)
    Next
    GUICtrlCreateLabel("TOTAL:",30,295,45,15)
    GUICtrlSetFont(-1, 8, $bold, 0, $default_font)
    ;GUICtrlSetBkColor(-1,0x445566)
    $Attribute_Total = GUICtrlCreateLabel("0",80,295,40,15)
    GUICtrlSetFont(-1, 8, $bold, 0, $default_font)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    
    ;GROUP - ARMOUR
    GUICtrlCreateGroup("Armour - 1 Point", 8, 330, 177, 107)
    GUICtrlSetFont(-1, 10, $bold, 0, $default_font)
    For $X = 0 to Ubound($aGroup2)-1
        GUICtrlCreateLabel($aGroup2[$X][0], 30, 350+($X*32), 90, 25)
        ;GUICtrlSetBkColor(-1,0x445566)
        $aGroup2[$X][1] = GUICtrlCreateCombo(0, 130, 350+($X*32), 40, 25)
        PopulateDropdown(-1)
        GUICtrlSetFont(-1, 10, $normal, 0, $default_font)
    Next
    GUICtrlCreateLabel("TOTAL:",30,415,45,15)
    GUICtrlSetFont(-1, 8, $bold, 0, $default_font)
    ;GUICtrlSetBkColor(-1,0x445566)
    $Armour_Total = GUICtrlCreateLabel("0",80,415,40,15)
    GUICtrlSetFont(-1, 8, $bold, 0, $default_font)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    
    ;GROUP - COMBAT
    GUICtrlCreateGroup("Combat - 5 Points", 208, 80, 209, 115)
    GUICtrlSetFont(-1, 10, $bold, 0, $default_font)
    $gb_label = GUICtrlCreateLabel("Glancing Blow", 232, 104, 87, 20)
    GUICtrlSetFont(-1, 10, $normal, 0, $default_font)
    $acr_label = GUICtrlCreateLabel("Action Cost Reduction", 232, 128, 134, 20)
    GUICtrlSetFont(-1, 10, $normal, 0, $default_font)
    $crit_label = GUICtrlCreateLabel("Critical Chance", 232, 152, 92, 20)
    GUICtrlSetFont(-1, 10, $normal, 0, $default_font)
    $gb_check = GUICtrlCreateCheckbox("", 376, 104, 17, 17)
    $acr_check = GUICtrlCreateCheckbox("", 376, 128, 17, 17)
    $crit_check = GUICtrlCreateCheckbox("", 376, 152, 17, 17)
    GUICtrlCreateLabel("TOTAL:",230,175,45,15)
    GUICtrlSetFont(-1, 8, $bold, 0, $default_font)
    ;GUICtrlSetBkColor(-1,0x445566)
    $Combat_Total = GUICtrlCreateLabel("0",280,175,40,15)
    GUICtrlSetFont(-1, 8, $bold, 0, $default_font)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    
    ;GROUP - MISC
    GUICtrlCreateGroup("Misc - 2 Points", 208, 210, 209, 227)
    GUICtrlSetFont(-1, 10, $bold, 0, $default_font)
    
    For $X = 0 to Ubound($aGroup3)-1
        GUICtrlCreateLabel($aGroup3[$X][0], 230, 230+($X*32), 120, 25)
        ;GUICtrlSetBkColor(-1,0x445566)
        $aGroup3[$X][1] = GUICtrlCreateCombo(0, 360, 230+($X*32), 40, 25)
        PopulateDropdown(-1)
        GUICtrlSetFont(-1, 10, $normal, 0, $default_font)
    Next
    GUICtrlCreateLabel("TOTAL:",230,415,45,15)
    GUICtrlSetFont(-1, 8, $bold, 0, $default_font)
    ;GUICtrlSetBkColor(-1,0x445566)
    $Misc_Total = GUICtrlCreateLabel("0",280,415,40,15)
    GUICtrlSetFont(-1, 8, $bold, 0, $default_font)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    
    ;GROUP - TRADER
    GUICtrlCreateGroup("Trader - 2 Points", 440, 80, 345, 235)
    GUICtrlSetFont(-1, 10, $bold, 0, $default_font)
    
    For $X = 0 to Ubound($aGroup4a)-1
        GUICtrlCreateLabel($aGroup4a[$X][0], 460, 104+($X*32), 100, 25)
        ;GUICtrlSetBkColor(-1,0x445566)
        $aGroup4a[$X][1] = GUICtrlCreateCombo(0, 560, 104+($X*32), 40, 25)
        PopulateDropdown(-1)
        GUICtrlSetFont(-1, 10, $normal, 0, $default_font)
    Next
    
    For $X = 0 to Ubound($aGroup4b)-1
        GUICtrlCreateLabel($aGroup4b[$X][0], 620, 104+($X*32), 120, 25)
        ;GUICtrlSetBkColor(-1,0x445566)
        $aGroup4b[$X][1] = GUICtrlCreateCombo(0, 740, 104+($X*32), 40, 25)
        PopulateDropdown(-1)
        GUICtrlSetFont(-1, 10, $normal, 0, $default_font)
    Next
    
    GUICtrlCreateLabel("TOTAL:",460,295,45,15)
    GUICtrlSetFont(-1, 8, $bold, 0, $default_font)
    ;GUICtrlSetBkColor(-1,0x445566)
    $Trader_Total = GUICtrlCreateLabel("0",510,295,40,15)
    GUICtrlSetFont(-1, 8, $bold, 0, $default_font)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $update_button
                CalculateTotals()
            Case $exit_button
                Exit
        EndSwitch
    WEnd
EndFunc

Func PopulateDropdown($hControl)
    For $Y = 1 to 5
        _GUICtrlComboBox_AddString($hControl, $Y)
    Next
EndFunc

Func CalculateTotals()
    $Total = 0
    For $X = 0 to Ubound($aGroup1)-1
        $Total += GUICtrlRead($aGroup1[$X][1])
    Next
    GUICtrlSetData($Attribute_Total,$Total)

    $Total = 0
    For $X = 0 to Ubound($aGroup2)-1
        $Total += GUICtrlRead($aGroup2[$X][1])
    Next
    GUICtrlSetData($Armour_Total,$Total)
    
    $Total = 0
    If IsChecked($gb_check) Then $Total += 1
    If IsChecked($acr_check) Then $Total += 1
    If IsChecked($crit_check) Then $Total += 1
    GUICtrlSetData($Combat_Total,$Total)

    $Total = 0
    For $X = 0 to Ubound($aGroup3)-1
        $Total += GUICtrlRead($aGroup3[$X][1])
    Next
    GUICtrlSetData($Misc_Total,$Total)
    
    $Total = 0
    For $X = 0 to Ubound($aGroup4a)-1
        $Total += GUICtrlRead($aGroup4a[$X][1])
    Next
    For $X = 0 to Ubound($aGroup4b)-1
        $Total += GUICtrlRead($aGroup4b[$X][1])
    Next
    GUICtrlSetData($Trader_Total,$Total)
EndFunc

Func IsChecked($hControl)
    Return BitAND(GUICtrlRead($hControl), $GUI_CHECKED) = $GUI_CHECKED
EndFunc

Share this post


Link to post
Share on other sites
weaponx

Well the method I have shown is meant to emulate a web form. In html when you create a form with combo boxes there is both a key and value for each option. One is for display and one is the actual value.

Here is what you had:

Agility

Agility x1

Agility x2

Agility x3

Agility x4

Agility x5

Now later on you would have had to do something tricky to determine the multiplier, a big ugly case statement.

What I did was separate the labels from the values and have them generated into an array. This way when they values need to be checked later on we can just loop through the array which contains all of the handles to the combo boxes.

NOTE: Looking through the help file I see that with GuiComboBoxEx you can apply both a display value and actual value to a combo box element. That may make things simpler by allowing you to use your original design.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.