Annonyreeder Posted May 25, 2016 Posted May 25, 2016 (edited) *Edit* - Replaced with my first reply, Original post was a bit confusing. Hopefully this makes more sense. Thanks in advance. Hello,I've this is what i've got so far, It doesn't do what I want to do but i'm hoping it explains what I want to do.When running the script, press F1 and this will assign the GUI input values 1'2'3'4 or you can change the order 2'3'1'4 ect.When pressing F2 it will run each function in the order they are equal to depending on the User Input placed earlier. I put some notes in the Startfunction() which should also help explain.I know that the StartFunctions() is wrong and the functions have not been assigned to those array elements, this is what i'm not sure how to do.. I've never worked with array before and would really appreciate the help, I think that should make sense but if you need me to explain a bit more please ask.Thanks again in advance. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Misc.au3> #include <GDIplus.au3> #Include <Memory.au3> #include <ImageSearch.au3> #include "_Log.au3" #include "FastFind.au3" #include <MsgBoxConstants.au3> Opt("GUIOnEventMode", 1) HotKeySet("{ESC}", "on_exit") HotKeySet("{F1}", "LoadModuel") HotKeySet("{F2}", "StartFunctions") MainGUI() ;This is the GUI, Contains 4 Inputs func MainGUI() $GUI = GUICreate("Main GUI", 320, 500, 1500, 0,$WS_POPUPWINDOW, $WS_EX_TOPMOST) GUISetOnEvent($GUI_EVENT_CLOSE, "on_exit") global $ModuleOrder = GUICtrlCreateLabel("Module order :", 0,265,100,12) global $UpgradeOrder = GUICtrlCreateInput("1",0,280,100,20) global $PictureOrder = GUICtrlCreateInput("2",0,300,100,20) global $ClickingOrder = GUICtrlCreateInput("3",0,320,100,20) global $MercOrder = GUICtrlCreateInput("4",0,340,100,20) $Button = GUICtrlCreateButton("Run Functions", 0, 200, 200, 20) GUICtrlSetOnEvent(-1, "StartFunctions") GUISetState() while 1 sleep(50) WEnd EndFunc func start() global $stopper = 1 ;Begin Starting Phase ConsoleWrite("Starting Bot in 5 " & @LF & " ") sleep(1000) ConsoleWrite("5 " & @LF & " ") sleep(1000) ConsoleWrite("4 " & @LF & " ") sleep(1000) ConsoleWrite("3 " & @LF & " ") sleep(1000) ConsoleWrite("2 " & @LF & " ") sleep(1000) ConsoleWrite("1 " & @LF & " ") sleep(1000) ;StartingConsole /End while $stopper < 2 If $ModuleDictionary.Exists("1") Then EndIf ;LoadModuel ;Bot General layout ;$ClickingStance() ;$UpgradeStance() ;$PictureStance() ;$MercStance() WEnd EndFunc func LoadModuel() ;assigning the values global $Module $UO = GUICtrlRead($UpgradeOrder) $PO = GUICtrlRead($PictureOrder) $CO = GUICtrlRead($ClickingOrder) $MO = GUICtrlRead($MercOrder) Dim $avArray[4] $avArray[0] = $UO $avArray[1] = $PO $avArray[2] = $CO $avArray[3] = $MO msgbox(0,'demo',$avArray[0]) EndFunc func StartFunctions() ;This function will run the following functions in the order defined in $avArray UpgradeStance() = $avArray[0] PictureStance() = $avArray[1] ClickStance() = $avArray[2] MercStance() = $avArray[3] _ArraySearch($avArray, '1', 0, 0, 0, 1, 1) ;Find array with value '1' and run function assigned above _ArraySearch($avArray, '2', 0, 0, 0, 1, 1) ;Find array with value '2' and run function assigned above _ArraySearch($avArray, '3', 0, 0, 0, 1, 1) ;Find array with value '3' and run function assigned above _ArraySearch($avArray, '4', 0, 0, 0, 1, 1) ;Find array with value '4' and run function assigned above EndFunc func UpgradeStance() while $order = $ModuleDictionary.Item("1") ConsoleWrite("Running UpgradeStance" & @LF & " ") WEnd EndFunc func PictureStance() while $order = $ModuleDictionary.Item("2") ConsoleWrite("Running PictureStance" & @LF & " ") WEnd EndFunc func ClickingStance() while $order = $ModuleDictionary.Item("3") ConsoleWrite("Running ClickingStance" & @LF & " ") wend EndFunc func MercStance() while $order = $ModuleDictionary.Item("4") ConsoleWrite("Running MercStance" & @LF & " ") wend EndFunc func on_exit() Exit EndFunc Edited May 25, 2016 by Annonyreeder
Annonyreeder Posted May 25, 2016 Author Posted May 25, 2016 (edited) See orig Edited May 25, 2016 by Annonyreeder
MichaelHB Posted May 25, 2016 Posted May 25, 2016 (edited) Hello Annonyreeder, Something like this maybe? You can store the name function in the array in the order that you want and then call them. #include <Array.au3> Local $aArray[5] = ["_1", "_2", "_3", "_4", "_5"] _ArrayDisplay($aArray) _ArrayShuffle($aArray) _ArrayDisplay($aArray) For $i = 0 To UBound($aArray)-1 Call($aArray[$i]) Next Func _1() MsgBox(0, "", "1") EndFunc Func _2() MsgBox(0, "", "2") EndFunc Func _3() MsgBox(0, "", "3") EndFunc Func _4() MsgBox(0, "", "4") EndFunc Func _5() MsgBox(0, "", "5") EndFunc Exit Edited May 25, 2016 by MichaelHB spell
Annonyreeder Posted May 25, 2016 Author Posted May 25, 2016 (edited) Hello, That wasn't exactly what I wanted but it has helped me lots thank you. I have managed to do what I wanted. Pressing F1 will load the User inputs into array and then run the functions in the order put into GUI. I've done an array-search for each position then called it. Is there a better way to do this? If not this will do just fine but feels like I've done it badly/amateurish expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Misc.au3> #include <GDIplus.au3> #Include <Memory.au3> #include <ImageSearch.au3> #include "_Log.au3" #include "FastFind.au3" #include <MsgBoxConstants.au3> Opt("GUIOnEventMode", 1) HotKeySet("{ESC}", "on_exit") HotKeySet("{F1}", "LoadModuel") HotKeySet("{F2}", "StartFunctions") MainGUI() ;This is the GUI, Contains 4 Inputs func MainGUI() $GUI = GUICreate("Main GUI", 320, 500, 1500, 0,$WS_POPUPWINDOW, $WS_EX_TOPMOST) GUISetOnEvent($GUI_EVENT_CLOSE, "on_exit") global $ModuleOrder = GUICtrlCreateLabel("Module order :", 0,265,100,12) global $UpgradeOrder = GUICtrlCreateInput("1",0,280,100,20) global $PictureOrder = GUICtrlCreateInput("2",0,300,100,20) global $ClickingOrder = GUICtrlCreateInput("3",0,320,100,20) global $MercOrder = GUICtrlCreateInput("4",0,340,100,20) $Button = GUICtrlCreateButton("Run Functions", 0, 200, 200, 20) GUICtrlSetOnEvent(-1, "StartFunctions") GUISetState() while 1 sleep(50) WEnd EndFunc func start() global $stopper = 1 ;Begin Starting Phase ConsoleWrite("Starting Bot in 5 " & @LF & " ") sleep(1000) ConsoleWrite("5 " & @LF & " ") sleep(1000) ConsoleWrite("4 " & @LF & " ") sleep(1000) ConsoleWrite("3 " & @LF & " ") sleep(1000) ConsoleWrite("2 " & @LF & " ") sleep(1000) ConsoleWrite("1 " & @LF & " ") sleep(1000) ;StartingConsole /End while $stopper < 2 If $ModuleDictionary.Exists("1") Then EndIf ;LoadModuel ;Bot General layout ;$ClickingStance() ;$UpgradeStance() ;$PictureStance() ;$MercStance() WEnd EndFunc func LoadModuel() ;assigning the values global $Module $UO = GUICtrlRead($UpgradeOrder) $PO = GUICtrlRead($PictureOrder) $CO = GUICtrlRead($ClickingOrder) $MO = GUICtrlRead($MercOrder) Dim $avArray[4][4] $avArray[0][0] = $UO $avArray[1][0] = $PO $avArray[2][0] = $CO $avArray[3][0] = $MO $avArray[0][2] = "UpgradeStance" $avArray[1][2] = "PictureStance" $avArray[2][2] = "ClickingStance" $avArray[3][2] = "MercStance" $iPosition = _ArraySearch($avArray, '1') Call($avArray[$iPosition][2]) $iPosition = _ArraySearch($avArray, '2') Call($avArray[$iPosition][2]) $iPosition = _ArraySearch($avArray, '3') Call($avArray[$iPosition][2]) $iPosition = _ArraySearch($avArray, '4') Call($avArray[$iPosition][2]) EndFunc func StartFunctions() ;This function will run the following functions in the order defined in $avArray _ArraySearch($avArray, '1', 0, 0, 0, 1, 1) ;Find array with value '1' and run function assigned above _ArraySearch($avArray, '2', 0, 0, 0, 1, 1) ;Find array with value '2' and run function assigned above _ArraySearch($avArray, '3', 0, 0, 0, 1, 1) ;Find array with value '3' and run function assigned above _ArraySearch($avArray, '4', 0, 0, 0, 1, 1) ;Find array with value '4' and run function assigned above EndFunc func UpgradeStance() ConsoleWrite("1" & @LF & " ") EndFunc func PictureStance() ConsoleWrite("2" & @LF & " ") EndFunc func ClickingStance() ConsoleWrite("3" & @LF & " ") EndFunc func MercStance() ConsoleWrite("4" & @LF & " ") EndFunc func on_exit() Exit EndFunc Edited May 25, 2016 by Annonyreeder
MichaelHB Posted May 25, 2016 Posted May 25, 2016 Its running in the order of the For/Next (0 to UBound of the array - 1). Offcourse it will always run in the same order. You already have everything you need, you just need to organize the logic. In the column 0 you have the order you want to call the function and in the column 2 you have the respective function right?! So why you are not using the "order column"? There is some options: _ArraySearch (search for the number/order you want to and find the index and then use in the "$avArray") _ArrayFindAll (same ideia as ArraySearch) _ArraySort (I would use this one, just see in the help file and try the examples) You can also use another For loop to check for the number. Like this: For $i = 0 To UBound($avArray)-1 For $j = 0 To UBound($avArray)-1 If ((Number($avArray[$j][0])-1) = $i) Then Call($avArray[$j][2]) Next Next
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now