Schleifen in Switch/Case?

  • Hallo,
    ist es möglich, Schleifen in Switch/Case zu verwenden, so in dieser Art?

    [autoit]

    While 1
    Switch GUIGetMsg()
    For $i=0 to 20 step 1
    Case $conrol[$i]
    _funktion($i)
    next
    EndSwitch
    WEnd

    [/autoit]

    Gruß Gremlin

  • Hallo Oscar,
    die Schleife geht eigentlich bis 48 und soll über nen Counter (in der Funktion) abgefragt werden ob sechs Zahlen gewählt wurden.
    Und so wird ein Lottozahlen-Generator draus.

    Gruß Gremlin

  • Ist noch im Umbau...

    Spoiler anzeigen
    [autoit]

    #NoTrayIcon
    #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_Outfile=LottoChance.exe
    #AutoIt3Wrapper_Res_Description=v1.2.04
    #AutoIt3Wrapper_Res_Comment=Lottochancen-GENERATOR: 6 aus 49
    #AutoIt3Wrapper_Res_Field=Companyname|dk78soft
    #AutoIt3Wrapper_Res_LegalCopyright=dk78soft
    #AutoIt3Wrapper_Res_ProductVersion=1.2.0.4
    #AutoIt3Wrapper_Res_FileVersion=1.2.0.4
    #AutoIt3Wrapper_Res_Language=7
    #AutoIt3Wrapper_UseUpx
    #AutoIt3Wrapper_Au3Check_Parameters=-d -w 2 -w 4 -w 6
    #AutoIt3Wrapper_Icon=lotto.ico
    ;#AutoIt3Wrapper_Res_Icon_Add=cancel.ico
    ;#AutoIt3Wrapper_Res_Icon_Add=ok.ico
    ;#AutoIt3Wrapper_Res_Icon_Add=write.ico
    #endregion

    [/autoit] [autoit][/autoit] [autoit]

    #include <ComboConstants.au3>
    #include <Array.au3>
    #include <GUIConstantsEx.au3>
    #include <GuiButton.au3>
    #include <WindowsConstants.au3>
    #include <GuiStatusBar.au3>
    #include <Date.au3>
    #include <File.au3>
    HotKeySet('{F9}', '_break')

    [/autoit] [autoit][/autoit] [autoit]

    Global $aLottoNum[49], $timer, $bBreak = False,$iCount = 0
    For $i = 1 To 49
    $aLottoNum[$i - 1] = $i
    Next
    Global $progname='LottoChance', $mycompany = 'dkSoftware', $version = '1.02.04'
    Global $breite=410, $hoehe=280
    Global $Form1 = GUICreate($progname, $breite, $hoehe,-1,-1,$WS_Border+$WS_POPUP+$WS_CLIPSIBLINGS)
    Global $ribboncontext =GUICtrlCreateMenu("o(°U°)o ")
    Global $idrandom=GUICtrlCreateMenuItem("Zufallsgenerator", $ribboncontext)
    Global $idclean=GUICtrlCreateMenuItem("Tip löschen", $ribboncontext)
    Global $idsim=GUICtrlCreateMenuItem("Simulation starten", $ribboncontext)
    GUICtrlSetState(-1,$GUI_DISABLE)
    GUICtrlCreateMenuItem("", $ribboncontext)
    Global $ribbonexit = GUICtrlCreateMenuItem("Beenden", $ribboncontext)

    [/autoit] [autoit][/autoit] [autoit]

    Global $ahCheck[49]
    For $i = 0 To 48
    $ahCheck[$i] = GUICtrlCreateCheckbox($i + 1, 5 + Mod($i, 7) * 30, 5 + Int($i / 7) * 30, 30, 30,$BS_PUSHLIKE)
    GUICtrlSetFont(-1, 12, 400,0,"IMPACT")
    GUICtrlSetTip(-1, "Wählen Sie ihre 6 Zahlen")
    Next

    [/autoit] [autoit][/autoit] [autoit]

    Global $label1 = GUICtrlCreateLabel(' 6 Zahlen auswählen!',5,235,400,16,1)
    Global $label3 = GUICtrlCreateLabel('0',250,15,60,16,2)
    GUICtrlSetFont(-1, 10, 800,'','Tahoma')
    GUICtrlCreateLabel('x 3 Richtige',312,17,70,15)
    Global $label4 = GUICtrlCreateLabel('0',250,35,60,16,2)
    GUICtrlSetFont(-1, 10, 800,'','Tahoma')
    GUICtrlCreateLabel('x 4 Richtige',312,37,70,15)
    Global $label5 = GUICtrlCreateLabel('0',250,55,60,16,2)
    GUICtrlSetFont(-1, 10, 800,'','Tahoma')
    GUICtrlCreateLabel('x 5 Richtige',312,57,70,15)
    Global $label6 = GUICtrlCreateLabel('0',250,78,60,18,2)
    GUICtrlSetFont(-1, 12, 800,'','Tahoma')
    GUICtrlCreateLabel('x 6 Richtige',312,82,70,15)
    Global $hStatusb = _GUICtrlStatusBar_Create($Form1, -1, "", $SBARS_TOOLTIPS)
    Global $aParts[2] = [$breite-200,$breite]
    Global $prozess = GUICtrlCreateProgress(15,220,380,8)
    GUICtrlSetState(-1,$GUI_HIDE)
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    _GUICtrlStatusBar_SetMinHeight($hStatusb, 25)
    _GUICtrlStatusBar_SetParts($hStatusb, $aParts)
    Global $hIcon = __WinAPI_ShellExtractIcons(@ScriptFullPath, 0, 16, 16)
    _GUICtrlStatusBar_SetIcon($hStatusb, 0, $hIcon)

    [/autoit] [autoit][/autoit] [autoit]

    _GUICtrlStatusBar_SetText($hStatusb,' '&$progname&' '&$version,0)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    Switch GUIGetMsg()
    Case $ribbonexit
    Exit
    #cs
    Case $ahCheck[0]
    _CheckboxCounter()
    Case $ahCheck[1]
    _CheckboxCounter()
    Case $ahCheck[2]
    _CheckboxCounter()
    Case $ahCheck[3]
    _CheckboxCounter()
    Case $ahCheck[4]
    _CheckboxCounter()
    Case $ahCheck[5]
    _CheckboxCounter()
    Case $ahCheck[6]
    _CheckboxCounter()
    Case $ahCheck[7]
    _CheckboxCounter()
    Case $ahCheck[8]
    _CheckboxCounter()
    Case $ahCheck[9]
    _CheckboxCounter()
    Case $ahCheck[10]
    _CheckboxCounter()
    Case $ahCheck[11]
    _CheckboxCounter()
    Case $ahCheck[12]
    _CheckboxCounter()
    Case $ahCheck[13]
    _CheckboxCounter()
    Case $ahCheck[14]
    _CheckboxCounter()
    Case $ahCheck[15]
    _CheckboxCounter()
    Case $ahCheck[16]
    _CheckboxCounter()
    Case $ahCheck[17]
    _CheckboxCounter()
    Case $ahCheck[18]
    _CheckboxCounter()
    Case $ahCheck[19]
    _CheckboxCounter()
    Case $ahCheck[20]
    _CheckboxCounter()
    Case $ahCheck[21]
    _CheckboxCounter()
    Case $ahCheck[22]
    _CheckboxCounter()
    Case $ahCheck[23]
    _CheckboxCounter()
    Case $ahCheck[24]
    _CheckboxCounter()
    Case $ahCheck[25]
    _CheckboxCounter()
    Case $ahCheck[26]
    _CheckboxCounter()
    Case $ahCheck[27]
    _CheckboxCounter()
    Case $ahCheck[28]
    _CheckboxCounter()
    Case $ahCheck[29]
    _CheckboxCounter()
    Case $ahCheck[30]
    _CheckboxCounter()
    Case $ahCheck[31]
    _CheckboxCounter()
    Case $ahCheck[32]
    _CheckboxCounter()
    Case $ahCheck[33]
    _CheckboxCounter()
    Case $ahCheck[34]
    _CheckboxCounter()
    Case $ahCheck[35]
    _CheckboxCounter()
    Case $ahCheck[36]
    _CheckboxCounter()
    Case $ahCheck[37]
    _CheckboxCounter()
    Case $ahCheck[38]
    _CheckboxCounter()
    Case $ahCheck[39]
    _CheckboxCounter()
    Case $ahCheck[40]
    _CheckboxCounter()
    Case $ahCheck[41]
    _CheckboxCounter()
    Case $ahCheck[42]
    _CheckboxCounter()
    Case $ahCheck[43]
    _CheckboxCounter()
    Case $ahCheck[44]
    _CheckboxCounter()
    Case $ahCheck[45]
    _CheckboxCounter()
    Case $ahCheck[46]
    _CheckboxCounter()
    Case $ahCheck[47]
    _CheckboxCounter()
    Case $ahCheck[48]
    _CheckboxCounter()

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 0 to 48 step 1
    Case $ahCheck[$i]
    _CheckboxCounter()
    Next
    #ce
    Case $idrandom
    _Randoming()
    Case $idclean
    _Clear()
    Case $idsim
    _Start()

    [/autoit] [autoit][/autoit] [autoit]

    EndSwitch

    [/autoit] [autoit][/autoit] [autoit]

    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _Randoming()

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 0 To 48
    GUICtrlSetState($ahCheck[$i],$GUI_DISABLE)
    GUICtrlSetState($ahCheck[$i],$GUI_UNCHECKED)
    Next
    Local $result,$zahl
    For $i = 1 to 6
    Do
    $zahl = Random(1,49,1)
    GUICtrlSetState($ahCheck[$zahl-1],$GUI_CHECKED)
    Until StringInStr($result,$zahl) = 0
    $result &= StringRight($zahl,stringlen($zahl)-1)

    [/autoit] [autoit][/autoit] [autoit]

    Next
    GUICtrlSetState($idsim, $GUI_ENABLE)
    _CheckboxCounter()
    if $iCount <> 6 Then _Randoming()
    AdlibUnRegister()

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _Break()
    $bBreak = True
    GUICtrlSetState($idsim, $GUI_DISABLE)
    GUICtrlSetState($idrandom,$GUI_ENABLE)
    GUICtrlSetState($idclean,$GUI_ENABLE)
    GUICtrlSetState($prozess,$GUI_HIDE)
    GUICtrlSetData($label1,' Start-Button anklicken!')
    EndFunc ;==>_Break

    [/autoit] [autoit][/autoit] [autoit]

    Func _Clear()
    For $i = 0 To 48
    GUICtrlSetState($ahCheck[$i],$GUI_ENABLE)
    GUICtrlSetState($ahCheck[$i],$GUI_UNCHECKED)
    Next
    GUICtrlSetState($idsim, $GUI_DISABLE)
    GUICtrlSetData($label1,' 6 Zahlen auswählen!')
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _Start()
    _CheckboxCounter()
    if $iCount <> 6 Then _Randoming()
    GUICtrlSetState($idrandom,$GUI_DISABLE)
    GUICtrlSetState($idclean,$GUI_DISABLE)
    GUICtrlSetState($idsim, $GUI_DISABLE)
    GUICtrlSetData($label3,0)
    GUICtrlSetData($label4,0)
    GUICtrlSetData($label5,0)
    GUICtrlSetData($label6,0)
    GUICtrlSetState($prozess,$GUI_SHOW)
    GUICtrlSetData($prozess,0)
    Local $aTip[6], $aDraw, $iWin = StringLeft(6, 1),$i3,$i4,$i5,$i6
    $iCount = 0
    For $i = 0 To 48
    If BitAND(GUICtrlRead($ahCheck[$i]), $GUI_CHECKED) Then
    $aTip[$iCount] = $i + 1
    $iCount += 1
    EndIf
    Next
    $iCount = 0
    GUICtrlSetData($label1,' Bitte warten...')

    [/autoit] [autoit][/autoit] [autoit]

    $timer = TimerInit()
    AdlibRegister('_DisplayTimer', 500)
    Do

    [/autoit] [autoit][/autoit] [autoit]

    $iCount += 1
    $aDraw = _Lottodraw()
    Switch _Win($aTip, $aDraw)

    [/autoit] [autoit][/autoit] [autoit]

    Case 3
    $i3 += 1
    GUICtrlSetData($label3,$i3)
    If $i3 = 5 then GUICtrlSetData($prozess,1)
    If $i3 = 10 then GUICtrlSetData($prozess,2)
    If $i3 = 25 then GUICtrlSetData($prozess,3)
    If $i3 = 50 then GUICtrlSetData($prozess,4)
    If $i3 = 100 then GUICtrlSetData($prozess,5)
    If $i3 = 1000 then GUICtrlSetData($prozess,10)
    If $i3 = 2000 then GUICtrlSetData($prozess,15)
    If $i3 = 3000 then GUICtrlSetData($prozess,20)
    If $i3 = 5000 then GUICtrlSetData($prozess,30)
    If $i3 = 7500 then GUICtrlSetData($prozess,40)
    If $i3 = 10000 then GUICtrlSetData($prozess,50)
    If $i3 = 15000 then GUICtrlSetData($prozess,60)
    If $i3 = 20000 then GUICtrlSetData($prozess,70)
    If $i3 = 30000 then GUICtrlSetData($prozess,80)
    If $i3 = 50000 then GUICtrlSetData($prozess,90)
    If $i3 = 75000 then GUICtrlSetData($prozess,95)
    Case 4
    $i4 += 1
    GUICtrlSetData($label4,$i4)
    Case 5
    $i5 += 1
    GUICtrlSetData($label5,$i5)
    Case 6
    $i6 += 1
    GUICtrlSetData($prozess,100)
    $bBreak = True
    GUICtrlSetData($label6,$i6)
    GUICtrlSetData($label1,' Gewonnen!')
    MsgBox(0, 'Lottogewinn', 'Hurra, ' & $iWin & ' Richtige!' & @CRLF & 'Anzahl der Ziehungen: ' _
    & _NumberFormatThousand($iCount) & @CRLF & 'Benötigte Zeit: ' & _NumberFormatThousand(Round(TimerDiff($timer) / 1000)) & ' sek.')
    GUICtrlSetState($prozess,$GUI_HIDE)
    EndSwitch

    [/autoit] [autoit][/autoit] [autoit]

    Until $bBreak
    $bBreak = False
    GUICtrlSetState($idclean, $GUI_ENABLE)
    GUICtrlSetState($idsim, $GUI_ENABLE)
    GUICtrlSetState($idrandom, $GUI_ENABLE)
    AdlibUnRegister()
    EndFunc ;==>_Start

    [/autoit] [autoit][/autoit] [autoit]

    Func _DisplayTimer()
    GUICtrlSetData($label1,' Bitte warten... '& _NumberFormatThousand($iCount)&' Ziehungen')
    EndFunc ;==>_DisplayTimer

    [/autoit] [autoit][/autoit] [autoit]

    Func _Lottodraw()
    Local $aTmp = $aLottoNum, $aDraw[6], $iTmp
    For $i = 0 To 5
    Local $iRandom = Random(0, 48 - $i, 1)
    $aDraw[$i] = $aTmp[$iRandom]
    $aTmp[$iRandom] = $aTmp[48 - $i]
    Next
    _ArraySort($aDraw)
    Return $aDraw
    EndFunc ;==>_Lottodraw

    [/autoit] [autoit][/autoit] [autoit]

    Func _Win($aTip, $aDraw)
    Local $iCount = 0
    For $i = 0 To 5
    If $aTip[$i] = $aDraw[$i] Then $iCount += 1
    Next
    Return $iCount
    EndFunc ;==>_Win

    [/autoit] [autoit][/autoit] [autoit]

    Func _CheckboxCounter()
    Global $iCount = 0
    For $i = 0 To 48
    $iCount += BitAND(GUICtrlRead($ahCheck[$i]), $GUI_CHECKED)
    Next
    GUICtrlSetData($label1,' '&6-$iCount & ' Zahlen auswählen!')
    If $iCount = 6 Then
    _CheckboxState($GUI_DISABLE)
    GUICtrlSetState($idsim, $GUI_ENABLE)
    GUICtrlSetData($label1,' Start-Button anklicken!')
    Else
    _CheckboxState($GUI_ENABLE)
    GUICtrlSetState($idsim, $GUI_DISABLE)
    EndIf
    EndFunc ;==>_CheckboxCounter

    [/autoit] [autoit][/autoit] [autoit]

    Func _CheckboxState($State)
    For $i = 0 To 48
    If BitAND(GUICtrlRead($ahCheck[$i]), $GUI_UNCHECKED) Then GUICtrlSetState($ahCheck[$i], $State)
    Next
    EndFunc ;==>_CheckboxState

    [/autoit] [autoit][/autoit] [autoit]

    Func _NumberFormatThousand($vNumber, $ret='DE') ; bis 18 Vorkommastellen
    Local $sOut = '', $a = StringRegExp(StringReplace($vNumber, '.', ','), "(-?\d{1,3})(\d{3})?(\d{3})?(\d{3})?(\d{3})?(\d{3})?(?:\Z|(,\d+))", 3)
    For $i = 0 To UBound($a) -1
    If $a[$i] <> '' Then $sOut &= '.' & $a[$i]
    Next
    If $ret <> 'DE' Then Return StringTrimLeft(StringReplace(StringReplace($sOut, '.', ','), ',,', '.'), 1)
    Return StringTrimLeft(StringReplace($sOut, '.,', ','), 1)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func __WinAPI_ShellExtractIcons($sIcon, $iIndex, $iWidth, $iHeight)
    Local $Ret = DllCall('shell32.dll', 'int', 'SHExtractIconsW', 'wstr', $sIcon, 'int', $iIndex, 'int', $iWidth, 'int', $iHeight, 'ptr*', 0, 'ptr*', 0, 'int', 1, 'int', 0)
    If (@error) Or ($Ret[0] = 0) Or ($Ret[5] = Ptr(0)) Then Return SetError(1, 0, 0)
    Return $Ret[5]
    EndFunc ;==>__WinAPI_ShellExtractIcons

    [/autoit]
    • Offizieller Beitrag

    Ich habe mal nur den Check auf 6 Zahlen eingebaut:

    Spoiler anzeigen
    [autoit]


    #NoTrayIcon
    #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_Outfile=LottoChance.exe
    #AutoIt3Wrapper_Res_Description=v1.2.04
    #AutoIt3Wrapper_Res_Comment=Lottochancen-GENERATOR: 6 aus 49
    #AutoIt3Wrapper_Res_Field=Companyname|dk78soft
    #AutoIt3Wrapper_Res_LegalCopyright=dk78soft
    #AutoIt3Wrapper_Res_ProductVersion=1.2.0.4
    #AutoIt3Wrapper_Res_FileVersion=1.2.0.4
    #AutoIt3Wrapper_Res_Language=7
    #AutoIt3Wrapper_UseUpx
    #AutoIt3Wrapper_Au3Check_Parameters=-d -w 2 -w 4 -w 6
    #AutoIt3Wrapper_Icon=lotto.ico
    ;#AutoIt3Wrapper_Res_Icon_Add=cancel.ico
    ;#AutoIt3Wrapper_Res_Icon_Add=ok.ico
    ;#AutoIt3Wrapper_Res_Icon_Add=write.ico
    #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

    [/autoit] [autoit][/autoit] [autoit]

    #include <ComboConstants.au3>
    #include <Array.au3>
    #include <GUIConstantsEx.au3>
    #include <GuiButton.au3>
    #include <WindowsConstants.au3>
    #include <GuiStatusBar.au3>
    #include <Date.au3>
    #include <File.au3>
    HotKeySet('{F9}', '_break')

    [/autoit] [autoit][/autoit] [autoit]

    Global $aLottoNum[49], $timer, $bBreak = False, $iCount = 0
    For $i = 1 To 49
    $aLottoNum[$i - 1] = $i
    Next
    Global $progname = 'LottoChance', $mycompany = 'dkSoftware', $version = '1.02.04'
    Global $breite = 410, $hoehe = 280
    Global $Form1 = GUICreate($progname, $breite, $hoehe, -1, -1, $WS_Border + $WS_POPUP + $WS_CLIPSIBLINGS)
    Global $ribboncontext = GUICtrlCreateMenu("o(°U°)o ")
    Global $idrandom = GUICtrlCreateMenuItem("Zufallsgenerator", $ribboncontext)
    Global $idclean = GUICtrlCreateMenuItem("Tip löschen", $ribboncontext)
    Global $idsim = GUICtrlCreateMenuItem("Simulation starten", $ribboncontext)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUICtrlCreateMenuItem("", $ribboncontext)
    Global $ribbonexit = GUICtrlCreateMenuItem("Beenden", $ribboncontext)

    [/autoit] [autoit][/autoit] [autoit]

    Global $ahCheck[49]
    For $i = 0 To 48
    $ahCheck[$i] = GUICtrlCreateCheckbox($i + 1, 5 + Mod($i, 7) * 30, 5 + Int($i / 7) * 30, 30, 30, $BS_PUSHLIKE)
    GUICtrlSetFont(-1, 12, 400, 0, "IMPACT")
    GUICtrlSetTip(-1, "Wählen Sie ihre 6 Zahlen")
    Next

    [/autoit] [autoit][/autoit] [autoit]

    Global $label1 = GUICtrlCreateLabel(' 6 Zahlen auswählen!', 5, 235, 400, 16, 1)
    Global $label3 = GUICtrlCreateLabel('0', 250, 15, 60, 16, 2)
    GUICtrlSetFont(-1, 10, 800, '', 'Tahoma')
    GUICtrlCreateLabel('x 3 Richtige', 312, 17, 70, 15)
    Global $label4 = GUICtrlCreateLabel('0', 250, 35, 60, 16, 2)
    GUICtrlSetFont(-1, 10, 800, '', 'Tahoma')
    GUICtrlCreateLabel('x 4 Richtige', 312, 37, 70, 15)
    Global $label5 = GUICtrlCreateLabel('0', 250, 55, 60, 16, 2)
    GUICtrlSetFont(-1, 10, 800, '', 'Tahoma')
    GUICtrlCreateLabel('x 5 Richtige', 312, 57, 70, 15)
    Global $label6 = GUICtrlCreateLabel('0', 250, 78, 60, 18, 2)
    GUICtrlSetFont(-1, 12, 800, '', 'Tahoma')
    GUICtrlCreateLabel('x 6 Richtige', 312, 82, 70, 15)
    Global $hStatusb = _GUICtrlStatusBar_Create($Form1, -1, "", $SBARS_TOOLTIPS)
    Global $aParts[2] = [$breite - 200, $breite]
    Global $prozess = GUICtrlCreateProgress(15, 220, 380, 8)
    GUICtrlSetState(-1, $GUI_HIDE)
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    _GUICtrlStatusBar_SetMinHeight($hStatusb, 25)
    _GUICtrlStatusBar_SetParts($hStatusb, $aParts)
    Global $hIcon = __WinAPI_ShellExtractIcons(@ScriptFullPath, 0, 16, 16)
    _GUICtrlStatusBar_SetIcon($hStatusb, 0, $hIcon)

    [/autoit] [autoit][/autoit] [autoit]

    _GUICtrlStatusBar_SetText($hStatusb, ' ' & $progname & ' ' & $version, 0)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    Switch GUIGetMsg()
    Case $ribbonexit
    Exit
    Case $ahCheck[0] To $ahCheck[48]
    _CheckUserInput()
    Case $idrandom
    _Randoming()
    Case $idclean
    _Clear()
    Case $idsim
    _Start()

    [/autoit] [autoit][/autoit] [autoit]

    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _CheckUserInput()
    Local $iCount = 0
    For $i = 0 To UBound($ahCheck) - 1
    If BitAND(GUICtrlRead($ahCheck[$i]), $GUI_CHECKED) Then $iCount += 1
    Next
    If $iCount = 6 Then
    For $i = 0 To UBound($ahCheck) - 1
    If Not BitAND(GUICtrlRead($ahCheck[$i]), $GUI_CHECKED) Then GUICtrlSetState($ahCheck[$i], $GUI_DISABLE)
    Next
    Else
    For $i = 0 To UBound($ahCheck) - 1
    If Not BitAND(GUICtrlRead($ahCheck[$i]), $GUI_CHECKED) Then GUICtrlSetState($ahCheck[$i], $GUI_ENABLE)
    Next
    EndIf
    EndFunc ;==>_CheckUserInput

    [/autoit] [autoit][/autoit] [autoit]

    Func _Randoming()
    For $i = 0 To 48
    GUICtrlSetState($ahCheck[$i], $GUI_DISABLE)
    GUICtrlSetState($ahCheck[$i], $GUI_UNCHECKED)
    Next
    Local $result, $zahl
    For $i = 1 To 6
    Do
    $zahl = Random(1, 49, 1)
    GUICtrlSetState($ahCheck[$zahl - 1], $GUI_CHECKED)
    Until StringInStr($result, $zahl) = 0
    $result &= StringRight($zahl, StringLen($zahl) - 1)

    [/autoit] [autoit][/autoit] [autoit]

    Next
    GUICtrlSetState($idsim, $GUI_ENABLE)
    _CheckboxCounter()
    If $iCount <> 6 Then _Randoming()
    AdlibUnRegister()
    EndFunc ;==>_Randoming

    [/autoit] [autoit][/autoit] [autoit]

    Func _Break()
    $bBreak = True
    GUICtrlSetState($idsim, $GUI_DISABLE)
    GUICtrlSetState($idrandom, $GUI_ENABLE)
    GUICtrlSetState($idclean, $GUI_ENABLE)
    GUICtrlSetState($prozess, $GUI_HIDE)
    GUICtrlSetData($label1, ' Start-Button anklicken!')
    EndFunc ;==>_Break

    [/autoit] [autoit][/autoit] [autoit]

    Func _Clear()
    For $i = 0 To 48
    GUICtrlSetState($ahCheck[$i], $GUI_ENABLE)
    GUICtrlSetState($ahCheck[$i], $GUI_UNCHECKED)
    Next
    GUICtrlSetState($idsim, $GUI_DISABLE)
    GUICtrlSetData($label1, ' 6 Zahlen auswählen!')
    EndFunc ;==>_Clear

    [/autoit] [autoit][/autoit] [autoit]

    Func _Start()
    _CheckboxCounter()
    If $iCount <> 6 Then _Randoming()
    GUICtrlSetState($idrandom, $GUI_DISABLE)
    GUICtrlSetState($idclean, $GUI_DISABLE)
    GUICtrlSetState($idsim, $GUI_DISABLE)
    GUICtrlSetData($label3, 0)
    GUICtrlSetData($label4, 0)
    GUICtrlSetData($label5, 0)
    GUICtrlSetData($label6, 0)
    GUICtrlSetState($prozess, $GUI_SHOW)
    GUICtrlSetData($prozess, 0)
    Local $aTip[6], $aDraw, $iWin = StringLeft(6, 1), $i3, $i4, $i5, $i6
    $iCount = 0
    For $i = 0 To 48
    If BitAND(GUICtrlRead($ahCheck[$i]), $GUI_CHECKED) Then
    $aTip[$iCount] = $i + 1
    $iCount += 1
    EndIf
    Next
    $iCount = 0
    GUICtrlSetData($label1, ' Bitte warten...')

    [/autoit] [autoit][/autoit] [autoit]

    $timer = TimerInit()
    AdlibRegister('_DisplayTimer', 500)
    Do

    [/autoit] [autoit][/autoit] [autoit]

    $iCount += 1
    $aDraw = _Lottodraw()
    Switch _Win($aTip, $aDraw)

    [/autoit] [autoit][/autoit] [autoit]

    Case 3
    $i3 += 1
    GUICtrlSetData($label3, $i3)
    If $i3 = 5 Then GUICtrlSetData($prozess, 1)
    If $i3 = 10 Then GUICtrlSetData($prozess, 2)
    If $i3 = 25 Then GUICtrlSetData($prozess, 3)
    If $i3 = 50 Then GUICtrlSetData($prozess, 4)
    If $i3 = 100 Then GUICtrlSetData($prozess, 5)
    If $i3 = 1000 Then GUICtrlSetData($prozess, 10)
    If $i3 = 2000 Then GUICtrlSetData($prozess, 15)
    If $i3 = 3000 Then GUICtrlSetData($prozess, 20)
    If $i3 = 5000 Then GUICtrlSetData($prozess, 30)
    If $i3 = 7500 Then GUICtrlSetData($prozess, 40)
    If $i3 = 10000 Then GUICtrlSetData($prozess, 50)
    If $i3 = 15000 Then GUICtrlSetData($prozess, 60)
    If $i3 = 20000 Then GUICtrlSetData($prozess, 70)
    If $i3 = 30000 Then GUICtrlSetData($prozess, 80)
    If $i3 = 50000 Then GUICtrlSetData($prozess, 90)
    If $i3 = 75000 Then GUICtrlSetData($prozess, 95)
    Case 4
    $i4 += 1
    GUICtrlSetData($label4, $i4)
    Case 5
    $i5 += 1
    GUICtrlSetData($label5, $i5)
    Case 6
    $i6 += 1
    GUICtrlSetData($prozess, 100)
    $bBreak = True
    GUICtrlSetData($label6, $i6)
    GUICtrlSetData($label1, ' Gewonnen!')
    MsgBox(0, 'Lottogewinn', 'Hurra, ' & $iWin & ' Richtige!' & @CRLF & 'Anzahl der Ziehungen: ' _
    & _NumberFormatThousand($iCount) & @CRLF & 'Benötigte Zeit: ' & _NumberFormatThousand(Round(TimerDiff($timer) / 1000)) & ' sek.')
    GUICtrlSetState($prozess, $GUI_HIDE)
    EndSwitch

    [/autoit] [autoit][/autoit] [autoit]

    Until $bBreak
    $bBreak = False
    GUICtrlSetState($idclean, $GUI_ENABLE)
    GUICtrlSetState($idsim, $GUI_ENABLE)
    GUICtrlSetState($idrandom, $GUI_ENABLE)
    AdlibUnRegister()
    EndFunc ;==>_Start

    [/autoit] [autoit][/autoit] [autoit]

    Func _DisplayTimer()
    GUICtrlSetData($label1, ' Bitte warten... ' & _NumberFormatThousand($iCount) & ' Ziehungen')
    EndFunc ;==>_DisplayTimer

    [/autoit] [autoit][/autoit] [autoit]

    Func _Lottodraw()
    Local $aTmp = $aLottoNum, $aDraw[6], $iTmp
    For $i = 0 To 5
    Local $iRandom = Random(0, 48 - $i, 1)
    $aDraw[$i] = $aTmp[$iRandom]
    $aTmp[$iRandom] = $aTmp[48 - $i]
    Next
    _ArraySort($aDraw)
    Return $aDraw
    EndFunc ;==>_Lottodraw

    [/autoit] [autoit][/autoit] [autoit]

    Func _Win($aTip, $aDraw)
    Local $iCount = 0
    For $i = 0 To 5
    If $aTip[$i] = $aDraw[$i] Then $iCount += 1
    Next
    Return $iCount
    EndFunc ;==>_Win

    [/autoit] [autoit][/autoit] [autoit]

    Func _CheckboxCounter()
    Global $iCount = 0
    For $i = 0 To 48
    $iCount += BitAND(GUICtrlRead($ahCheck[$i]), $GUI_CHECKED)
    Next
    GUICtrlSetData($label1, ' ' & 6 - $iCount & ' Zahlen auswählen!')
    If $iCount = 6 Then
    _CheckboxState($GUI_DISABLE)
    GUICtrlSetState($idsim, $GUI_ENABLE)
    GUICtrlSetData($label1, ' Start-Button anklicken!')
    Else
    _CheckboxState($GUI_ENABLE)
    GUICtrlSetState($idsim, $GUI_DISABLE)
    EndIf
    EndFunc ;==>_CheckboxCounter

    [/autoit] [autoit][/autoit] [autoit]

    Func _CheckboxState($State)
    For $i = 0 To 48
    If BitAND(GUICtrlRead($ahCheck[$i]), $GUI_UNCHECKED) Then GUICtrlSetState($ahCheck[$i], $State)
    Next
    EndFunc ;==>_CheckboxState

    [/autoit] [autoit][/autoit] [autoit]

    Func _NumberFormatThousand($vNumber, $ret = 'DE') ; bis 18 Vorkommastellen
    Local $sOut = '', $a = StringRegExp(StringReplace($vNumber, '.', ','), "(-?\d{1,3})(\d{3})?(\d{3})?(\d{3})?(\d{3})?(\d{3})?(?:\Z|(,\d+))", 3)
    For $i = 0 To UBound($a) - 1
    If $a[$i] <> '' Then $sOut &= '.' & $a[$i]
    Next
    If $ret <> 'DE' Then Return StringTrimLeft(StringReplace(StringReplace($sOut, '.', ','), ',,', '.'), 1)
    Return StringTrimLeft(StringReplace($sOut, '.,', ','), 1)
    EndFunc ;==>_NumberFormatThousand

    [/autoit] [autoit][/autoit] [autoit]

    Func __WinAPI_ShellExtractIcons($sIcon, $iIndex, $iWidth, $iHeight)
    Local $ret = DllCall('shell32.dll', 'int', 'SHExtractIconsW', 'wstr', $sIcon, 'int', $iIndex, 'int', $iWidth, 'int', $iHeight, 'ptr*', 0, 'ptr*', 0, 'int', 1, 'int', 0)
    If (@error) Or ($ret[0] = 0) Or ($ret[5] = Ptr(0)) Then Return SetError(1, 0, 0)
    Return $ret[5]
    EndFunc ;==>__WinAPI_ShellExtractIcons

    [/autoit]
    • Offizieller Beitrag

    Hier noch eine kürzere Version der Funktion "_CheckUserInput":

    Spoiler anzeigen
    [autoit]


    Func _CheckUserInput()
    Local $iCount = 0
    For $Checkbox In $ahCheck
    If BitAND(GUICtrlRead($Checkbox), $GUI_CHECKED) Then $iCount += 1
    Next
    For $Checkbox In $ahCheck
    If Not BitAND(GUICtrlRead($Checkbox), $GUI_CHECKED) Then GUICtrlSetState($Checkbox, ($iCount = 6 ? $GUI_DISABLE : $GUI_ENABLE))
    Next
    EndFunc ;==>_CheckUserInput

    [/autoit]