pezo89 Posted December 1, 2010 Share Posted December 1, 2010 Hi, i where just wondering how i can input from a string of names.. say i have a inputbox, and adds this string for example Test1,Test2,Test3 and i have a loop that inputs each of the test names in order separated by the , so send ("test1") and then loop done, next time it sends test2 instead.. saw awile back, but cannot find the post again Link to comment Share on other sites More sharing options...
Kalin Posted December 1, 2010 Share Posted December 1, 2010 Hi, i where just wondering how i can input from a string of names..say i have a inputbox, and adds this string for example Test1,Test2,Test3and i have a loop that inputs each of the test names in order separated by the ,so send ("test1")and then loop done, next time it sends test2 instead..saw awile back, but cannot find the post again Can you be a little bit more specific?Also, please post your current code here so I can understand what you mean better. *mutters to self, Melba better not beat me to it* Link to comment Share on other sites More sharing options...
JohnOne Posted December 1, 2010 Share Posted December 1, 2010 What you want to be doing is using stringsplit(), to read your string into an array, using the comma as the delininator. You can then loop through the array and send each 'test' in whatever order you desire. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Realm Posted December 1, 2010 Share Posted December 1, 2010 Hello pezo89, I am not sure of what your asking, but guessing, I think your trying to split a string and send the items one at a time. If that is correct something like this would help you: $string = 'Test1,Test2,Test3' $sArray = StringSplit($string,',',2) ;splits string where commas are place into an array that is 0-based For $i = 0 to UBound($string)-1 Send($sArray[$i]) Next Realm My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. Link to comment Share on other sites More sharing options...
Kalin Posted December 1, 2010 Share Posted December 1, 2010 What you want to be doing is using stringsplit(), to read your string into an array, using the comma as the delininator.You can then loop through the array and send each 'test' in whatever order you desire.Or he can just set the focus to a different input each time while using a seperate Send() for each.But this works well too, just didn't really know what he meant. Link to comment Share on other sites More sharing options...
pezo89 Posted December 1, 2010 Author Share Posted December 1, 2010 how to explain... erm.. the code as it stands now Func add2() $write1 = InputBox("Please input the name(s)","Please seperate the names with ,") add2() while 1 MouseClick("left", 190,49,1,100) MouseClick("left", 179,45,1,100) MouseClick("left", 221,52,1,100) ;Search bar send ($write1) MouseClick("left", 321,51,1,100) ; Search button OK ;found Name- Adding name mouseclick ("right",954,576,1,100) MouseClick("left",1018,630,1,100) MouseClick("left", 920,490,1,100);Settings1 ;Watchlist on MouseClick("left", 844,533,1,100) ;done ;Push Add contact MouseClick("left", 915,646,1,100) EndFunc wend so lets say i type in Andreas and Tom.. this way "Andreas,Tom" then it does two things. 1 = change the while run to the number of names typed into the inputbox (for this example 2) 2 = sends Andreas to the $write1 command, and on the second run it sends Tom into the $write1 command *hope this explains it abit* Link to comment Share on other sites More sharing options...
Kalin Posted December 1, 2010 Share Posted December 1, 2010 how to explain... erm.. the code as it stands now Func add2() $write1 = InputBox("Please input the name(s)","Please seperate the names with ,") add2() while 1 MouseClick("left", 190,49,1,100) MouseClick("left", 179,45,1,100) MouseClick("left", 221,52,1,100) ;Search bar send ($write1) MouseClick("left", 321,51,1,100) ; Search button OK ;found Name- Adding name mouseclick ("right",954,576,1,100) MouseClick("left",1018,630,1,100) MouseClick("left", 920,490,1,100);Settings1 ;Watchlist on MouseClick("left", 844,533,1,100) ;done ;Push Add contact MouseClick("left", 915,646,1,100) EndFunc wend so lets say i type in Andreas and Tom.. this way "Andreas,Tom" then it does two things. 1 = change the while run to the number of names typed into the inputbox (for this example 2) 2 = sends Andreas to the $write1 command, and on the second run it sends Tom into the $write1 command *hope this explains it abit* Basically your solution to this is what the users aboved mentioned, use an array. Link to comment Share on other sites More sharing options...
Realm Posted December 1, 2010 Share Posted December 1, 2010 (edited) Hello pezo89, Your structure is all wrong. First, your calling your function from within itself. While possible, it is not recommended due to recursion, and depending on the rest of your script, It may never run. Second, you ended the function before you ended the loop. I have made a few modifications, that will make it functional, and how I believe you want it. Local $input1 $input1 = InputBox("Please input the name(s)","Please seperate the names with ,") add2() Func add2() $write1 = StringSplit($input1,',',2) For $i = 0 To UBound($write1)-1 MouseClick("left", 190,49,1,100) MouseClick("left", 179,45,1,100) MouseClick("left", 221,52,1,100) ;Search bar send ($write1[$i]) MouseClick("left", 321,51,1,100) ; Search button OK ;found Name- Adding name mouseclick ("right",954,576,1,100) MouseClick("left",1018,630,1,100) MouseClick("left", 920,490,1,100);Settings1 ;Watchlist on MouseClick("left", 844,533,1,100) ;done ;Push Add contact MouseClick("left", 915,646,1,100) Next EndFunc Realm Edited December 1, 2010 by Realm My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. Link to comment Share on other sites More sharing options...
pezo89 Posted December 1, 2010 Author Share Posted December 1, 2010 It works like a charm. Thanks alot for the help fellas, really appriciate it! btw, (as it seems you guys are really experienced) is there any 'easy' fix to this input form? only beeing able to select one of the checkboxes, and it does a diffrent loop deppendant on wtch one is selected or if ya can point me in the right direction please #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=C:\Users\Andreas\Documents\Dreadnought.kxf $Dreadnought = GUICreate("Dreadnought", 633, 172, 192, 114) GUISetIcon("C:\Users\Andreas\Downloads\au3.ico") $input1 = GUICtrlCreateInput("Input Names here, Seperate them with ,", 24, 16, 369, 24) $Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 104, 64, 97, 17) $Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 104, 88, 97, 17) $Checkbox3 = GUICtrlCreateCheckbox("Checkbox3", 104, 112, 97, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
Realm Posted December 1, 2010 Share Posted December 1, 2010 pezo89, I am glad to see that you are atleast providing an example of the code. However, when asking for help you need to be more descriptive, explaining in full what it is that your attempting to do, what problem your having, and what results your expecting. Having all the information is easier to help, just like having all the parts is handy in repairing a vehicle. Now If I understand your qeustion correctly, you want the only one checkbox to be selected and if it is, then the other 2 to remain unchecked. If I am correct, there are 2 suggestions to correct this.First, instead of using CheckBoxes, use Radio buttons such as GUICtrlCreateRadio(). These buttons act as a group, unless you code them not to, and do exactly what I think your asking for.Second, Would be to include a GUICtrlRead() and Switch into your While Loop, and if one is checked, then uncheck the other 2.I would suggest going with the radio buttons since it would be easier to incorporate into your script, unless you need them to be check boxes for whatever reason.Realm My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. Link to comment Share on other sites More sharing options...
pezo89 Posted December 1, 2010 Author Share Posted December 1, 2010 (edited) yea i understand. but my head is all over at these hours, so kind hard explaning.. anyways this is what iv gotten so far, it's a few pices iv picked up abit here and abit there and put them togheter. but my question is how can i add the add2 & add3 func into where the msgbox is? and have 3 diffrent ie: func deppending on witch f the 3 buttons that is selected, but func add2 & 3 are always the same thou expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=C:\Users\Andreas\Documents\Dreadnought.kxf $Dreadnought = GUICreate("Dreadnought", 633, 172, 192, 114) GUISetIcon("C:\Users\Andreas\Downloads\au3.ico") $input1 = GUICtrlCreateInput("Input Names here, Seperate them with ,", 24, 16, 369, 24) GUIStartGroup() Local $checkCN[7][3] ; This array holds the ControlIDs for the radios $checkCN[0][0] = GUICtrlCreateRadio("input_1",104, 64, 97, 17) $checkCN[1][0] = GUICtrlCreateRadio("input_2", 104, 88, 97, 17) $checkCN[2][0] = GUICtrlCreateRadio("input_3", 104, 112, 97, 17) $Button1 = GUICtrlCreateButton("Button1", 264, 64, 161, 49, $WS_GROUP) if $Button1=0 Then MsgBox(0,"test","test") EndIf For $i = 0 To 2 GUICtrlSetState($checkCN[$i][1], $GUI_DISABLE) GUICtrlSetState($checkCN[$i][2], $GUI_DISABLE) GUISetState() Local $iCurrSel = 7 ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button1 MsgBox(0,"test","test") Exit EndSelect WEnd Next GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Edited December 1, 2010 by pezo89 Link to comment Share on other sites More sharing options...
Realm Posted December 1, 2010 Share Posted December 1, 2010 pezo89, This is what I am talking about, you need to give more information. What activates these funtions? does the radio buttons, does the input, does the 'Button1'? I don't know how to help you place your function calls without this knowledge. For this example I will assume its 'Button1' that searches for the checked radio button, then performs the selected function. As for your Functions place them at the end of your script. Why do you have 2 While loops there? The Second one is not needed, and the First one should be place after you set the GUI state. Your code structure is all wrong!!! No offense meant; but how did you get to 143 posts in almost 2 years, and still you don't understand structure, functions, or placement of custom functions? What I suggest is spending some time reading the 'Help File' and taking part in some tutorials. There are many tutorials on You Tube along with a Tutorial built in AutoIt in Example section of the Forums called: 'AutoIt 1-2-3' I know you just want to jump right into it, but this is one of those things in life that pay off more by doing the studying first. It will save you time, and us as well. expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=C:\Users\Andreas\Documents\Dreadnought.kxf $Dreadnought = GUICreate("Dreadnought", 633, 172, 192, 114) GUISetIcon("C:\Users\Andreas\Downloads\au3.ico") $input1 = GUICtrlCreateInput("Input Names here, Seperate them with ,", 24, 16, 369, 24) Local $checkCN[3] ; This array holds the ControlIDs for the radios $checkCN[0] = GUICtrlCreateRadio("input_1",104, 64, 97, 17) $checkCN[1] = GUICtrlCreateRadio("input_2", 104, 88, 97, 17) $checkCN[2] = GUICtrlCreateRadio("input_3", 104, 112, 97, 17) $Button1 = GUICtrlCreateButton("Button1", 264, 64, 161, 49, $WS_GROUP) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button1 MsgBox(0,"test","test") For $check = 0 To UBound($checkCN)-1 If GUICtrlRead($checkCN[$check]) = $GUI_CHECKED Then Switch $check Case = 0 add1($input1) Case = 1 add2($input1) Case = 2 add3($input1) EndSwitch EndIf Exit EndSelect WEnd Func add1() ;do something EndFunc Func add2($input1) MsgBox(0,'Here','Here') $write1 = StringSplit($input1,',',2) For $i = 0 To UBound($write1)-1 MouseClick("left", 190,49,1,100) MouseClick("left", 179,45,1,100) MouseClick("left", 221,52,1,100) ;Search bar send ($write1[$i]) MouseClick("left", 321,51,1,100) ; Search button OK ;found Name- Adding name mouseclick ("right",954,576,1,100) MouseClick("left",1018,630,1,100) MouseClick("left", 920,490,1,100);Settings1 ;Watchlist on MouseClick("left", 844,533,1,100) ;done ;Push Add contact MouseClick("left", 915,646,1,100) Next EndFunc Func add3() ;do something EndFunc Realm My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. Link to comment Share on other sites More sharing options...
pezo89 Posted December 2, 2010 Author Share Posted December 2, 2010 (edited) hi i had an Case error, now it is gone. but now i only selects the top function, and even if i check the others it wont change. been reading around on case in helpfile.hopefully il figure it out btw, Thanks alot for the help expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=C:\Users\Andreas\Documents\Dreadnought.kxf $Dreadnought = GUICreate("Dreadnought", 633, 172, 192, 114) GUISetIcon("C:\Users\Andreas\Downloads\au3.ico") $input1 = GUICtrlCreateInput("Input Names here, Seperate them with ,", 24, 16, 369, 24) Local $checkCN[3] ; This array holds the ControlIDs for the radios $checkCN[0] = GUICtrlCreateRadio("input_1",104, 64, 97, 17) $checkCN[1] = GUICtrlCreateRadio("input_2", 104, 88, 97, 17) $checkCN[2] = GUICtrlCreateRadio("input_3", 104, 112, 97, 17) $Button1 = GUICtrlCreateButton("Button1", 264, 64, 161, 49, $WS_GROUP) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button1 MsgBox(0,"test","test") For $check = 0 To UBound($checkCN)-1 If GUICtrlRead($checkCN[$check]) = $GUI_CHECKED Then Switch $check Case $checkCN[0] = 0 add1() Case $checkCN[1] = 1 add2() Case $checkCN[2] = 2 add3() EndSwitch EndIf Exit Next EndSelect WEnd Func add1() ;do something EndFunc Func add2() MsgBox(0,'Here','Here') $write1 = StringSplit($input1,',',2) For $i = 0 To UBound($write1)-1 MouseClick("left", 190,49,1,100) MouseClick("left", 179,45,1,100) MouseClick("left", 221,52,1,100) ;Search bar send ($write1[$i]) MouseClick("left", 321,51,1,100) ; Search button OK ;found Name- Adding name mouseclick ("right",954,576,1,100) MouseClick("left",1018,630,1,100) MouseClick("left", 920,490,1,100);Settings1 ;Watchlist on MouseClick("left", 844,533,1,100) ;done ;Push Add contact MouseClick("left", 915,646,1,100) Next EndFunc Func add3() ;do something EndFunc Edit: managed to make it work, unsure if this is the 'correct' way to do it. but it works expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Local $input1 #Region ### START K $Dreadnought = GUICreate("Dreadnought", 633, 172, 192, 114) GUISetIcon("C:\Users\Andreas\Downloads\au3.ico") $input1 = InputBox("Please input the name(s)","Please seperate the names with , and press enter") Local $checkCN[3] ; This array holds the ControlIDs for the radios $checkCN[0] = GUICtrlCreateRadio("input_1",104, 64, 97, 17) $checkCN[1] = GUICtrlCreateRadio("input_2", 104, 88, 97, 17) $checkCN[2] = GUICtrlCreateRadio("input_3", 104, 112, 97, 17) $Button1 = GUICtrlCreateButton("Button1", 264, 64, 161, 49, $WS_GROUP) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button1 MsgBox(0,"test","test") #region select function depending on witch checkbox that is checked If GUICtrlRead($checkCN[0]) = $GUI_CHECKED Then add1() EndIf If GUICtrlRead($checkCN[1]) = $GUI_CHECKED Then add2() EndIf If GUICtrlRead($checkCN[3]) = $GUI_CHECKED Then add3() EndIf EndSelect WEnd #region: Function ; - Selects witch mode to do deppending on witch checbox that has been selected Func add1() $write1 = StringSplit($input1,',',2) For $i = 0 To UBound($write1)-1 sleep (100) ControlFocus("Untitled - Notepad","",15) send ($write1[$i]) Next EndFunc Func add2() $write1 = StringSplit($input1,',',2) For $i = 0 To UBound($write1)-1 sleep (100) ControlFocus("Untitled - Notepad","",15) send ($write1[$i]) Next EndFunc Func add3() ;do something EndFunc Edited December 2, 2010 by pezo89 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