Jump to content

Two small problems in my small team generator


NoHAX
 Share

Recommended Posts

HI all :)

I want create something like "team generator". Look into the code

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUICloseOnESC", 1)
Opt("GUIonEventMode", 1)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Team Generator", 625, 445, 428, 139)
$Input1 = GUICtrlCreateInput("", 24, 32, 121, 21)
$Input2 = GUICtrlCreateInput("", 24, 64, 121, 21)
$Input3 = GUICtrlCreateInput("", 24, 96, 121, 21)
$Input4 = GUICtrlCreateInput("", 24, 128, 121, 21)
$Input5 = GUICtrlCreateInput("", 160, 32, 121, 21)
$Input6 = GUICtrlCreateInput("", 160, 64, 121, 21)
$Input7 = GUICtrlCreateInput("", 160, 96, 121, 21)
$Input8 = GUICtrlCreateInput("", 160, 128, 121, 21)
$Input9 = GUICtrlCreateInput("", 304, 32, 121, 21)
$Input10 = GUICtrlCreateInput("", 304, 64, 121, 21)
$Input11 = GUICtrlCreateInput("", 304, 96, 121, 21)
$Input12 = GUICtrlCreateInput("", 304, 128, 121, 21)
$Input13 = GUICtrlCreateInput("", 440, 32, 121, 21)
$Input14 = GUICtrlCreateInput("", 440, 64, 121, 21)
$Input15 = GUICtrlCreateInput("", 440, 96, 121, 21)
$Input16 = GUICtrlCreateInput("", 440, 128, 121, 21)
$Button1 = GUICtrlCreateButton("Generate", 32, 416, 553, 25, $WS_GROUP)
$Button2 = GUICtrlCreateButton("Set", 448, 184, 121, 25, $WS_GROUP)
$Combo1 = GUICtrlCreateCombo("How many teams?", 448, 160, 121, 25)
GUICtrlSetData(-1, "4|5|6|7|8|9|10|11|12|13|14|15|16")
GUICtrlSetOnEvent($Button1, "_generate")
GUICtrlSetOnEvent($Button2, "_set")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Func _set()
$Combo_value = GUICtrlRead($Combo1)
if $Combo_value = 4 Then
GUICtrlDelete($Input5)
GUICtrlDelete($Input6)
GUICtrlDelete($Input7)
GUICtrlDelete($Input8)
GUICtrlDelete($Input9)
GUICtrlDelete($Input10)
GUICtrlDelete($Input11)
GUICtrlDelete($Input12)
GUICtrlDelete($Input13)
GUICtrlDelete($Input14)
GUICtrlDelete($Input15)
GUICtrlDelete($Input16)
EndIf
if $Combo_value = 5 Then
GUICtrlDelete($Input6)
GUICtrlDelete($Input7)
GUICtrlDelete($Input8)
GUICtrlDelete($Input9)
GUICtrlDelete($Input10)
GUICtrlDelete($Input11)
GUICtrlDelete($Input12)
GUICtrlDelete($Input13)
GUICtrlDelete($Input14)
GUICtrlDelete($Input15)
GUICtrlDelete($Input16)
EndIf
if $Combo_value = 6 Then
GUICtrlDelete($Input7)
GUICtrlDelete($Input8)
GUICtrlDelete($Input9)
GUICtrlDelete($Input10)
GUICtrlDelete($Input11)
GUICtrlDelete($Input12)
GUICtrlDelete($Input13)
GUICtrlDelete($Input14)
GUICtrlDelete($Input15)
GUICtrlDelete($Input16)
EndIf
if $Combo_value = 7 Then
GUICtrlDelete($Input8)
GUICtrlDelete($Input9)
GUICtrlDelete($Input10)
GUICtrlDelete($Input11)
GUICtrlDelete($Input12)
GUICtrlDelete($Input13)
GUICtrlDelete($Input14)
GUICtrlDelete($Input15)
GUICtrlDelete($Input16)
EndIf
if $Combo_value = 8 Then
GUICtrlDelete($Input9)
GUICtrlDelete($Input10)
GUICtrlDelete($Input11)
GUICtrlDelete($Input12)
GUICtrlDelete($Input13)
GUICtrlDelete($Input14)
GUICtrlDelete($Input15)
GUICtrlDelete($Input16)
EndIf
if $Combo_value = 9 Then
GUICtrlDelete($Input10)
GUICtrlDelete($Input11)
GUICtrlDelete($Input12)
GUICtrlDelete($Input13)
GUICtrlDelete($Input14)
GUICtrlDelete($Input15)
GUICtrlDelete($Input16)
EndIf
if $Combo_value = 10 Then
GUICtrlDelete($Input11)
GUICtrlDelete($Input12)
GUICtrlDelete($Input13)
GUICtrlDelete($Input14)
GUICtrlDelete($Input15)
GUICtrlDelete($Input16)
EndIf
if $Combo_value = 11 Then
GUICtrlDelete($Input12)
GUICtrlDelete($Input13)
GUICtrlDelete($Input14)
GUICtrlDelete($Input15)
GUICtrlDelete($Input16)
EndIf
if $Combo_value = 12 Then
GUICtrlDelete($Input13)
GUICtrlDelete($Input14)
GUICtrlDelete($Input15)
GUICtrlDelete($Input16)
EndIf
if $Combo_value = 13 Then
GUICtrlDelete($Input14)
GUICtrlDelete($Input15)
GUICtrlDelete($Input16)
EndIf
if $Combo_value = 14 Then
GUICtrlDelete($Input15)
GUICtrlDelete($Input16)
EndIf
if $Combo_value = 15 Then
GUICtrlDelete($Input16)
EndIf
if $Combo_value = 16 Then
MsgBox(0, "Teams", "No changes :)")
EndIf
EndFunc

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Func _generate()
$Combo_value = GUICtrlRead($Combo1)
Dim $Team[16]
$Team[0] = GUICtrlRead($Input1)
$Team[1] = GUICtrlRead($Input2)
$Team[2] = GUICtrlRead($Input3)
$Team[3] = GUICtrlRead($Input4)
$Team[4] = GUICtrlRead($Input5)
$Team[5] = GUICtrlRead($Input6)
$Team[6] = GUICtrlRead($Input7)
$Team[7] = GUICtrlRead($Input8)
$Team[8] = GUICtrlRead($Input9)
$Team[9] = GUICtrlRead($Input10)
$Team[10] = GUICtrlRead($Input11)
$Team[11] = GUICtrlRead($Input12)
$Team[12] = GUICtrlRead($Input13)
$Team[13] = GUICtrlRead($Input14)
$Team[14] = GUICtrlRead($Input15)
$Team[15] = GUICtrlRead($Input16)

