Jump to content
Arclite86

shuffle number from 1 to 5

Recommended Posts

 

Much easier if you store your input ids into an array

#Include <Array.au3>

Local $inputs[6]

$Form1_1 = GUICreate("Form1", 477, 291, 293, 182)
$Inputs[0] = GUICtrlCreateInput("Input1", 0, 64, 41, 21)
$Inputs[1] = GUICtrlCreateInput("Input2", 0, 88, 41, 21)
$Inputs[2] = GUICtrlCreateInput("Input3", 0, 112, 41, 21)
$Inputs[3] = GUICtrlCreateInput("Input4", 0, 136, 41, 21)
$Inputs[4] = GUICtrlCreateInput("Input5", 0, 160, 41, 21)
$Inputs[5] = GUICtrlCreateInput("Input6", 0, 184, 41, 21)

Local $aArray[6] = [ 1, 2, 3, 4, 5, 6]
_ArrayShuffle($aArray)

For $i = 0 To 5
    GUICtrlSetData($Inputs[$i], $aArray[$i])
Next
GUISetState()

While 1
  Sleep(10)
Wend

it seems that it doesnt read the

because if i try this:

$Input[1] = GUICtrlCreateInput("-", 0, 64, 41, 21)
$Input[2] = GUICtrlCreateInput("-", 0, 88, 41, 21)
$Input[3] = GUICtrlCreateInput("-", 0, 112, 41, 21)
$Input[4] = GUICtrlCreateInput("-", 0, 136, 41, 21)
$Input[5] = GUICtrlCreateInput("-", 0, 160, 41, 21)
$Input[6] = GUICtrlCreateInput("-", 0, 184, 41, 21)

func shuffle()

   Local $inputs[6]


$Inputs[0] = GUICtrlCreateInput("Input1", 0, 64, 41, 21)
$Inputs[1] = GUICtrlCreateInput("Input2", 0, 88, 41, 21)
$Inputs[2] = GUICtrlCreateInput("Input3", 0, 112, 41, 21)
$Inputs[3] = GUICtrlCreateInput("Input4", 0, 136, 41, 21)
$Inputs[4] = GUICtrlCreateInput("Input5", 0, 160, 41, 21)
$Inputs[5] = GUICtrlCreateInput("Input6", 0, 184, 41, 21)

Local $aArray[6] = [ 1, 2, 3, 4, 5, 6]
_ArrayShuffle($aArray)

For $i = 0 To 5
    GUICtrlSetData($Inputs[$i], $aArray[$i])
Next
GUISetState()

   EndFunc




Call("shuffle")
sleep(1000)
$munershuffle = GUICtrlRead(input1)
MsgBox($MB_SYSTEMMODAL,"hoi", "number " & $munershuffle)


$input1read = GUICtrlRead($input1)

Select



Case $input1read = 1
  Call("input1")

  GUICtrlSetData($input16,$hokje0)

   Case $input1read = 2
    Call("input2")
  GUICtrlSetData($input16,$hokje1)

   Case $input1read = 3
      Call("input3")
  GUICtrlSetData($input16,$hokje2)

   Case $input1read = 4
  Call("input4")
  GUICtrlSetData($input16,$hokje3)

   Case $input1read = 5
  Call("input5")
  GUICtrlSetData($input16,$hokje4)

   Case $input1read = 6
    Call("input6")
  GUICtrlSetData($input16,$hokje5)


EndSelect

and the select function doesnt seem to recognize it

Share this post


Link to post
Share on other sites

it seems that it doesnt read the

because if i try this:

$Input[1] = GUICtrlCreateInput("-", 0, 64, 41, 21)
$Input[2] = GUICtrlCreateInput("-", 0, 88, 41, 21)
$Input[3] = GUICtrlCreateInput("-", 0, 112, 41, 21)
$Input[4] = GUICtrlCreateInput("-", 0, 136, 41, 21)
$Input[5] = GUICtrlCreateInput("-", 0, 160, 41, 21)
$Input[6] = GUICtrlCreateInput("-", 0, 184, 41, 21)

func shuffle()

   Local $inputs[6]


$Inputs[0] = GUICtrlCreateInput("Input1", 0, 64, 41, 21)
$Inputs[1] = GUICtrlCreateInput("Input2", 0, 88, 41, 21)
$Inputs[2] = GUICtrlCreateInput("Input3", 0, 112, 41, 21)
$Inputs[3] = GUICtrlCreateInput("Input4", 0, 136, 41, 21)
$Inputs[4] = GUICtrlCreateInput("Input5", 0, 160, 41, 21)
$Inputs[5] = GUICtrlCreateInput("Input6", 0, 184, 41, 21)

Local $aArray[6] = [ 1, 2, 3, 4, 5, 6]
_ArrayShuffle($aArray)

For $i = 0 To 5
    GUICtrlSetData($Inputs[$i], $aArray[$i])
Next
GUISetState()

   EndFunc




Call("shuffle")
sleep(1000)
$munershuffle = GUICtrlRead(input1)
MsgBox($MB_SYSTEMMODAL,"hoi", "number " & $munershuffle)


$input1read = GUICtrlRead($input1)

Select



Case $input1read = 1
  Call("input1")

  GUICtrlSetData($input16,$hokje0)

   Case $input1read = 2
    Call("input2")
  GUICtrlSetData($input16,$hokje1)

   Case $input1read = 3
      Call("input3")
  GUICtrlSetData($input16,$hokje2)

   Case $input1read = 4
  Call("input4")
  GUICtrlSetData($input16,$hokje3)

   Case $input1read = 5
  Call("input5")
  GUICtrlSetData($input16,$hokje4)

   Case $input1read = 6
    Call("input6")
  GUICtrlSetData($input16,$hokje5)


EndSelect

and the select function doesnt seem to recognize it

the msgbox gives a number 0 when5 ( for example) is displaying

Share this post


Link to post
Share on other sites

Arclite86,

You are not reading the inputs correctly.  Try this...

#include <GUIConstantsEx.au3>
#Include <Array.au3>

Local $inputs[6]

$Form1_1 = GUICreate("Form1", 477, 291, 293, 182)
$Inputs[0] = GUICtrlCreateInput("Input1", 0, 064, 41, 21)
$Inputs[1] = GUICtrlCreateInput("Input2", 0, 088, 41, 21)
$Inputs[2] = GUICtrlCreateInput("Input3", 0, 112, 41, 21)
$Inputs[3] = GUICtrlCreateInput("Input4", 0, 136, 41, 21)
$Inputs[4] = GUICtrlCreateInput("Input5", 0, 160, 41, 21)
$Inputs[5] = GUICtrlCreateInput("Input6", 0, 184, 41, 21)

Local $aArray[6] = [ 1, 2, 3, 4, 5, 6]
_ArrayShuffle($aArray)

For $i = 0 To 5
    GUICtrlSetData($Inputs[$i], $aArray[$i])
Next

GUISetState()

local $msg

While 1

    $msg = guigetmsg()

    switch $msg
        case $GUI_EVENT_CLOSE
            exit
        case $inputs[0] to $inputs[ubound($inputs) - 1]
            ; if any input control is actioned list them all
            for $1 = 0 to ubound($Inputs) - 1
                ConsoleWrite('Input' & $1+1 & ' = ' & guictrlread($Inputs[$1]) & @CRLF)
            next
    endswitch

Wend

kylomas

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

Arclite86,

Another example displaying only the control actioned...

#include <GUIConstantsEx.au3>
#Include <Array.au3>

Local $inputs[6]

$Form1_1 = GUICreate("Form1", 477, 291, 293, 182)
$dummy_place_holder = guictrlcreatedummy()  ;   dummy control used to reference the relative order of the following controls
$Inputs[0] = GUICtrlCreateInput("Input1", 0, 064, 41, 21)
$Inputs[1] = GUICtrlCreateInput("Input2", 0, 088, 41, 21)
$Inputs[2] = GUICtrlCreateInput("Input3", 0, 112, 41, 21)
$Inputs[3] = GUICtrlCreateInput("Input4", 0, 136, 41, 21)
$Inputs[4] = GUICtrlCreateInput("Input5", 0, 160, 41, 21)
$Inputs[5] = GUICtrlCreateInput("Input6", 0, 184, 41, 21)

Local $aArray[6] = [ 1, 2, 3, 4, 5, 6]
_ArrayShuffle($aArray)

For $i = 0 To 5
    GUICtrlSetData($Inputs[$i], $aArray[$i])
Next

GUISetState()

local $msg

While 1

    $msg = guigetmsg()

    switch $msg
        case $GUI_EVENT_CLOSE
            exit
        case $Inputs[0] to $Inputs[ubound($Inputs) - 1]
            ConsoleWrite('Input #' & $msg - $dummy_place_holder & ' actioned.  Value = ' & guictrlread($msg) & @CRLF)
    endswitch

Wend

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

and finally, the hammer and tongs method...

#include <GUIConstantsEx.au3>
#Include <Array.au3>

Local $inputs[6]

$Form1_1 = GUICreate("Form1", 477, 291, 293, 182)
$Inputs[0] = GUICtrlCreateInput("Input1", 0, 064, 41, 21)
$Inputs[1] = GUICtrlCreateInput("Input2", 0, 088, 41, 21)
$Inputs[2] = GUICtrlCreateInput("Input3", 0, 112, 41, 21)
$Inputs[3] = GUICtrlCreateInput("Input4", 0, 136, 41, 21)
$Inputs[4] = GUICtrlCreateInput("Input5", 0, 160, 41, 21)
$Inputs[5] = GUICtrlCreateInput("Input6", 0, 184, 41, 21)

Local $aArray[6] = [ 1, 2, 3, 4, 5, 6]
_ArrayShuffle($aArray)

For $i = 0 To 5
    GUICtrlSetData($Inputs[$i], $aArray[$i])
Next

GUISetState()

local $msg

While 1

    $msg = guigetmsg()

    switch $msg
        case $GUI_EVENT_CLOSE
            exit
        case $Inputs[0]
            ConsoleWrite('Input #1 actioned.  Value = ' & guictrlread($msg) & @CRLF)
        case $Inputs[1]
            ConsoleWrite('Input #2 actioned.  Value = ' & guictrlread($msg) & @CRLF)
        case $Inputs[2]
            ConsoleWrite('Input #3 actioned.  Value = ' & guictrlread($msg) & @CRLF)
        case $Inputs[3]
            ConsoleWrite('Input #4 actioned.  Value = ' & guictrlread($msg) & @CRLF)
        case $Inputs[4]
            ConsoleWrite('Input #5 actioned.  Value = ' & guictrlread($msg) & @CRLF)
        case $Inputs[5]
            ConsoleWrite('Input #6 actioned.  Value = ' & guictrlread($msg) & @CRLF)
    endswitch

Wend

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

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

×
×
  • Create New...