Exact Match in listbox

Get help with using AutoHotkey and its commands and hotkeys
holydoji
Posts: 8
Joined: 05 Dec 2019, 14:35

Exact Match in listbox

20 Dec 2019, 17:36

Hello,

I want to automate creating stuff using a software (Articulate Storyline 3). In Storyline 2 I have to choose from a listbox exact name of a trigger, so it must be the exact match of the name. It is for example "Kopie1ofFirstTime" and not the also existing names like "Kopie12ofFirstTime" or "Kopie11ofFirstTime" and so on.

After that I want later in the script choose the next trigger name with one number count higher, so "Kopie2ofFirstTime" and so on.

The listbox already contains all trigger names, I am wondering how to select the exact name in the listbox.

I am lost with the Control, ChooseString, ...because this only picks the first found value that is not the right one.

Could you help me with a clue?

Thanks,
Thorsten
Last edited by holydoji on 21 Dec 2019, 04:34, edited 1 time in total.
A_Perry_1984
Posts: 76
Joined: 07 Dec 2018, 12:08

Re: Exact Match in listbox

20 Dec 2019, 19:37

Will something like this work?

Code: Select all

#SingleInstance, Force
List = Kopie1ofFirstTime||Kopie2ofFirstTime|Kopie3ofFirstTime|Kopie3ofFirstTime
Gui, +Alwaysontop 
Gui, Add, listbox, vMyList, % list
Gui, Add, button, gChoose ,Choose
Gui, Show, w180
return

Choose:
Gui, Submit, nohide
Loop
{
i++
GuiControl, Choose, MyList, Kopie%i%ofFirstTime
if (i = 3)
	i =
sleep 1000
}
return

*esc::
ExitApp
holydoji
Posts: 8
Joined: 05 Dec 2019, 14:35

Re: Exact Match in listbox

21 Dec 2019, 06:15

Hi there,

thank you, Perry for your code.
I wrote misleading i think. I updated my first post.

So I am talking about the bold marked code below.
I am using a software in that I have to create hundreds of so called triggers. All triggernames are in one listbox. First trigger should have name Kopie1vonQFirstTime, the second that I create the name Kopie2vonQFirstTime and so on.

Code ist working for the first Trigger, but now I dont know how to cycle through the loop to create 50 further trigger with triggernames.

START: Zweite Variable aus Triggerbox kopieren und in alle restlichen Folien kopieren **Vorsicht, Trigger vorher ausprobieren. In SL scheint es so: 2.Trigger = 3, 3.Trigger = 5, 4.Trigger = 6
Control,Choose,3,WindowsForms10.LISTBOX.app.0.3d07698_r9_ad11,ahk_class WindowsForms10.Window.8.app.0.3d07698_r9_ad1 ;Zweite Variable auswählen
Sleep, 350
ControlClick,WindowsForms10.BUTTON.app.0.3d07698_r9_ad115,ahk_class WindowsForms10.Window.8.app.0.3d07698_r9_ad1,,Left,1,,, ; Button "Ausgewählten Trigger kopieren" klicken
Sleep, 350
CoordMode,Mouse,Relative
Loop 50 ; In soviele Slide wird der kopierte Trigger eingefügt ***Slideanzahl hier anpassen***
{
Click, 35, 400 ; Klick in linke Slide-Leiste damit diese aktiv wird
Sleep, 350
Send {Down} ; Taste Pfeil runter zur nächsten Slide
Sleep, 350
ControlClick,WindowsForms10.BUTTON.app.0.3d07698_r9_ad114,ahk_class WindowsForms10.Window.8.app.0.3d07698_r9_ad1,,Left,1,,, ; Button "Ausgewählten Trigger einfügen" klicken
Sleep, 350
ControlClick,WindowsForms10.BUTTON.app.0.3d07698_r9_ad116,ahk_class WindowsForms10.Window.8.app.0.3d07698_r9_ad1,,Left,1,,, ; Button "Trigger bearbeiten" klicken
Sleep, 500
var=0 ; Variable hat diesen Startwert
var+=1 ; Increase Var by 1 and assign this new value to the variable var
Control, ChooseString,Kopie%var%vonQFirstTime,WindowsForms10.COMBOBOX.app.0.3d07698_r9_ad16,Trigger-Assistent ;Im Feld "Variable" den Wert "KopieXXvonQFirstTime" auswählen

Sleep, 500
ControlClick,WindowsForms10.BUTTON.app.0.3d07698_r9_ad17,Trigger-Assistent
Sleep, 500
just me
Posts: 7114
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Exact Match in listbox

21 Dec 2019, 07:02

Moin,

searching for Kopie1vonQFirstTime won't find Kopie11vonQFirstTime.

Code: Select all

var=0 ; Variable hat diesen Startwert ; <<<<< ich denke, der Startwert muss vor Beginn der Schleife gesetzt werden !!!
var+=1 ; Increase Var by 1 and assign this new value to the variable var
Control, ChooseString,Kopie%var%vonQFirstTime,WindowsForms10.COMBOBOX.app.0.3d07698_r9_ad16,Trigger-Assistent ;Im Feld "Variable" den Wert "KopieXXvonQFirstTime" auswählen
If you reset var to 0 within the Loop, the script will always try to choose Kopie1vonQFirstTime.
holydoji
Posts: 8
Joined: 05 Dec 2019, 14:35

Re: Exact Match in listbox

21 Dec 2019, 12:29

Moin zurück :)