MsgBox(0,"Groups", "Group A" & @CRLF & $Team[Random(0,$Combo_Value,1)] & @CRLF & $Team[Random(0,$Combo_Value,1)] & @CRLF)
EndFunc

This work fine, but i have 2 small problems on msg box :idea:

On example i set 4 teams in combo box:

TeamA

TeamB

TeamC

TeamD

First problem:

______________________

Groups [x]|

----------------------|

Group A |

TeamB |

TeamB |

|

[ OK ] |

----------------------|

there is a two teams with this same caption

and Second problem

______________________

Groups [x]|

----------------------|

Group A |

TeamA |

0 |

|

[ OK ] |

----------------------|

Omg i cant draw msgbox on keyboard :P my mobile net is too slow now to sending pictures :lol:

I think the problem with "0" is from combobox value (this value start from 0, not from 1)

Need help :mad:

I think the "Func _set()" is funny for some peoples but i rlly dont have any idea today for it :D

Thx for all who try help me :)

Edited by NoHAX
Link to comment
Share on other sites

First problem:

______________________

Groups [x]|

----------------------|

Group A |

TeamB |

TeamB |

|

[ OK ] |

----------------------|

there is a two teams with this same caption

and Second problem

______________________

Groups [x]|

----------------------|

Group A |

TeamA |

0 |

|

[ OK ] |

----------------------|

Hi,

1st, You have to insert a condition that the team only can show up once.

2nd, You have to automate the array, a kind like this :

Func _generate()
$Combo_value = GUICtrlRead($Combo1)
Dim $Team[$Combo_value + 1]
_ArrayDisplay($Team, "test")
for $x = 1 to $Combo_value
$target = "$Input" & $x
$Team[$x] = GUICtrlRead($target)
ConsoleWrite( "Input : " & $target & " | Value is : " & $Team[$x] & @CRLF)
next
_ArrayDisplay($Team, "test")
MsgBox(0,"Groups", "Group A" & @CRLF & $Team[Random(0,$Combo_Value,1)] & @CRLF & $Team[Random(0,$Combo_Value,1)] & @CRLF)
EndFunc

But i dont know why, if is me or bug, you cannot read $target, because value is alway 0, that means that GUIctrlread is failing!

Maybe im doing something wrong!

Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Link to comment
Share on other sites

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <SliderConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Local $t[17]
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 625, 224, 430, 486)
$Group1 = GUICtrlCreateGroup("Teams", 8, 8, 601, 137)
$coordy = 32
$coordx = 16
For $i = 1 To 16 Step 1
    $t[$i] = GUICtrlCreateInput("", $coordx, $coordy, 137, 21)
    $coordy += 24
    If $i = 4 Then
        $coordx = 160
        $coordy = 32
    ElseIf $i = 8 Then
        $coordx = 304
        $coordy = 32
    ElseIf $i = 12 Then
        $coordx = 448
        $coordy = 32
    EndIf
Next

For $i = 5 to 16 Step 1
    GUICtrlSetState($t[$i], $GUI_DISABLE)
Next
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Set count", 8, 152, 449, 49)
$Slider1 = GUICtrlCreateSlider(16, 168, 433, 25)
GUICtrlSetLimit(-1, 12, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("Total", 464, 152, 65, 49)
$Total = GUICtrlCreateInput("4", 472, 168, 49, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY))
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Generate = GUICtrlCreateButton("Generate", 536, 160, 73, 41, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
GUIRegisterMsg($WM_HSCROLL  , "WM_HSCROLL"  )

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

Case $Generate
    MsgBox(0, "", "Do it yourself:)")
EndSwitch
WEnd


Func WM_HSCROLL($hWnd, $iMsg, $iwParam, $ilParam)
GUICtrlSetData($Total, GUICtrlRead($Slider1)+4)
For $i = 4 to 16 Step 1
    If $i > GUICtrlRead($Slider1)+4 And GUICtrlGetState($t[$i]) = 80 Then
        GUICtrlSetState($t[$i], $GUI_DISABLE)
    ElseIf $i <= GUICtrlRead($Slider1)+4 And GUICtrlGetState($t[$i]) = 144 Then
        GUICtrlSetState($t[$i], $GUI_ENABLE)
    EndIf
Next
EndFunc

_____________________________________________________________________________

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