Page 1 of 1

loop script

Posted: 23 Nov 2017, 16:03
by Mightykiller
Hello i need help to make a loop script to sendinput whats inside MyListBox , but i want it to send them like this first name in line 1 - second name in line 2 etc
And send a string before every input
for example if i had a list box that has names like "Nike roger roy and the string was Hello the scripts should do this :
Hello Nike
Hello roger
Hello roy

Re: loop script

Posted: 23 Nov 2017, 17:52
by Osprey
Do you mean like this?

Code: Select all

MyListBox = Nike|roger|roy

Gui, Add, ListBox, vMyListBoxItem, %MyListBox%

MyString = Hello

Loop, parse, MyListBox, |
{
    SendInput, %MyString% %A_LoopField%`n
}

Re: loop script

Posted: 23 Nov 2017, 19:55
by Mightykiller
No i need to send just the names in the ListBox 1 time.

Re: loop script

Posted: 23 Nov 2017, 20:13
by Osprey
That's what it does. If the listbox (technically, the string that the listbox uses) contains the names Nike, roger and roy (Nike|roger|roy), it prints out...

Hello Nike
Hello roger
Hello roy

...one time. Have you tried running it?

Re: loop script

Posted: 24 Nov 2017, 14:50
by Mightykiller
i have 1 edit box and the input from that edit is sent to the Listbox now i only need to press a button and all the names in my listbox will be sent with a string using SendInput thats all...

Re: loop script

Posted: 24 Nov 2017, 14:53
by Mightykiller
i did try this, but it does't work it only sends the names wrong

Code: Select all

Vouch:  
    MyString = Hello

Loop, parse, MyListBox, |
{
    
    SendInput, %MyString% %A_LoopField%`n
}
    
    return

Re: loop script

Posted: 24 Nov 2017, 15:25
by A_AhkUser
Hi,

Use ControlGet,, List to retrieve all the entries of a listview control:

Code: Select all

boolean = 0
string = Hello
values = a|b|c|d|e|f
Gui, Add, ListBox, w400 h400 vMyListBox +hwndLVID, ; +hwndID strores listview ID in LVID
Gui, Add, Button,, send_to_listbox
Gui, Show, AutoSize
return

Buttonsend_to_listbox:
GuiControl,, MyListBox, %values%
boolean = 1
return

#If boolean
F2::
ControlGet, list, List,,, ahk_id %LVID% ; to operate upon a control's ID,  one can use ahk_id %ControlID% for the WinTitle parameter 
Loop, Parse, list, `n
    MsgBox, %string% %A_LoopField%.
return
#If

Re: loop script

Posted: 25 Nov 2017, 14:39
by Mightykiller
This doesn't work only prints out abcdef when i press Buttonsend_to_listbox:

Re: loop script

Posted: 25 Nov 2017, 21:00
by A_AhkUser
Mightykiller wrote:This doesn't work only prints out abcdef when i press Buttonsend_to_listbox:
...and when you press F2 what's happen :?: