chrisgreece Posted June 26, 2019 Share Posted June 26, 2019 For some years now i have been browsing the forums as a novice, finding useful advises for almost everything and because of that i created code that made my work in office A LOT EASIER and faster! I have to thank for that all the active members who help us with their knowledge and make us better in coding! The reason i write is because i am having troubles with trying to get some information from an input , stringsplit it with a character "-" and then pass the info the a guictrlmessage in my function. More specifically #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GUIDateTimePicker.au3> #include <string.au3> #include <Array.au3> #include <MsgBoxConstants.au3> $Form1 = GUICreate("Form", 800, 500, 210, 124) $input= GUICtrlCreateInput("Input",100,100,200,200) $button= GUICtrlCreateButton("Button" ,299,299,50,50,$WS_Group) $input = StringSplit($input, "-") Case $button For $i = 0 to ($input) -1 "I have tried also to Ubound with no luck. Basically i have tried many things i just cant get a grasp of it" ShellExecute("notepad.exe") Local $hWnd = WinWait("[CLASS:Notepad]", "", 3) ControlSetText($hWnd, "", "", $input[$i]) send (Guictrlread($aArray)) WinClose($hWnd) Send ("{right}{enter}") next What i basically want is to loop the whole procedure as many times as there is something in the input If the input has aaa-bbb-ccc i want it to make 3 loops, run notepad write this aaa then close then again bbb- and finally the ccc and then go on on what i have put afterwards ( this is just an example so i can grasp the idea how this thing works so i can implement it somewhere more complex) Link to comment Share on other sites More sharing options...
Subz Posted June 26, 2019 Share Posted June 26, 2019 Try For $i = 1 To $input[0] Or For $i = 1 To Ubound($Input) - 1 chrisgreece 1 Link to comment Share on other sites More sharing options...
chrisgreece Posted June 26, 2019 Author Share Posted June 26, 2019 6 minutes ago, Subz said: Try For $i = 1 To $input[0] Or For $i = 1 To Ubound($Input) - 1 #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GUIDateTimePicker.au3> #include <string.au3> #include <Array.au3> #include <MsgBoxConstants.au3> $Form1 = GUICreate("Form", 800, 500, 210, 124) $input= GUICtrlCreateInput("Input",100,100,200,200) $button= GUICtrlCreateButton("Button" ,299,299,50,50,$WS_Group) $input = StringSplit($input, "-") GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE EXit Case $button For $i = 1 To $input[0] ShellExecute("notepad.exe") Local $hWnd = WinWait("[CLASS:Notepad]", "", 3) ControlSetText($hWnd, "", "", $input[$i]) send (Guictrlread($input[i])) WinClose($hWnd) Send ("{right}{enter}") it returns error "C:\Users\Chris Meli\Desktop\install\test arrays.au3" (31) : ==> Unknown function name.: send (Guictrlread($input[i])) send (Guictrlread($input[^ ERROR Link to comment Share on other sites More sharing options...
Subz Posted June 26, 2019 Share Posted June 26, 2019 Just re-read your code it should be something like: #include <Array.au3> #include <GUIConstantsEx.au3> Example() Func Example() Local $aInput GUICreate("Example", 320, 120) Local $idInput = GUICtrlCreateInput("aa-bbb-cccc-dddd", 10, 5, 300, 20) Local $idBtn = GUICtrlCreateButton("Ok", 40, 75, 60, 20) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idBtn $aInput = StringSplit(GUICtrlRead($idInput), "-") _ArrayDisplay($aInput) For $i = 1 To $aInput[0] MsgBox(4096, "Using $aInput[0]", $aInput[$i]) Next For $i = 1 To UBound($aInput) - 1 MsgBox(4096, "Using Ubound", $aInput[$i]) Next EndSwitch WEnd EndFunc chrisgreece 1 Link to comment Share on other sites More sharing options...
chrisgreece Posted June 26, 2019 Author Share Posted June 26, 2019 and if i remove $i from there it opens notepad and writes "03" i guess its a way of telling me that i am doing something wrong! Link to comment Share on other sites More sharing options...
chrisgreece Posted June 26, 2019 Author Share Posted June 26, 2019 7 minutes ago, Subz said: Just re-read your code it should be something like: #include <Array.au3> #include <GUIConstantsEx.au3> Example() Func Example() Local $aInput GUICreate("Example", 320, 120) Local $idInput = GUICtrlCreateInput("aa-bbb-cccc-dddd", 10, 5, 300, 20) Local $idBtn = GUICtrlCreateButton("Ok", 40, 75, 60, 20) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idBtn $aInput = StringSplit(GUICtrlRead($idInput), "-") _ArrayDisplay($aInput) For $i = 1 To $aInput[0] MsgBox(4096, "Using $aInput[0]", $aInput[$i]) Next For $i = 1 To UBound($aInput) - 1 MsgBox(4096, "Using Ubound", $aInput[$i]) Next EndSwitch WEnd EndFunc Thank you so much for helping me out! Truly i am really grateful, you just saved me like five hours a week for sure or even more & helped me finally understand that i should had put GuiCtrlread in Stringsplit! THANKS MAN! Link to comment Share on other sites More sharing options...
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