Label

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Alcrkai
Posts: 47
Joined: 16 Mar 2021, 10:51

Label

20 Jun 2021, 05:59

Good Morning.

How do I make a label run automatically, I made an example below. I want the listview labels to run without me having to click on the list how do I do this?

Code: Select all

arrayex:=[]

arrayex.push(["one"])
arrayex.push(["two"])

gui, add, button, ggo w40 h30,go
gui, show , w90 h45 ,
return




GuiClose:
ExitApp

go:
gui, submit, nohide
gui, g:destroy
Gui, g:Add, ListView, x2 y19 w200 h310 vlvo gone cred +AltSubmit Grid , One
Gui, g:Add, ListView, x242 y19 w220 h310 vlvt gtwo cred grid , Two
Gui, g:Show, w479 h379, Untitled GUI
return

one:
Gui, submit, nohide
Gui, listview, lvo
Loop % arrayex.count()
	LV_Add("", "one")
return

two:
gui, Submit, nohide
Gui, listview, lvt
Loop % arrayex.count()
 LV_Add("", "two")
return
User avatar
mikeyww
Posts: 26939
Joined: 09 Sep 2014, 18:38

Re: Label

20 Jun 2021, 06:12

Gosub will call the labeled routine. An alternative is putting the code before your first Return. You can also do both: put the labeled routine before your first Return; it would then run at the start and also later when called. An example is below.

Code: Select all

arrayex:=[], arrayex.push(["one"]), arrayex.push(["two"])
Gui, Add, Button, w40 h30, Go
Gui, Show, x350 y350 w90 h45
ButtonGo:
Gui, g:New
Gui, Add, ListView, x2   y19 w200 h310 vlvo gone cred Grid AltSubmit, One
Gui, Add, ListView, x242 yp  w220 hp   vlvt gtwo cred Grid          , Two
Gui, Show, w479 h379, Count
Return
Alcrkai
Posts: 47
Joined: 16 Mar 2021, 10:51

Re: Label

20 Jun 2021, 06:34

thanks.
it worked, I had tried it before but I hadn't used new, now that I used it, it worked
User avatar
mikeyww
Posts: 26939
Joined: 09 Sep 2014, 18:38

Re: Label

20 Jun 2021, 06:36

Good! Your other method with "Destroy" is also OK, but "New" will first destroy a GUI by the same name, so there is not much difference if any.

Other simple demos here:

1. "yp" means "Use the previous y-value".
2. The default "go to" label name for a button is "Button" followed by the button text. For a named GUI, this would also be preceded by the GUI name.

You could use one GUI instead of two. If you maintain two, you will sometimes need to specify the target GUI in other threads such as labeled routines.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Joey5 and 271 guests