loop script

Get help with using AutoHotkey and its commands and hotkeys
Mightykiller
Posts: 43
Joined: 09 Oct 2017, 13:34

loop script

23 Nov 2017, 16:03

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
Osprey
Posts: 294
Joined: 18 Nov 2017, 05:50

Re: loop script

23 Nov 2017, 17:52

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
}
Last edited by Osprey on 23 Nov 2017, 20:11, edited 1 time in total.
Mightykiller
Posts: 43
Joined: 09 Oct 2017, 13:34

Re: loop script

23 Nov 2017, 19:55

No i need to send just the names in the ListBox 1 time.
Osprey
Posts: 294
Joined: 18 Nov 2017, 05:50

Re: loop script

23 Nov 2017, 20:13

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?
Mightykiller
Posts: 43
Joined: 09 Oct 2017, 13:34

Re: loop script

24 Nov 2017, 14:50

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...
Mightykiller
Posts: 43
Joined: 09 Oct 2017, 13:34

Re: loop script

24 Nov 2017, 14:53

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
A_AhkUser
Posts: 884
Joined: 06 Mar 2017, 16:18
Location: France

Re: loop script

24 Nov 2017, 15:25

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
Mightykiller
Posts: 43
Joined: 09 Oct 2017, 13:34

Re: loop script

25 Nov 2017, 14:39

This doesn't work only prints out abcdef when i press Buttonsend_to_listbox:
A_AhkUser
Posts: 884
Joined: 06 Mar 2017, 16:18
Location: France

Re: loop script

25 Nov 2017, 21:00

Mightykiller wrote:This doesn't work only prints out abcdef when i press Buttonsend_to_listbox:
...and when you press F2 what's happen :?:

Return to “Ask For Help”

Who is online

Users browsing this forum: blad4, Google [Bot], Mipha and 49 guests