Jump to content

shuffle number from 1 to 5


Recommended Posts

I have a script that has 5 inputs

these inputs are filled with number from 1 to 5

so:

input1 = 1

input2 = 2

input3 = 3 

input4 = 4

input3 = 5 

but I want it to shuffle the numbers like:

input1 = 4

input2 = 1

input3 = 5

input4 = 2

input5= 3

I dont want to use the Random function because then there is a possibilty It will chose number with the same value, I need a number from 1 to 5 to be shown but in different order

Link to comment
Share on other sites

You need to include the Array UDF. Use

#include <Array.au3>

BTW: Which version of AutoIt do you run?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Your best bet is always to use a current release (or beta if you want) of the complete official AutoIt distribution. You find it like all of us mere mortals, in the dedicated download section.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

You need to check the help file! Set the cursor on _ArrayShuffle and press F1.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

As you can see you run an old version of Autoit (3.3.10.2). Upgrade to the latest production version (3.3.12.0) and the problem goes away.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I guess you downloaded and installed the latest beta. But to run a script with a beta version you need to press Alt+F5 ind SciTE. Just pressing F5  executes the script using the installed production version.

Means: You can have a production and a beta version installed in parallel.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

sorry for asking but I just cant figure out how to get the number from a  array to an input, this is what i tried

Local $aArray_Base[16] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15]


Local $aArray = $aArray_Base
_ArrayShuffle($aArray)
_ArrayDisplay($aArray, "1D - Shuffled", Default, 16)

$aArray = 1

$readfrom = _FileReadToArray(, $aArray, 1)

GUICtrlSetData($input1,$readfrom)
Edited by Arclite86
Link to comment
Share on other sites

  • Moderators

Arclite86,

Just loop through the array like this: :)

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

Local $aArray_Base[16] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15]
Local $aArray = $aArray_Base
_ArrayShuffle($aArray)

$hGUI = GUICreate("Test", 500, 500)

$cInput = GUICtrlCreateInput("", 10, 10, 200, 40)
GUICtrlSetFont($cInput, 24)

GUISetState()

For $i = 0 To 15
    GUICtrlSetData($cInput, $aArray[$i])
    Sleep(500)
Next

Exit
M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

i dont understand this one:

it misses one number:

#Region ### START Koda GUI section ### Form=
$Form1_1 = GUICreate("Form1", 477, 291, 293, 182)

$Input1 = GUICtrlCreateInput("Input1", 0, 64, 41, 21)
$Input2 = GUICtrlCreateInput("Input2", 0, 88, 41, 21)
$Input3 = GUICtrlCreateInput("Input3", 0, 112, 41, 21)
$Input4 = GUICtrlCreateInput("Input4", 0, 136, 41, 21)
$Input5 = GUICtrlCreateInput("Input5", 0, 160, 41, 21)
$Input6 = GUICtrlCreateInput("Input6", 0, 184, 41, 21)

   

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







GUISetState()

For $i = 1 To 1
    GUICtrlSetData($Input1, $aArray[$i])
sleep(500)
Next

For $i = 2 To 2
    GUICtrlSetData($Input2, $aArray[$i])
sleep(500)
Next

For $i = 3 To 3
    GUICtrlSetData($Input3, $aArray[$i])
sleep(500)
 Next

 For $i = 4 To 4
    GUICtrlSetData($Input4, $aArray[$i])
sleep(500)
 Next

  For $i = 5 To 5
    GUICtrlSetData($Input5, $aArray[$i])
sleep(500)
 Next

  For $i = 6 To 6
    GUICtrlSetData($Input6, $aArray[$i])
    sleep(500)
 Next

   For $i = 7 To 7
    GUICtrlSetData($Input6, $aArray[$i])
    sleep(500)
 Next
Edited by Arclite86
Link to comment
Share on other sites

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