I deleted " var=0 " and the script is working.

I am just irritated my AHK Studio that always marks this line

var+=1

and says that this variable is not assigned a value.

I dont understand what the cause is.
just me
Posts: 7114
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Exact Match in listbox

22 Dec 2019, 06:48

Code: Select all

START: ; Zweite Variable aus Triggerbox kopieren und in alle restlichen Folien kopieren **Vorsicht, Trigger vorher ausprobieren. In SL scheint es so: 2.Trigger = 3, 3.Trigger = 5, 4.Trigger = 6
Control,Choose,3,WindowsForms10.LISTBOX.app.0.3d07698_r9_ad11,ahk_class WindowsForms10.Window.8.app.0.3d07698_r9_ad1 ;Zweite Variable auswählen
Sleep, 350
ControlClick,WindowsForms10.BUTTON.app.0.3d07698_r9_ad115,ahk_class WindowsForms10.Window.8.app.0.3d07698_r9_ad1,,Left,1,,, ; Button "Ausgewählten Trigger kopieren" klicken
Sleep, 350
CoordMode,Mouse,Relative
Var := 0 ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Loop 50 ; In soviele Slide wird der kopierte Trigger eingefügt ***Slideanzahl hier anpassen***
{
	Click, 35, 400 ; Klick in linke Slide-Leiste damit diese aktiv wird
	Sleep, 350
	Send {Down} ; Taste Pfeil runter zur nächsten Slide
	Sleep, 350
	ControlClick,WindowsForms10.BUTTON.app.0.3d07698_r9_ad114,ahk_class WindowsForms10.Window.8.app.0.3d07698_r9_ad1,,Left,1,,, ; Button "Ausgewählten Trigger einfügen" klicken
	Sleep, 350
	ControlClick,WindowsForms10.BUTTON.app.0.3d07698_r9_ad116,ahk_class WindowsForms10.Window.8.app.0.3d07698_r9_ad1,,Left,1,,, ; Button "Trigger bearbeiten" klicken
	Sleep, 500
	var += 1 ; Increase Var by 1 and assign this new value to the variable var <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
	Control, ChooseString,Kopie%var%vonQFirstTime,WindowsForms10.COMBOBOX.app.0.3d07698_r9_ad16,Trigger-Assistent ;Im Feld "Variable" den Wert "KopieXXvonQFirstTime" auswählen
	...

Return to “Ask For Help”

Who is online

Users browsing this forum: AHKStudent, Bing [Bot], c7aesa7r, Google [Bot], NOLLIE, TAC109 and 49 guests