ListView PROBLEM Topic is solved

Ask gaming related questions (AHK v1.1 and older)
henriquehassi
Posts: 24
Joined: 29 Jul 2020, 17:11

ListView PROBLEM

30 Jul 2020, 14:12

I'm trying to add some images associated with Listview, the problem is that whenever I add another line with a different image it replaces the image of all other lines

look at the example
https://prnt.sc/trdava

my code

Code: Select all

Waypoint := 0

SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
Gui, Add, Tab2, +BackgroundTrans x-3 y0 h408 w650, Waypoints|Configurações
Gui, Add, GroupBox, x2 y50 w650 h500 , Bush Colector
Gui, Add, ListView, x12 y109 w480 h290 vWaypoint,  Waypoint|Action|Bush Direction
LV_ModifyCol(1, 50), LV_ModifyCol(2, 100), LV_ModifyCol(3, 150)
Gui, Add, DropDownList, x502 y289 w140 h100 vATITUDE,  Andar|Coletar|
Gui, Add, Button, x502 y189 w40 h30 gWEST, WEST
Gui, Add, Button, x552 y159 w40 h30 gNORTH, NORT
Gui, Add, Button, x602 y189 w40 h30 gEAST, EAST
Gui, Add, Button, x552 y219 w40 h30 gSOUTH, SOUT
Gui, Show, x322 y263 h408 w650, New GUI Window
Return

GuiClose:
ExitApp


NORTH:
gui, submit, nohide
Action = %ATITUDE%
Bush_Direction = SOUTH
Waypoint += 1
ImageListID := IL_Create(10)
LV_SetImageList(ImageListID)
IL_Add(ImageListID, "files/marks/mark1.png")
LV_Add("icon" 1,Waypoint,Action,Bush_Direction)
Return



SOUTH:
gui, submit, nohide
Action = %ATITUDE%
Bush_Direction = SOUTH
Waypoint += 1
ImageListID := IL_Create(10)
LV_SetImageList(ImageListID)
IL_Add(ImageListID, "files/marks/mark2.png")
LV_Add("icon" 1,Waypoint,Action,Bush_Direction)
Return



WEST:
gui, submit, nohide
Action = %ATITUDE%
Bush_Direction = WEST
Waypoint += 1
ImageListID := IL_Create(10)
LV_SetImageList(ImageListID)
IL_Add(ImageListID, "files/marks/mark3.png")
LV_Add("icon" 1,Waypoint,Action,Bush_Direction)
Return



EAST:
gui, submit, nohide
Action = %ATITUDE%
Bush_Direction = EAST
Waypoint += 1
ImageListID := IL_Create(10)
LV_SetImageList(ImageListID)
IL_Add(ImageListID, "files/marks/mark4.png")
LV_Add("icon" 1,Waypoint,Action,Bush_Direction)
Return


IniRead("settingsFULLKEYBOARD.ini", "Numpad") ; reads the [Settings] section from the ini file MyApp.ini into the script's memory.






































IniRead(_IniFile="", _Options="") ; http://www.autohotkey.com/forum/topic72442.html
{
	Local _Reading, _Prepend, _Entries, _nSec, _nKey, _@, _@1, _@2, _@3, _@4, _@5 := 1, _Literal := """", _Commands := "sa|ka|sl|sr|p|d|r|e|t|c|b|f"
	;--------------------------------------OPTIONS-------------------------------------------------------
	; Each letter or word below is a flag that corresponds to one of the settings of the function. These settings can take any string as a value. A) By default, each setting takes the value assigned in the first column below. B) You may change settings by including that flag in the Options parameter of the function. In this case the passed option will take the value assigned in the 2nd column below. C) Indicate any other value with a string immediately following the corresponding flag. Include spaces in this string by surrounding it with quotes. Separate each flag and string pairing with a space.
	;----------------------------------------------------------------------------------------------------
	; DEFAULT                 USER DEFAULT             NAME                    ABOUT
	, _sa := "",              _sa_user := "Sections*"  ;sa = Section Array     Creates the specified pseudoarray containing each section header that was read. An asterisk (*) will be replaced by the item number, otherwise it will be appended to the end. Item 0 will contain the size of the ray. Only applicable if all sections are being read (s = "")
	, _ka := "",              _ka_user := "Keys*"      ;ka = Key Array         Same as above but for individual keys. Similar to the d option
	, _sl := "",              _sl_user := "*"          ;sl = Section (Literal) Section to use out of whole file. If multiple sections have the same name the first will be used. Specify an asterisk (*) to only read the first section. Leave blank to read the entire file
	, _sr := "",              _sr_user := ""           ;sr = Section (RegEx)   Same as above but will extract from all sections whose names match the given regular expression
	, _p := "",               _p_user := "*_"          ;p = Prepend            Prepend this string to the variables. An asterisk (*) will be replaced by the current section name
	, _d := "",               _d_user := "`n"          ;d = Delimited List     Instead of returning the number of keys read, the function will return a string of all variables created (i.e. all keys read with any additional modifications made by _r or _p) delimited by the indicated character(s)
	, _r := "",               _r_user := "_"           ;r = Replace Bad Chars  One or more characters in key or section names that are unsuitable for AutoHotkey variable names will be replaced by this character
	, _e := "fso",            _e_user := ""            ;e = Error Behavior     Indicate/omit any combination of the characters f/s/o/r to display an error dialog/exit silently if the ini file cannot be found/the desired section cannot be found/a preexisting variable will be overwritten/r will replace any inappropriate characters
	, _t := True,             _t_user := False         ;t = Trim Whitespace    Trims whitespaces from the beginning and end of all keys and values
	, _c := True,             _c_user := False         ;c = Allow Comments     Specifying true for Allow Comments will exclude all comments from ini values. Comments are delimited with a space and then a semicolon (;) as in AutoHotkey
	, _b := True,             _b_user := False         ;b = Use Booleans       If b is true then keys with the string "true", "false", "yes", or "no" will be interpreted as 1 or 0 so as to work nicely with AutoHotkey IF statements
	, _f := True,             _f_user := False         ;f = Deref Values       If f is true then Transform, Deref will be used on all key values. For instance, this allows you to give a filepath a %A_ScriptDir%\File.dat
	;---------------------------------USER CONFIGURATIONS------------------------------------------------
	, _UserConfig_Foo := "x12 y34"
	, _UserConfig_Bar := "cWhite -a"
	;----------------------------------------------------------------------------------------------------
	While (_@5 := RegExMatch(_Options, "i)(?:^|\s)(?:!(\w+)|(\+|-)?(" _Commands ")(" _Literal "(?:[^" _Literal "]|" _Literal _Literal ")*" _Literal "(?= |$)|[^ ]*))", _@, _@5 + StrLen(_@)))
		If (_@1 <> "")
			_Options := SubStr(_Options, 1, _@5 + StrLen(_@)) _UserConfig_%_@1% SubStr(_Options, _@5 + StrLen(_@))
		Else If (_@4 <> "") {
			If (InStr(_@4, _Literal) = 1) and (_@4 <> _Literal) and (SubStr(_@4, 0, 1) = _Literal) and (_@4 := SubStr(_@4, 2, -1))
				StringReplace, _@4, _@4, %_Literal%%_Literal%, %_Literal%, All
			_%_@3% := _@4
		} Else
			_%_@3% := _@2 = "+" ? True : _@2 = "-" ? False : _%_@3%_user
	If (_IniFile = "") {
		If !FileExist(_IniFile := SubStr(A_ScriptFullPath, 1, InStr(A_ScriptFullPath, ".", 0, 0)) "ini") {
			If InStr(_e, "f")
				MsgBox, 262160, %A_ScriptName% - %A_ThisFunc%(): Error, The IniFile parameter was omitted or blank, which the function interprets as an ini file with the same name as the script and in the same dir, i.e.:`n`n%_IniFile%`n`nThis file does not exist.
			Return
		}
	} Else If (IniFile = "*") {
		Loop, *.ini
		{
			_IniFile := A_LoopFileFullPath
			Break
		}
		If (_IniFile = "*") {
			If InStr(_e, "f")
				MsgBox, 262160, %A_ScriptName% - %A_ThisFunc%(): Error, No .ini file found in working directory.`n`not avoid this error, specify an explicit .ini file path in the first parameter of the function.
			Return
		}
	} Else If !FileExist(_IniFile) {
		If InStr(_e, "f")
			MsgBox, 262160, %A_ScriptName% - %A_ThisFunc%(): Error, File "%_IniFile%" not found or does not exist.
		Return
	}
	If RegExMatch(_r, "[^\w#@$?]") or RegExMatch(_p, "[^\w*#@$?]") {
		MsgBox, 262160, %A_ScriptName% - %A_ThisFunc%(): Error, Neither the p nor r options may contain characters that are not alloewd in AutoHotkey variable names.
		Return
	}
	_Entries := _d = "" ? 0 : _d
	If !InStr(_p, "*")
		_Prepend := _p
	If (_sl <> "") {
		If (_sr <> "") {
			MsgBox, 262160, %A_ScriptName% - %A_ThisFunc%(): Error, Please enter either a sl (Section - Literal) or sr (Section - RegEx) value, not both.
			Return
		}
	} Else If (_sr = "")
		_Reading := True
	If (_sa <> "") {
		If RegExMatch(_sa, "[^\w#@$?*]")
			_sa := RegExReplace(_sa, "[^\w#@$?*]")
		If !InStr(_sa, "*")
			_sa .= "*"
	}
	If (_ka <> "") {
		If RegExMatch(_ka, "[^\w#@$?*]")
			_ka := RegExReplace(_ka, "[^\w#@$?*]")
		If !InStr(_ka, "*")
			_ka .= "*"
		If (_ka = _sa) {
			MsgBox, 262160, %A_ScriptName% - %A_ThisFunc%(): Error, The sa (Section Output Array) and ka (Key Output Array) options cannot be the same.
			Return
		}
	}
	Loop, Read, %_IniFile%
		If RegExMatch(A_LoopReadLine, "^[^=]*\[\K[^\]]+(?=\])", _@) {
			If _t
				_@ = %_@%
			If (_sr <> "")
				_Reading := RegExMatch(_@, _sr) ? True : False
			Else If (_sl <> "")
				If _Reading
					Break
				Else If (_@ = _sl) or (_sl = "*")
					_Reading := True
			If !_Reading
				Continue
			If InStr(_p, "*") {
				StringReplace, _Prepend, _p, *, % RegExReplace(_@, "[^\w#_t$?]+", _r, _@2), All
				If _@2 and InStr(_e, "r") {
					MsgBox, 262420, %A_ScriptName% - %A_ThisFunc%(): Error, The section "%_@%" contains characters not allowed in AutoHotkey variable names. Replace these characters with "%_r%"?`n`nTo change the replacement character, use the r option.
					IfMsgBox NO
						Return
				}
			}
			If _sa {
				_nSec += 1
				StringReplace, _@1, _sa, *, %_nSec%, All
				%_@1% := _@
			}
		} Else If _Reading and InStr(A_LoopReadLine, "=") {
			_@ := SubStr(A_LoopReadLine, 1, InStr(A_LoopReadLine, "=") - 1), _@2 := SubStr(A_LoopReadLine, InStr(A_LoopReadLine, "=") + 1)
			If _t {
				_@ = %_@%
				_@2 = %_@2%
			}
			If _c
				_@2 := RegExReplace(_@2, "(?:\s+|^);.*")
			_@1 := RegExReplace(_@, "[^\w#_t$?]+", _r)
			If (_@1 <> _@) and InStr(_e, "r") {
				MsgBox, 262420, %A_ScriptName% - %A_ThisFunc%(): Error, The key name "%_@%" contains characters not allowed in AutoHotkey variable names. Replace these characters with "%_r%"?`n`nTo change the replacement character, use the r option.
				IfMsgBox NO
					Return
			}
			If (%_Prepend%%_@1% <> "") and InStr(_e, "o") {
				MsgBox, 262420, %A_ScriptName% - %A_ThisFunc%(): Error, The variable "%_Prepend%%_@1%" has already been assigned, either by %A_ThisFunc%() or elsewhere in the script. Overwrite it with "%_@2%" (the value from the .ini file)?`n`nTo avoid this error, try using the p or s options to make output variable names more unique.
				IfMsgBox NO
					Return
			}
			If _f
				Transform, _@2, Deref, %_@2%
			%_Prepend%%_@1% := !_b ? _@2 : _@2 = "True" or _@2 = "Yes" ? True : _@2 = "False" or _@2 = "No" ? False : _@2
			If (_d <> "") {
				StringReplace, _Entries, _Entries, %_d%%_Prepend%%_@1%%_d%, %_d%, All
				_Entries .= _Prepend _@1 _d
			} Else
				_Entries += 1
			If _ka {
				_nKey += 1
				StringReplace, _@, _ka, *, %_nKey%, All
				%_@% := _Prepend _@1
			}
		}
	If (_sl <> "") and !_Reading and InStr(_e, "s")
		MsgBox, 262160, %A_ScriptName% - %A_ThisFunc%(): Error, Section "%_sl%" was not found in ini file "%_IniFile%", therefore no variables were assigned.`n`nTo avoid this error, use the sr (Section Name - RegEx) option instead of sl (Section Name - Literal), or omit both options.
	If _sa {
		StringReplace, _@, _sa, *, 0, All
		%_@% := _nSec
	}
	If _ka {
		StringReplace, _@, _ka, *, 0, All
		%_@% := _nKey
	}
	Return _d = "" ? _Entries : SubStr(_Entries, 2, -1)
}
Last edited by BoBo on 01 Aug 2020, 00:32, edited 1 time in total.
Reason: Moved to Gaming section.
User avatar
boiler
Posts: 16902
Joined: 21 Dec 2014, 02:44

Re: ListView PROBLEM

30 Jul 2020, 15:54

That's because you keep resetting the ImageList each time a button is pressed. It gets rid of whatever was there before. And don't add the image to the list again every time a button is pressed. Create the list and add images to it all up front, then just have the button routines select the appropriate image (not image 1 each time) from that predefined list:

Code: Select all

Waypoint := 0

SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
Gui, Add, Tab2, +BackgroundTrans x-3 y0 h408 w650, Waypoints|Configurações
Gui, Add, GroupBox, x2 y50 w650 h500 , Bush Colector
Gui, Add, ListView, x12 y109 w480 h290 vWaypoint,  Waypoint|Action|Bush Direction
LV_ModifyCol(1, 50), LV_ModifyCol(2, 100), LV_ModifyCol(3, 150)
Gui, Add, DropDownList, x502 y289 w140 h100 vATITUDE,  Andar|Coletar|
Gui, Add, Button, x502 y189 w40 h30 gWEST, WEST
Gui, Add, Button, x552 y159 w40 h30 gNORTH, NORT
Gui, Add, Button, x602 y189 w40 h30 gEAST, EAST
Gui, Add, Button, x552 y219 w40 h30 gSOUTH, SOUT
Gui, Show, x322 y263 h408 w650, New GUI Window
ImageListID := IL_Create(10)
LV_SetImageList(ImageListID)
IL_Add(ImageListID, "files/marks/mark1.png")
IL_Add(ImageListID, "files/marks/mark2.png")
IL_Add(ImageListID, "files/marks/mark3.png")
IL_Add(ImageListID, "files/marks/mark4.png")
Return

GuiClose:
ExitApp


NORTH:
gui, submit, nohide
Action = %ATITUDE%
Bush_Direction = SOUTH
Waypoint += 1
LV_Add("icon1",Waypoint,Action,Bush_Direction)
Return



SOUTH:
gui, submit, nohide
Action = %ATITUDE%
Bush_Direction = SOUTH
Waypoint += 1
LV_Add("icon2",Waypoint,Action,Bush_Direction)
Return



WEST:
gui, submit, nohide
Action = %ATITUDE%
Bush_Direction = WEST
Waypoint += 1
LV_Add("icon3",Waypoint,Action,Bush_Direction)
Return



EAST:
gui, submit, nohide
Action = %ATITUDE%
Bush_Direction = EAST
Waypoint += 1
LV_Add("icon4",Waypoint,Action,Bush_Direction)
Return


IniRead("settingsFULLKEYBOARD.ini", "Numpad") ; reads the [Settings] section from the ini file MyApp.ini into the script's memory.






































IniRead(_IniFile="", _Options="") ; http://www.autohotkey.com/forum/topic72442.html
{
	Local _Reading, _Prepend, _Entries, _nSec, _nKey, _@, _@1, _@2, _@3, _@4, _@5 := 1, _Literal := """", _Commands := "sa|ka|sl|sr|p|d|r|e|t|c|b|f"
	;--------------------------------------OPTIONS-------------------------------------------------------
	; Each letter or word below is a flag that corresponds to one of the settings of the function. These settings can take any string as a value. A) By default, each setting takes the value assigned in the first column below. B) You may change settings by including that flag in the Options parameter of the function. In this case the passed option will take the value assigned in the 2nd column below. C) Indicate any other value with a string immediately following the corresponding flag. Include spaces in this string by surrounding it with quotes. Separate each flag and string pairing with a space.
	;----------------------------------------------------------------------------------------------------
	; DEFAULT                 USER DEFAULT             NAME                    ABOUT
	, _sa := "",              _sa_user := "Sections*"  ;sa = Section Array     Creates the specified pseudoarray containing each section header that was read. An asterisk (*) will be replaced by the item number, otherwise it will be appended to the end. Item 0 will contain the size of the ray. Only applicable if all sections are being read (s = "")
	, _ka := "",              _ka_user := "Keys*"      ;ka = Key Array         Same as above but for individual keys. Similar to the d option
	, _sl := "",              _sl_user := "*"          ;sl = Section (Literal) Section to use out of whole file. If multiple sections have the same name the first will be used. Specify an asterisk (*) to only read the first section. Leave blank to read the entire file
	, _sr := "",              _sr_user := ""           ;sr = Section (RegEx)   Same as above but will extract from all sections whose names match the given regular expression
	, _p := "",               _p_user := "*_"          ;p = Prepend            Prepend this string to the variables. An asterisk (*) will be replaced by the current section name
	, _d := "",               _d_user := "`n"          ;d = Delimited List     Instead of returning the number of keys read, the function will return a string of all variables created (i.e. all keys read with any additional modifications made by _r or _p) delimited by the indicated character(s)
	, _r := "",               _r_user := "_"           ;r = Replace Bad Chars  One or more characters in key or section names that are unsuitable for AutoHotkey variable names will be replaced by this character
	, _e := "fso",            _e_user := ""            ;e = Error Behavior     Indicate/omit any combination of the characters f/s/o/r to display an error dialog/exit silently if the ini file cannot be found/the desired section cannot be found/a preexisting variable will be overwritten/r will replace any inappropriate characters
	, _t := True,             _t_user := False         ;t = Trim Whitespace    Trims whitespaces from the beginning and end of all keys and values
	, _c := True,             _c_user := False         ;c = Allow Comments     Specifying true for Allow Comments will exclude all comments from ini values. Comments are delimited with a space and then a semicolon (;) as in AutoHotkey
	, _b := True,             _b_user := False         ;b = Use Booleans       If b is true then keys with the string "true", "false", "yes", or "no" will be interpreted as 1 or 0 so as to work nicely with AutoHotkey IF statements
	, _f := True,             _f_user := False         ;f = Deref Values       If f is true then Transform, Deref will be used on all key values. For instance, this allows you to give a filepath a %A_ScriptDir%\File.dat
	;---------------------------------USER CONFIGURATIONS------------------------------------------------
	, _UserConfig_Foo := "x12 y34"
	, _UserConfig_Bar := "cWhite -a"
	;----------------------------------------------------------------------------------------------------
	While (_@5 := RegExMatch(_Options, "i)(?:^|\s)(?:!(\w+)|(\+|-)?(" _Commands ")(" _Literal "(?:[^" _Literal "]|" _Literal _Literal ")*" _Literal "(?= |$)|[^ ]*))", _@, _@5 + StrLen(_@)))
		If (_@1 <> "")
			_Options := SubStr(_Options, 1, _@5 + StrLen(_@)) _UserConfig_%_@1% SubStr(_Options, _@5 + StrLen(_@))
		Else If (_@4 <> "") {
			If (InStr(_@4, _Literal) = 1) and (_@4 <> _Literal) and (SubStr(_@4, 0, 1) = _Literal) and (_@4 := SubStr(_@4, 2, -1))
				StringReplace, _@4, _@4, %_Literal%%_Literal%, %_Literal%, All
			_%_@3% := _@4
		} Else
			_%_@3% := _@2 = "+" ? True : _@2 = "-" ? False : _%_@3%_user
	If (_IniFile = "") {
		If !FileExist(_IniFile := SubStr(A_ScriptFullPath, 1, InStr(A_ScriptFullPath, ".", 0, 0)) "ini") {
			If InStr(_e, "f")
				MsgBox, 262160, %A_ScriptName% - %A_ThisFunc%(): Error, The IniFile parameter was omitted or blank, which the function interprets as an ini file with the same name as the script and in the same dir, i.e.:`n`n%_IniFile%`n`nThis file does not exist.
			Return
		}
	} Else If (IniFile = "*") {
		Loop, *.ini
		{
			_IniFile := A_LoopFileFullPath
			Break
		}
		If (_IniFile = "*") {
			If InStr(_e, "f")
				MsgBox, 262160, %A_ScriptName% - %A_ThisFunc%(): Error, No .ini file found in working directory.`n`not avoid this error, specify an explicit .ini file path in the first parameter of the function.
			Return
		}
	} Else If !FileExist(_IniFile) {
		If InStr(_e, "f")
			MsgBox, 262160, %A_ScriptName% - %A_ThisFunc%(): Error, File "%_IniFile%" not found or does not exist.
		Return
	}
	If RegExMatch(_r, "[^\w#@$?]") or RegExMatch(_p, "[^\w*#@$?]") {
		MsgBox, 262160, %A_ScriptName% - %A_ThisFunc%(): Error, Neither the p nor r options may contain characters that are not alloewd in AutoHotkey variable names.
		Return
	}
	_Entries := _d = "" ? 0 : _d
	If !InStr(_p, "*")
		_Prepend := _p
	If (_sl <> "") {
		If (_sr <> "") {
			MsgBox, 262160, %A_ScriptName% - %A_ThisFunc%(): Error, Please enter either a sl (Section - Literal) or sr (Section - RegEx) value, not both.
			Return
		}
	} Else If (_sr = "")
		_Reading := True
	If (_sa <> "") {
		If RegExMatch(_sa, "[^\w#@$?*]")
			_sa := RegExReplace(_sa, "[^\w#@$?*]")
		If !InStr(_sa, "*")
			_sa .= "*"
	}
	If (_ka <> "") {
		If RegExMatch(_ka, "[^\w#@$?*]")
			_ka := RegExReplace(_ka, "[^\w#@$?*]")
		If !InStr(_ka, "*")
			_ka .= "*"
		If (_ka = _sa) {
			MsgBox, 262160, %A_ScriptName% - %A_ThisFunc%(): Error, The sa (Section Output Array) and ka (Key Output Array) options cannot be the same.
			Return
		}
	}
	Loop, Read, %_IniFile%
		If RegExMatch(A_LoopReadLine, "^[^=]*\[\K[^\]]+(?=\])", _@) {
			If _t
				_@ = %_@%
			If (_sr <> "")
				_Reading := RegExMatch(_@, _sr) ? True : False
			Else If (_sl <> "")
				If _Reading
					Break
				Else If (_@ = _sl) or (_sl = "*")
					_Reading := True
			If !_Reading
				Continue
			If InStr(_p, "*") {
				StringReplace, _Prepend, _p, *, % RegExReplace(_@, "[^\w#_t$?]+", _r, _@2), All
				If _@2 and InStr(_e, "r") {
					MsgBox, 262420, %A_ScriptName% - %A_ThisFunc%(): Error, The section "%_@%" contains characters not allowed in AutoHotkey variable names. Replace these characters with "%_r%"?`n`nTo change the replacement character, use the r option.
					IfMsgBox NO
						Return
				}
			}
			If _sa {
				_nSec += 1
				StringReplace, _@1, _sa, *, %_nSec%, All
				%_@1% := _@
			}
		} Else If _Reading and InStr(A_LoopReadLine, "=") {
			_@ := SubStr(A_LoopReadLine, 1, InStr(A_LoopReadLine, "=") - 1), _@2 := SubStr(A_LoopReadLine, InStr(A_LoopReadLine, "=") + 1)
			If _t {
				_@ = %_@%
				_@2 = %_@2%
			}
			If _c
				_@2 := RegExReplace(_@2, "(?:\s+|^);.*")
			_@1 := RegExReplace(_@, "[^\w#_t$?]+", _r)
			If (_@1 <> _@) and InStr(_e, "r") {
				MsgBox, 262420, %A_ScriptName% - %A_ThisFunc%(): Error, The key name "%_@%" contains characters not allowed in AutoHotkey variable names. Replace these characters with "%_r%"?`n`nTo change the replacement character, use the r option.
				IfMsgBox NO
					Return
			}
			If (%_Prepend%%_@1% <> "") and InStr(_e, "o") {
				MsgBox, 262420, %A_ScriptName% - %A_ThisFunc%(): Error, The variable "%_Prepend%%_@1%" has already been assigned, either by %A_ThisFunc%() or elsewhere in the script. Overwrite it with "%_@2%" (the value from the .ini file)?`n`nTo avoid this error, try using the p or s options to make output variable names more unique.
				IfMsgBox NO
					Return
			}
			If _f
				Transform, _@2, Deref, %_@2%
			%_Prepend%%_@1% := !_b ? _@2 : _@2 = "True" or _@2 = "Yes" ? True : _@2 = "False" or _@2 = "No" ? False : _@2
			If (_d <> "") {
				StringReplace, _Entries, _Entries, %_d%%_Prepend%%_@1%%_d%, %_d%, All
				_Entries .= _Prepend _@1 _d
			} Else
				_Entries += 1
			If _ka {
				_nKey += 1
				StringReplace, _@, _ka, *, %_nKey%, All
				%_@% := _Prepend _@1
			}
		}
	If (_sl <> "") and !_Reading and InStr(_e, "s")
		MsgBox, 262160, %A_ScriptName% - %A_ThisFunc%(): Error, Section "%_sl%" was not found in ini file "%_IniFile%", therefore no variables were assigned.`n`nTo avoid this error, use the sr (Section Name - RegEx) option instead of sl (Section Name - Literal), or omit both options.
	If _sa {
		StringReplace, _@, _sa, *, 0, All
		%_@% := _nSec
	}
	If _ka {
		StringReplace, _@, _ka, *, 0, All
		%_@% := _nKey
	}
	Return _d = "" ? _Entries : SubStr(_Entries, 2, -1)
}
garry
Posts: 3758
Joined: 22 Dec 2013, 12:50

Re: ListView PROBLEM  Topic is solved

31 Jul 2020, 04:14

@boiler thank you
was playing with script , if close, saves content from listview
EDIT : modified, continue with 'waypoint'

Code: Select all

;- ListView PROBLEM 
;- https://www.autohotkey.com/boards/viewtopic.php?f=76&t=79296

#Warn
#NoEnv
SetWorkingDir,%A_ScriptDir% 
;---------
MainWindowTitle=LV_ARROW_PICTURE
Waypoint := 0
Fx=%a_scriptdir%\%mainwindowtitle%_INI.txt
dlm:=";"
c1:=""
;---------
Gui,1:default
Gui, Add, Tab2, +BackgroundTrans x-3 y0 h408 w650, Waypoints|Configurações
Gui, Add, GroupBox, x2 y50 w650 h500 , Bush Colector
Gui, Add, ListView, x12 y109 w480 h290 vWaypoint,  Waypoint|Action|Bush Direction
LV_ModifyCol(1, 50), LV_ModifyCol(2, 100), LV_ModifyCol(3, 150)
Gui, Add, DropDownList, x502 y289 w140 h100 vATITUDE,  Andar|Coletar
Gui, Add, Button, x502 y189 w40 h30 gWEST , WEST
Gui, Add, Button, x552 y159 w40 h30 gNORTH, NORT
Gui, Add, Button, x602 y189 w40 h30 gEAST , EAST
Gui, Add, Button, x552 y219 w40 h30 gSOUTH, SOUT
Gui, Show, x322 y263 h408 w650,%MainWindowTitle%
GuiControl,1: ChooseString,atitude,Coletar
ImageListID := IL_Create(10)
LV_SetImageList(ImageListID)
IL_Add(ImageListID, "NORTH.ico")
IL_Add(ImageListID, "SOUTH.ico")
IL_Add(ImageListID, "WEST.ico")
IL_Add(ImageListID, "EAST.ico")
/*
IL_Add(ImageListID, "files\marks\arrowN_16x16.ico")
IL_Add(ImageListID, "files\marks\arrowS_16x16.ico")
IL_Add(ImageListID, "files\marks\arrowW_16x16.ico")
IL_Add(ImageListID, "files\marks\arrowE_16x16.ico")
*/
gosub,fill
Return
;---------------------
GuiClose:
Gui,1:submit,nohide
ControlGet, Listx, List, , SysListView321,%mainwindowtitle%
if listx<>
 {
 stringreplace,listx,listx,`t,%dlm%,all
 ifexist,%fx%
    filedelete,%fx%
 fileappend,%listx%,%fx%
 listx=
 }
ExitApp
;---------------------
;-------------- Fill Listview xy.CSV -----------
Fill:
Gui,1:submit,nohide
LV_Delete()
FileRead,aac,  *P65001 %fx%
for each, Line in StrSplit(aac, "`n", "`r")
{
if line=
  continue
  c1=
  c2=
  c3=
  stringsplit,C,line,%dlm%
  c1=%c1%
  c2=%c2%
  c3=%c3%
  if (c3="NORTH")
    LV_Add("icon1",c1,c2,c3)
  if (c3="SOUTH")
    LV_Add("icon2",c1,c2,c3)
  if (c3="WEST")
    LV_Add("icon3",c1,c2,c3)
  if (c3="EAST")
    LV_Add("icon4",c1,c2,c3)
  }
waypoint:=C1
return
;----------------------------------------------------
NORTH:
gui, submit, nohide
Action = %ATITUDE%
Bush_Direction = NORTH
Waypoint += 1
LV_Add("icon1",Waypoint,Action,Bush_Direction)
Return
;---------------------
SOUTH:
gui, submit, nohide
Action = %ATITUDE%
Bush_Direction = SOUTH
Waypoint += 1
LV_Add("icon2",Waypoint,Action,Bush_Direction)
Return
;---------------------
WEST:
gui, submit, nohide
Action = %ATITUDE%
Bush_Direction = WEST
Waypoint += 1
LV_Add("icon3",Waypoint,Action,Bush_Direction)
Return
;---------------------
EAST:
gui, submit, nohide
Action = %ATITUDE%
Bush_Direction = EAST
Waypoint += 1
LV_Add("icon4",Waypoint,Action,Bush_Direction)
Return
;============================================================================
henriquehassi
Posts: 24
Joined: 29 Jul 2020, 17:11

Re: ListView PROBLEM

31 Jul 2020, 11:17

garry wrote:
31 Jul 2020, 04:14
@boiler thank you
was playing with script , if close, saves content from listview
EDIT : modified, continue with 'waypoint'

Code: Select all

;- ListView PROBLEM 
;- https://www.autohotkey.com/boards/viewtopic.php?f=76&t=79296

#Warn
#NoEnv
SetWorkingDir,%A_ScriptDir% 
;---------
MainWindowTitle=LV_ARROW_PICTURE
Waypoint := 0
Fx=%a_scriptdir%\%mainwindowtitle%_INI.txt
dlm:=";"
c1:=""
;---------
Gui,1:default
Gui, Add, Tab2, +BackgroundTrans x-3 y0 h408 w650, Waypoints|Configurações
Gui, Add, GroupBox, x2 y50 w650 h500 , Bush Colector
Gui, Add, ListView, x12 y109 w480 h290 vWaypoint,  Waypoint|Action|Bush Direction
LV_ModifyCol(1, 50), LV_ModifyCol(2, 100), LV_ModifyCol(3, 150)
Gui, Add, DropDownList, x502 y289 w140 h100 vATITUDE,  Andar|Coletar
Gui, Add, Button, x502 y189 w40 h30 gWEST , WEST
Gui, Add, Button, x552 y159 w40 h30 gNORTH, NORT
Gui, Add, Button, x602 y189 w40 h30 gEAST , EAST
Gui, Add, Button, x552 y219 w40 h30 gSOUTH, SOUT
Gui, Show, x322 y263 h408 w650,%MainWindowTitle%
GuiControl,1: ChooseString,atitude,Coletar
ImageListID := IL_Create(10)
LV_SetImageList(ImageListID)
IL_Add(ImageListID, "NORTH.ico")
IL_Add(ImageListID, "SOUTH.ico")
IL_Add(ImageListID, "WEST.ico")
IL_Add(ImageListID, "EAST.ico")
/*
IL_Add(ImageListID, "files\marks\arrowN_16x16.ico")
IL_Add(ImageListID, "files\marks\arrowS_16x16.ico")
IL_Add(ImageListID, "files\marks\arrowW_16x16.ico")
IL_Add(ImageListID, "files\marks\arrowE_16x16.ico")
*/
gosub,fill
Return
;---------------------
GuiClose:
Gui,1:submit,nohide
ControlGet, Listx, List, , SysListView321,%mainwindowtitle%
if listx<>
 {
 stringreplace,listx,listx,`t,%dlm%,all
 ifexist,%fx%
    filedelete,%fx%
 fileappend,%listx%,%fx%
 listx=
 }
ExitApp
;---------------------
;-------------- Fill Listview xy.CSV -----------
Fill:
Gui,1:submit,nohide
LV_Delete()
FileRead,aac,  *P65001 %fx%
for each, Line in StrSplit(aac, "`n", "`r")
{
if line=
  continue
  c1=
  c2=
  c3=
  stringsplit,C,line,%dlm%
  c1=%c1%
  c2=%c2%
  c3=%c3%
  if (c3="NORTH")
    LV_Add("icon1",c1,c2,c3)
  if (c3="SOUTH")
    LV_Add("icon2",c1,c2,c3)
  if (c3="WEST")
    LV_Add("icon3",c1,c2,c3)
  if (c3="EAST")
    LV_Add("icon4",c1,c2,c3)
  }
waypoint:=C1
return
;----------------------------------------------------
NORTH:
gui, submit, nohide
Action = %ATITUDE%
Bush_Direction = NORTH
Waypoint += 1
LV_Add("icon1",Waypoint,Action,Bush_Direction)
Return
;---------------------
SOUTH:
gui, submit, nohide
Action = %ATITUDE%
Bush_Direction = SOUTH
Waypoint += 1
LV_Add("icon2",Waypoint,Action,Bush_Direction)
Return
;---------------------
WEST:
gui, submit, nohide
Action = %ATITUDE%
Bush_Direction = WEST
Waypoint += 1
LV_Add("icon3",Waypoint,Action,Bush_Direction)
Return
;---------------------
EAST:
gui, submit, nohide
Action = %ATITUDE%
Bush_Direction = EAST
Waypoint += 1
LV_Add("icon4",Waypoint,Action,Bush_Direction)
Return
;============================================================================
man, you and the other guy did a great job, would you be interested in helping me on this project? I can pay for the help, please :)
garry
Posts: 3758
Joined: 22 Dec 2013, 12:50

Re: ListView PROBLEM

31 Jul 2020, 11:32

@boiler user boiler had the solution , I just added some fancy things
you have a big ini-file which I don't understand
User avatar
boiler
Posts: 16902
Joined: 21 Dec 2014, 02:44

Re: ListView PROBLEM

31 Jul 2020, 11:45

@garry, you also added some useful code. Feel free to accept the offer to be hired for additional work if you would like.
henriquehassi
Posts: 24
Joined: 29 Jul 2020, 17:11

Re: ListView PROBLEM

31 Jul 2020, 14:45

boiler wrote:
31 Jul 2020, 11:45
@garry, you also added some useful code. Feel free to accept the offer to be hired for additional work if you would like.
whichever of you two agree to help me I will be very grateful, the next step that I will add is to make the program follow what is in the listview in order, as for example it has two possible "walk" and "collect" functions the script will follow according to what is in the interface performing different functions.


each image that is in each line of the listview corresponds to the image that will be fetched on the screen, but I really have no idea how to make the script follow what is in the listview regardless of how many lines it has, any of you have any idea how to do it that?
User avatar
boiler
Posts: 16902
Joined: 21 Dec 2014, 02:44

Re: ListView PROBLEM

31 Jul 2020, 15:58

henriquehassi wrote:
31 Jul 2020, 14:45
each image that is in each line of the listview corresponds to the image that will be fetched on the screen, but I really have no idea how to make the script follow what is in the listview regardless of how many lines it has, any of you have any idea how to do it that?
You can loop on all the rows and extract the text from a particular column in each row as shown in the example under LV_GetCount(). Then perform whatever action is desired based on the contents of the text extracted. I would think you can act on what’s in one of the text columns rather than the icon, right? The icon is just a visual representation of what was put in for Bush_Direction, correct?
henriquehassi
Posts: 24
Joined: 29 Jul 2020, 17:11

Re: ListView PROBLEM

31 Jul 2020, 20:21

boiler wrote:
31 Jul 2020, 15:58
henriquehassi wrote:
31 Jul 2020, 14:45
each image that is in each line of the listview corresponds to the image that will be fetched on the screen, but I really have no idea how to make the script follow what is in the listview regardless of how many lines it has, any of you have any idea how to do it that?
You can loop on all the rows and extract the text from a particular column in each row as shown in the example under LV_GetCount(). Then perform whatever action is desired based on the contents of the text extracted. I would think you can act on what’s in one of the text columns rather than the icon, right? The icon is just a visual representation of what was put in for Bush_Direction, correct?
about what you said in relation to the image of each line, this image is the same that will be searched for in the minimap icon in the game, for example if the player marked the image of an "X" in the interface, with the north direction and the "walk" action it will search the minimap for the corresponding data in the game, it will look for the X icon in the game so that as soon as it finds you to take the appropriate actions, do you have any idea how to do this? I would like you to agree to help me, I pay for your services, I believe that for you it is something easily accomplished, since apart from what has already been done, little is missing
User avatar
boiler
Posts: 16902
Joined: 21 Dec 2014, 02:44

Re: ListView PROBLEM

31 Jul 2020, 20:37

You’re missing my point about the other columns. You can tell which icon/image to search for by the text in another column as long as there is certain text that always appears with its associated icon. Each row that has a certain icon will have certain text in another column, correct? That’s how you’ll determine what’s in each row because it’s very easy to read that text and then know to search for the associated icon. It’s not as easy to see what icon is in each row.

It’s not a matter of money for me. I’ll help for free in this thread. If you’d rather have someone dedicated to working this task for you, you’d have a good chance at finding someone by starting a new thread noting that you’re willing to pay for the help.
henriquehassi
Posts: 24
Joined: 29 Jul 2020, 17:11

Re: ListView PROBLEM

31 Jul 2020, 22:28

boiler wrote:
31 Jul 2020, 20:37
You’re missing my point about the other columns. You can tell which icon/image to search for by the text in another column as long as there is certain text that always appears with its associated icon. Each row that has a certain icon will have certain text in another column, correct? That’s how you’ll determine what’s in each row because it’s very easy to read that text and then know to search for the associated icon. It’s not as easy to see what icon is in each row.

It’s not a matter of money for me. I’ll help for free in this thread. If you’d rather have someone dedicated to working this task for you, you’d have a good chance at finding someone by starting a new thread noting that you’re willing to pay for the help.
I did not forget that point, hahaha, about the images, this interface is an outline of what I intend to do in the final project, but there will be a Field for the user to choose the image he wants to create his own route in the game, for example, the the way this image is now associated with a button, but in the future he will select an icon from 10 icons and place it from north, south, east, west, and what is the action, if it is to collect or walk, understand a little? but I can associate each one of the images with a name, making it easier for the script to identify which is the image to perform the search, about your help, I really hope you do not abandon me hahaha I know that for you it is something of no importance, but this project It is important for me, and in relation to making the script follow what is in the listviews in order, one line at a time, can you give me an example and how to do that? for me to bring a more improved code for you to analyze ?? I wish for example that it reads the first line, identifies that it is the first waypoint, check the action, perform an "x" action that I will determine, after that action will go to line 2, so on regardless of how many lines there are listview, I know it got a little confusing, but if you don't understand I try to explain it better
User avatar
boiler
Posts: 16902
Joined: 21 Dec 2014, 02:44

Re: ListView PROBLEM

01 Aug 2020, 06:11

OK. I think I understand. The first thing to do is add a text column indicating which icon is added. The width of that column can be set to zero so that it’s not visible to the user. Like this (not tested):

Code: Select all

;- ListView PROBLEM 
;- https://www.autohotkey.com/boards/viewtopic.php?f=76&t=79296

#Warn
#NoEnv
SetWorkingDir,%A_ScriptDir% 
;---------
MainWindowTitle=LV_ARROW_PICTURE
Waypoint := 0
Fx=%a_scriptdir%\%mainwindowtitle%_INI.txt
dlm:=";"
c1:=""
;---------
Gui,1:default
Gui, Add, Tab2, +BackgroundTrans x-3 y0 h408 w650, Waypoints|Configurações
Gui, Add, GroupBox, x2 y50 w650 h500 , Bush Colector
Gui, Add, ListView, x12 y109 w480 h290 vWaypoint,  Waypoint|Action|Bush Direction|IconText
LV_ModifyCol(1, 50), LV_ModifyCol(2, 100), LV_ModifyCol(3, 150)
LV_ModifyCol(4, 0)
Gui, Add, DropDownList, x502 y289 w140 h100 vATITUDE,  Andar|Coletar
Gui, Add, Button, x502 y189 w40 h30 gWEST , WEST
Gui, Add, Button, x552 y159 w40 h30 gNORTH, NORT
Gui, Add, Button, x602 y189 w40 h30 gEAST , EAST
Gui, Add, Button, x552 y219 w40 h30 gSOUTH, SOUT
Gui, Show, x322 y263 h408 w650,%MainWindowTitle%
GuiControl,1: ChooseString,atitude,Coletar
ImageListID := IL_Create(10)
LV_SetImageList(ImageListID)
IL_Add(ImageListID, "NORTH.ico")
IL_Add(ImageListID, "SOUTH.ico")
IL_Add(ImageListID, "WEST.ico")
IL_Add(ImageListID, "EAST.ico")
/*
IL_Add(ImageListID, "files\marks\arrowN_16x16.ico")
IL_Add(ImageListID, "files\marks\arrowS_16x16.ico")
IL_Add(ImageListID, "files\marks\arrowW_16x16.ico")
IL_Add(ImageListID, "files\marks\arrowE_16x16.ico")
*/
gosub,fill
Return
;---------------------
GuiClose:
Gui,1:submit,nohide
ControlGet, Listx, List, , SysListView321,%mainwindowtitle%
if listx<>
 {
 stringreplace,listx,listx,`t,%dlm%,all
 ifexist,%fx%
    filedelete,%fx%
 fileappend,%listx%,%fx%
 listx=
 }
ExitApp
;---------------------
;-------------- Fill Listview xy.CSV -----------
Fill:
Gui,1:submit,nohide
LV_Delete()
FileRead,aac,  *P65001 %fx%
for each, Line in StrSplit(aac, "`n", "`r")
{
if line=
  continue
  c1=
  c2=
  c3=
  stringsplit,C,line,%dlm%
  c1=%c1%
  c2=%c2%
  c3=%c3%
  if (c3="NORTH")
    LV_Add("icon1",c1,c2,c3,1)
  if (c3="SOUTH")
    LV_Add("icon2",c1,c2,c3,2)
  if (c3="WEST")
    LV_Add("icon3",c1,c2,c3,3)
  if (c3="EAST")
    LV_Add("icon4",c1,c2,c3,4)
  }
waypoint:=C1
return
;----------------------------------------------------
NORTH:
gui, submit, nohide
Action = %ATITUDE%
Bush_Direction = NORTH
Waypoint += 1
LV_Add("icon1",Waypoint,Action,Bush_Direction,1)
Return
;---------------------
SOUTH:
gui, submit, nohide
Action = %ATITUDE%
Bush_Direction = SOUTH
Waypoint += 1
LV_Add("icon2",Waypoint,Action,Bush_Direction,2)
Return
;---------------------
WEST:
gui, submit, nohide
Action = %ATITUDE%
Bush_Direction = WEST
Waypoint += 1
LV_Add("icon3",Waypoint,Action,Bush_Direction,3)
Return
;---------------------
EAST:
gui, submit, nohide
Action = %ATITUDE%
Bush_Direction = EAST
Waypoint += 1
LV_Add("icon4",Waypoint,Action,Bush_Direction,4)
Return
;============================================================================
garry
Posts: 3758
Joined: 22 Dec 2013, 12:50

Re: ListView PROBLEM

01 Aug 2020, 07:51

@boiler
Feel free to accept the offer to be hired for additional work if you would like.

I try to help, if I can ... but this seems for me difficult ...
Thank you for your many professional scripts and big help
henriquehassi
Posts: 24
Joined: 29 Jul 2020, 17:11

Re: ListView PROBLEM

01 Aug 2020, 11:07

@boiler
@garry
I am finalizing some steps of the project to bring you more concrete things, so far you have given me great tips and assistance, please don’t give up on me hahahhaha, in a few minutes I’ll attach the improved project here, I made some advances with the last tip you gave me to attach each mark in 1 number :)

@EDIT@ 13:54

here is the code with some other modifications and advances

Code: Select all

;- ListView PROBLEM 
;- https://www.autohotkey.com/boards/viewtopic.php?f=76&t=79296

#Warn
#NoEnv
SetWorkingDir,%A_ScriptDir% 
;---------
MainWindowTitle=LV_ARROW_PICTURE
Waypoint := 0
Fx=%a_scriptdir%\%mainwindowtitle%_INI.txt
dlm:=";"
c1:=""
;---------
Gui,1:default
Gui, Add, Tab2, +BackgroundTrans x-3 y0 h408 w650, Waypoints|Configurações
Gui, Add, GroupBox, x2 y50 w650 h500 , Bush Colector
Gui, Add, ListView, x12 y109 w480 h290 vWaypoint,  Waypoint|Action|Bush Direction|IconText
LV_ModifyCol(1, 50), LV_ModifyCol(2, 100), LV_ModifyCol(3, 150)
LV_ModifyCol(4, 0)
Gui, Add, DropDownList, x502 y289 w140 h100 vATITUDE, Coletar
Gui, Add, Button, x502 y189 w40 h30 gWEST , WEST
Gui, Add, Button, x552 y159 w40 h30 gNORTH, NORT
Gui, Add, Button, x552 y100 w40 h30 gWALK_WP, WALK
Gui, Add, Button, x602 y189 w40 h30 gEAST , EAST
Gui, Add, Button, x552 y219 w40 h30 gSOUTH, SOUT
Gui, Show, x322 y263 h408 w650,%MainWindowTitle%
GuiControl,1: ChooseString,atitude,Coletar
ImageListID := IL_Create(10)
LV_SetImageList(ImageListID)
IL_Add(ImageListID, "files/marks/mark1.png")
IL_Add(ImageListID, "files/marks/mark2.png")
IL_Add(ImageListID, "files/marks/mark3.png")
IL_Add(ImageListID, "files/marks/mark4.png")
IL_Add(ImageListID, "files/marks/mark5.png")
IL_Add(ImageListID, "files/marks/mark6.png")
IL_Add(ImageListID, "files/marks/mark7.png")
IL_Add(ImageListID, "files/marks/mark8.png")
IL_Add(ImageListID, "files/marks/mark9.png")
IL_Add(ImageListID, "files/marks/mark10.png")
IL_Add(ImageListID, "files/marks/mark11.png")
IL_Add(ImageListID, "files/marks/mark12.png")
IL_Add(ImageListID, "files/marks/mark13.png")
IL_Add(ImageListID, "files/marks/mark14.png")
IL_Add(ImageListID, "files/marks/mark15.png")
IL_Add(ImageListID, "files/marks/mark16.png")
IL_Add(ImageListID, "files/marks/mark17.png")
IL_Add(ImageListID, "files/marks/mark18.png")
IL_Add(ImageListID, "files/marks/mark19.png")
IL_Add(ImageListID, "files/marks/mark20.png")
IL_Add(ImageListID, "files/marks/mark21.png")
/*
IL_Add(ImageListID, "files\marks\arrowN_16x16.ico")
IL_Add(ImageListID, "files\marks\arrowS_16x16.ico")
IL_Add(ImageListID, "files\marks\arrowW_16x16.ico")
IL_Add(ImageListID, "files\marks\arrowE_16x16.ico")
*/
gosub,fill
Return
;---------------------
GuiClose:
Gui,1:submit,nohide
ControlGet, Listx, List, , SysListView321,%mainwindowtitle%
if listx<>
 {
 stringreplace,listx,listx,`t,%dlm%,all
 ifexist,%fx%
    filedelete,%fx%
 fileappend,%listx%,%fx%
 listx=
 }
ExitApp
;---------------------
;-------------- Fill Listview xy.CSV -----------
Fill:
Gui,1:submit,nohide
LV_Delete()
FileRead,aac,  *P65001 %fx%
for each, Line in StrSplit(aac, "`n", "`r")
{
if line=
  continue
  c1=
  c2=
  c3=
  c4=
  stringsplit,C,line,%dlm%
  c1=%c1%
  c2=%c2%
  c3=%c3%
  c4=%c4%
if (c3="WALK")
{ 
if (c4 = 1)
    LV_Add("icon1",c1,c2,c3,c4)
    if (c4 = 2)
     LV_Add("icon2",c1,c2,c3,c4)
       if (c4 = 3)
     LV_Add("icon3",c1,c2,c3,c4)
       if (c4 = 4)
     LV_Add("icon4",c1,c2,c3,c4)
       if (c4 = 5)
     LV_Add("icon5",c1,c2,c3,c4)
       if (c4 = 6)
     LV_Add("icon6",c1,c2,c3,c4)
       if (c4 = 7)
     LV_Add("icon7",c1,c2,c3,c4)
       if (c4 = 8)
     LV_Add("icon8",c1,c2,c3,c4)
       if (c4 = 9)
     LV_Add("icon9",c1,c2,c3,c4)
       if (c4 = 10)
     LV_Add("icon10",c1,c2,c3,c4)
       if (c4 = 11)
     LV_Add("icon11",c1,c2,c3,c4)
       if (c4 = 12)
     LV_Add("icon12",c1,c2,c3,c4)
       if (c4 = 13)
     LV_Add("icon13",c1,c2,c3,c4)
       if (c4 = 14)
     LV_Add("icon14",c1,c2,c3,c4)
       if (c4 = 15)
     LV_Add("icon15",c1,c2,c3,c4)
       if (c4 = 16)
     LV_Add("icon16",c1,c2,c3,c4)
       if (c4 = 17)
     LV_Add("icon17",c1,c2,c3,c4)
       if (c4 = 18)
     LV_Add("icon18",c1,c2,c3,c4)
       if (c4 = 19)
     LV_Add("icon19",c1,c2,c3,c4)
       if (c4 = 20)
     LV_Add("icon20",c1,c2,c3,c4)
    } 
  if (c3="NORTH")
    LV_Add("icon21",c1,c2,c3,c4)
  if (c3="SOUTH")
    LV_Add("icon21",c1,c2,c3,c4)
  if (c3="WEST")
    LV_Add("icon21",c1,c2,c3,c4)
  if (c3="EAST")
    LV_Add("icon21",c1,c2,c3,c4)
  }
waypoint:=C1
return
;----------------------------------------------------


WALK_WP:
Gui, 2:Add, GroupBox, x2 y-1 w510 h120 , Choose your mark
Gui, 2:Add, Picture, x12 y19 w40 h40 gAdd_Walk_Mark01, %A_ScriptDir%\files\Marks\mark1.png
Gui, 2:Add, Picture, x62 y19 w40 h40 gAdd_Walk_Mark02, %A_ScriptDir%\files\Marks\mark2.png
Gui, 2:Add, Picture, x112 y19 w40 h40 gAdd_Walk_Mark03, %A_ScriptDir%\files\Marks\mark3.png
Gui, 2:Add, Picture, x162 y19 w40 h40 gAdd_Walk_Mark04, %A_ScriptDir%\files\Marks\mark4.png
Gui, 2:Add, Picture, x212 y19 w40 h40 gAdd_Walk_Mark05, %A_ScriptDir%\files\Marks\mark5.png
Gui, 2:Add, Picture, x262 y19 w40 h40 gAdd_Walk_Mark06, %A_ScriptDir%\files\Marks\mark6.png
Gui, 2:Add, Picture, x312 y19 w40 h40 gAdd_Walk_Mark07, %A_ScriptDir%\files\Marks\mark7.png
Gui, 2:Add, Picture, x362 y19 w40 h40 gAdd_Walk_Mark08, %A_ScriptDir%\files\Marks\mark8.png
Gui, 2:Add, Picture, x412 y19 w40 h40 gAdd_Walk_Mark09, %A_ScriptDir%\files\Marks\mark9.png
Gui, 2:Add, Picture, x462 y19 w40 h40 gAdd_Walk_Mark10, %A_ScriptDir%\files\Marks\mark10.png
Gui, 2:Add, Picture, x12 y69 w40 h40 gAdd_Walk_Mark11, %A_ScriptDir%\files\Marks\mark11.png
Gui, 2:Add, Picture, x62 y69 w40 h40 gAdd_Walk_Mark12, %A_ScriptDir%\files\Marks\mark12.png
Gui, 2:Add, Picture, x112 y69 w40 h40 gAdd_Walk_Mark13, %A_ScriptDir%\files\Marks\mark13.png
Gui, 2:Add, Picture, x162 y69 w40 h40 gAdd_Walk_Mark14, %A_ScriptDir%\files\Marks\mark14.png
Gui, 2:Add, Picture, x212 y69 w40 h40 gAdd_Walk_Mark15, %A_ScriptDir%\files\Marks\mark15.png
Gui, 2:Add, Picture, x262 y69 w40 h40 gAdd_Walk_Mark16, %A_ScriptDir%\files\Marks\mark16.png
Gui, 2:Add, Picture, x312 y69 w40 h40 gAdd_Walk_Mark17, %A_ScriptDir%\files\Marks\mark17.png
Gui, 2:Add, Picture, x362 y69 w40 h40 gAdd_Walk_Mark18, %A_ScriptDir%\files\Marks\mark18.png
Gui, 2:Add, Picture, x412 y69 w40 h40 gAdd_Walk_Mark19, %A_ScriptDir%\files\Marks\mark19.png
Gui, 2:Add, Picture, x462 y69 w40 h40 gAdd_Walk_Mark20, %A_ScriptDir%\files\Marks\mark20.png
Gui, 2:Show, x147 y105 h126 w519, Choose your Mark
Return




NORTH:
gui, submit, nohide
Action = %ATITUDE%
Bush_Direction = NORTH
Waypoint += 1
Gui, 1:Default
Gui, 1:ListView, Waypoint
LV_Add("icon21",Waypoint,Action,Bush_Direction,21)
Return
;---------------------
SOUTH:
gui, submit, nohide
Action = %ATITUDE%
Bush_Direction = SOUTH
Waypoint += 1
LV_Add("icon21",Waypoint,Action,Bush_Direction,21)
Return
;---------------------
WEST:
gui, submit, nohide
Action = %ATITUDE%
Bush_Direction = WEST
Waypoint += 1
LV_Add("icon21",Waypoint,Action,Bush_Direction,21)
Return
;---------------------
EAST:
gui, submit, nohide
Action = %ATITUDE%
Bush_Direction = EAST
Waypoint += 1
LV_Add("icon21",Waypoint,Action,Bush_Direction,21)
Return
;============================================================================




Add_Walk_Mark01:
gui, 2: Destroy
Action = Walk
Bush_Direction = Walk
Waypoint += 1
Gui, 1:Default
Gui, 1:ListView, Waypoint
LV_Add("icon1",Waypoint,Action,Bush_Direction,1)
return
Add_Walk_Mark02:
gui, 2: Destroy
Action = Walk
Bush_Direction = Walk
Waypoint += 1
Gui, 1:Default
Gui, 1:ListView, Waypoint
LV_Add("icon2",Waypoint,Action,Bush_Direction,2)
return
Add_Walk_Mark03:
gui, 2: Destroy
Action = Walk
Bush_Direction = Walk
Waypoint += 1
Gui, 1:Default
Gui, 1:ListView, Waypoint
LV_Add("icon3",Waypoint,Action,Bush_Direction,3)
return
Add_Walk_Mark04:
gui, 2: Destroy
Action = Walk
Bush_Direction = Walk
Waypoint += 1
Gui, 1:Default
Gui, 1:ListView, Waypoint
LV_Add("icon4",Waypoint,Action,Bush_Direction,4)
return
Add_Walk_Mark05:
gui, 2: Destroy
Action = Walk
Bush_Direction = Walk
Waypoint += 1
Gui, 1:Default
Gui, 1:ListView, Waypoint
LV_Add("icon5",Waypoint,Action,Bush_Direction,5)
return
Add_Walk_Mark06:
gui, 2: Destroy
Action = Walk
Bush_Direction = Walk
Waypoint += 1
Gui, 1:Default
Gui, 1:ListView, Waypoint
LV_Add("icon6",Waypoint,Action,Bush_Direction,6)
return
Add_Walk_Mark07:
gui, 2: Destroy
Action = Walk
Bush_Direction = Walk
Waypoint += 1
Gui, 1:Default
Gui, 1:ListView, Waypoint
LV_Add("icon7",Waypoint,Action,Bush_Direction,7)
return
Add_Walk_Mark08:
gui, 2: Destroy
Action = Walk
Bush_Direction = Walk
Waypoint += 1
Gui, 1:Default
Gui, 1:ListView, Waypoint
LV_Add("icon8",Waypoint,Action,Bush_Direction,8)
return
Add_Walk_Mark09:
gui, 2: Destroy
Action = Walk
Bush_Direction = Walk
Waypoint += 1
Gui, 1:Default
Gui, 1:ListView, Waypoint
LV_Add("icon9",Waypoint,Action,Bush_Direction,9)
return
Add_Walk_Mark10:
gui, 2: Destroy
Action = Walk
Bush_Direction = Walk
Waypoint += 1
Gui, 1:Default
Gui, 1:ListView, Waypoint
LV_Add("icon10",Waypoint,Action,Bush_Direction,10)
return
Add_Walk_Mark11:
gui, 2: Destroy
Action = Walk
Bush_Direction = Walk
Waypoint += 1
Gui, 1:Default
Gui, 1:ListView, Waypoint
LV_Add("icon11",Waypoint,Action,Bush_Direction,11)
return
Add_Walk_Mark12:
gui, 2: Destroy
Action = Walk
Bush_Direction = Walk
Waypoint += 1
Gui, 1:Default
Gui, 1:ListView, Waypoint
LV_Add("icon12",Waypoint,Action,Bush_Direction,12)
return
Add_Walk_Mark13:
gui, 2: Destroy
Action = Walk
Bush_Direction = Walk
Waypoint += 1
Gui, 1:Default
Gui, 1:ListView, Waypoint
LV_Add("icon13",Waypoint,Action,Bush_Direction,13)
return
Add_Walk_Mark14:
gui, 2: Destroy
Action = Walk
Bush_Direction = Walk
Waypoint += 1
Gui, 1:Default
Gui, 1:ListView, Waypoint
LV_Add("icon14",Waypoint,Action,Bush_Direction,14)
return
Add_Walk_Mark15:
gui, 2: Destroy
Action = Walk
Bush_Direction = Walk
Waypoint += 1
Gui, 1:Default
Gui, 1:ListView, Waypoint
LV_Add("icon15",Waypoint,Action,Bush_Direction,15)
return
Add_Walk_Mark16:
gui, 2: Destroy
Action = Walk
Bush_Direction = Walk
Waypoint += 1
Gui, 1:Default
Gui, 1:ListView, Waypoint
LV_Add("icon16",Waypoint,Action,Bush_Direction,16)
return
Add_Walk_Mark17:
gui, 2: Destroy
Action = Walk
Bush_Direction = Walk
Waypoint += 1
Gui, 1:Default
Gui, 1:ListView, Waypoint
LV_Add("icon17",Waypoint,Action,Bush_Direction,17)
return
Add_Walk_Mark18:
gui, 2: Destroy
Action = Walk
Bush_Direction = Walk
Waypoint += 1
Gui, 1:Default
Gui, 1:ListView, Waypoint
LV_Add("icon18",Waypoint,Action,Bush_Direction,18)
return
Add_Walk_Mark19:
gui, 2: Destroy
Action = Walk
Bush_Direction = Walk
Waypoint += 1
Gui, 1:Default
Gui, 1:ListView, Waypoint
LV_Add("icon19",Waypoint,Action,Bush_Direction,19)
return
Add_Walk_Mark20:
gui, 2: Destroy
Action = Walk
Bush_Direction = Walk
Waypoint += 1
Gui, 1:Default
Gui, 1:ListView, Waypoint
LV_Add("icon20",Waypoint,Action,Bush_Direction,20)
return





2GuiClose:
Gui, 2: Destroy
return

I made some modifications and improvements, making it now read all the waypoints and their respective icons using what he told me to make each icon a number.

now the interface is a little better, I created a button only for the function "walk" now the buttons "north, south, east, west" are only used to designate the direction of the collection, and I attached to them any image representing the collection of the Bush.

now comes the next step and is the one where I really have no idea how to do it.

in my conception the interface is in a reasonable way, I can do some tests and I believe that the improvements I can make myself.

but the part of the code to make it all work the way I want ingame I still have some doubts and I hope you can help me hahahaha I know the topic is extending but I don't have as much knowledge as yours

come on, I'll make the icons available to download if you want to open the file and understand how it looks on the interface.

I will put an image here to represent an ipotese

ahk help.png
ahk help.png (39.94 KiB) Viewed 4662 times

right, I made some notes in the image to help you understand the logic behind the execution, but I have no idea how to make the code identify the actions and everything, could you please help me ?? I know I'm asking for too much already, but this is very important to me and I don't want you to think I'm lazy, I'm really trying but all attempts go wrong

https www.mediafire.com /file/i96pstmp0571wef/file Broken Link for safety < downloading the interface images, just place the files folder inside the script directory
User avatar
boiler
Posts: 16902
Joined: 21 Dec 2014, 02:44

Re: ListView PROBLEM

01 Aug 2020, 21:33

Before continuing, as I continue to advise on this, it would be better not to have repeated code and instead use loops with variables to collapse it into more compact code. This will make it easier to implement changes and not have to repeat the changes 20 times each, which can lead to errors. I also updated the indenting to make it easier to follow the logic and program structure. Can you test and let me know if you agree with changing to this approach? Please note other comments as well and reply as appropriate.

Code: Select all

;- ListView PROBLEM 
;- https://www.autohotkey.com/boards/viewtopic.php?f=76&t=79296

#Warn
#NoEnv
SetWorkingDir,%A_ScriptDir% 
;---------
MainWindowTitle=LV_ARROW_PICTURE
Waypoint := 0
Fx=%a_scriptdir%\%mainwindowtitle%_INI.txt
dlm:=";"
c1:=""
;---------
Gui,1:default
Gui, Add, Tab2, +BackgroundTrans x-3 y0 h408 w650, Waypoints|Configurações
Gui, Add, GroupBox, x2 y50 w650 h500 , Bush Colector
Gui, Add, ListView, x12 y109 w480 h290 vWaypoint,  Waypoint|Action|Bush Direction|IconText
LV_ModifyCol(1, 50), LV_ModifyCol(2, 100), LV_ModifyCol(3, 150)
LV_ModifyCol(4, 0)
Gui, Add, DropDownList, x502 y289 w140 h100 vATITUDE, Coletar
Gui, Add, Button, x502 y189 w40 h30 gWEST , WEST
Gui, Add, Button, x552 y159 w40 h30 gNORTH, NORT
Gui, Add, Button, x552 y100 w40 h30 gWALK_WP, WALK
Gui, Add, Button, x602 y189 w40 h30 gEAST , EAST
Gui, Add, Button, x552 y219 w40 h30 gSOUTH, SOUT
Gui, Show, x322 y263 h408 w650,%MainWindowTitle%
GuiControl,1: ChooseString,atitude,Coletar
ImageListID := IL_Create(10)
LV_SetImageList(ImageListID)
loop, 21 ; replaces the 21 lines
	IL_Add(ImageListID, "files/marks/mark" . A_Index . ".png")
/*
IL_Add(ImageListID, "files\marks\arrowN_16x16.ico")
IL_Add(ImageListID, "files\marks\arrowS_16x16.ico")
IL_Add(ImageListID, "files\marks\arrowW_16x16.ico")
IL_Add(ImageListID, "files\marks\arrowE_16x16.ico")
*/
gosub,fill
Return
;---------------------
GuiClose:
	Gui,1:submit,nohide
	ControlGet, Listx, List, , SysListView321,%mainwindowtitle%
	if listx<>
	{
		stringreplace,listx,listx,`t,%dlm%,all
		ifexist,%fx%
			filedelete,%fx%
		fileappend,%listx%,%fx%
		listx=
	}
ExitApp
;---------------------
;-------------- Fill Listview xy.CSV -----------
Fill:
	Gui,1:submit,nohide
	LV_Delete()
	FileRead,aac,  *P65001 %fx%
	for each, Line in StrSplit(aac, "`n", "`r")
	{
		if line=
			continue
		c1=
		c2=
		c3=
		c4=
		stringsplit,C,line,%dlm%
		c1=%c1% ; <<< what are these meant to accomplish?
		c2=%c2%
		c3=%c3%
		c4=%c4%
		if (c3="WALK")
			LV_Add("icon" . c4, c1, c2, c3, c4) ; this replaces all 20 of the if statements
		if (c3="NORTH")
			LV_Add("icon21",c1,c2,c3,c4)
		if (c3="SOUTH")
			LV_Add("icon21",c1,c2,c3,c4)
		if (c3="WEST")
			LV_Add("icon21",c1,c2,c3,c4)
		if (c3="EAST")
			LV_Add("icon21",c1,c2,c3,c4)
	}
	waypoint:=C1
return
;----------------------------------------------------


WALK_WP:
	Gui, 2:Add, GroupBox, x2 y-1 w510 h120 , Choose your mark
	loop, 20 ; replaces 20 separate Gui Add lines
		Gui, 2:Add, Picture, % "x" . (12 + 50 * (Mod(A_Index - 1, 10))) . " y19 w40 h40 gAdd_Walk_Mark" . (A_Index < 10 ? "0" : "") . A_Index, %A_ScriptDir%\files\Marks\mark%A_Index%.png
	Gui, 2:Show, x147 y105 h126 w519, Choose your Mark
Return



; verify that this works:
NORTH:
SOUTH:
WEST:
EAST:
	gui, submit, nohide
	Action = %ATITUDE%
	Bush_Direction = %A_ThisLabel% ; A_ThisLabel will be NORTH, SOUTH, WEST, EAST depending on which was called
	Waypoint += 1
	Gui, 1:Default
	Gui, 1:ListView, Waypoint
	LV_Add("icon21",Waypoint,Action,Bush_Direction,21)
Return
;============================================================================




Add_Walk_Mark01:
Add_Walk_Mark02:
Add_Walk_Mark03:
Add_Walk_Mark04:
Add_Walk_Mark05:
Add_Walk_Mark06:
Add_Walk_Mark07:
Add_Walk_Mark08:
Add_Walk_Mark09:
Add_Walk_Mark10:
Add_Walk_Mark11:
Add_Walk_Mark12:
Add_Walk_Mark13:
Add_Walk_Mark14:
Add_Walk_Mark15:
Add_Walk_Mark16:
Add_Walk_Mark17:
Add_Walk_Mark18:
Add_Walk_Mark19:
Add_Walk_Mark20:
	IconNum := LTrim(SubStr(A_ThisLabel, -1), "0") ; get the last 2 characters of A_ThisLabel and strip off leading 0
	gui, 2: Destroy
	Action = Walk
	Bush_Direction = Walk
	Waypoint += 1
	Gui, 1:Default
	Gui, 1:ListView, Waypoint
	LV_Add("icon" . IconNum,Waypoint,Action,Bush_Direction,IconNum)
return




2GuiClose:
	Gui, 2: Destroy
return
henriquehassi
Posts: 24
Joined: 29 Jul 2020, 17:11

Re: ListView PROBLEM

03 Aug 2020, 14:43

@boiler

Oops, sorry for the delay, you really made some good changes, and I did a few more to add all the images, now the interface itself is ok, now I'm in the stage of making the information read in the listview and reproduce according to what is over there


you can see this image to understand more or less what I want to do
ahk help.png
ahk help.png (39.94 KiB) Viewed 3591 times
I made several comments inside the script so that you can try to follow the logic I'm working on, but feel free to show a better way, because it sucks what I'm doing, you're saving me a lot

Code: Select all

;- ListView PROBLEM 
;- https://www.autohotkey.com/boards/viewtopic.php?f=76&t=79296

#Warn
#NoEnv
SetWorkingDir,%A_ScriptDir% 
;---------
MainWindowTitle=LV_ARROW_PICTURE
Waypoint := 0
Fx=%a_scriptdir%\%mainwindowtitle%_INI.txt
dlm:=";"
c1:=""
c2:=""
c3:=""
c4:=""
;---------
Gui,1:default
Gui, Add, Tab2, +BackgroundTrans x-3 y0 h408 w650, Waypoints|Configurações
Gui, Add, GroupBox, x2 y50 w650 h500 , Bush Colector
Gui, Add, ListView, x12 y109 w480 h290 vWaypoint,  Waypoint|Action|Bush Direction|IconText
LV_ModifyCol(1, 50), LV_ModifyCol(2, 100), LV_ModifyCol(3, 150)
LV_ModifyCol(4, 0)
Gui, Add, DropDownList, x502 y289 w140 h100 vATITUDE, Coletar
Gui, Add, Button, x502 y350 w40 h30 gSTART_TEST , START
Gui, Add, Button, x502 y189 w40 h30 gWEST , WEST
Gui, Add, Button, x552 y159 w40 h30 gNORTH, NORT
Gui, Add, Button, x552 y100 w40 h30 gWALK_WP, WALK
Gui, Add, Button, x602 y189 w40 h30 gEAST , EAST
Gui, Add, Button, x552 y219 w40 h30 gSOUTH, SOUT
Gui, Show, x322 y263 h408 w650,%MainWindowTitle%
GuiControl,1: ChooseString,atitude,Coletar
ImageListID := IL_Create(10)
LV_SetImageList(ImageListID)
loop, 21 ; replaces the 21 lines
	IL_Add(ImageListID, "files/marks/mark" . A_Index . ".png")
/*
IL_Add(ImageListID, "files\marks\arrowN_16x16.ico")
IL_Add(ImageListID, "files\marks\arrowS_16x16.ico")
IL_Add(ImageListID, "files\marks\arrowW_16x16.ico")
IL_Add(ImageListID, "files\marks\arrowE_16x16.ico")
*/
gosub,fill
Return
;---------------------
GuiClose:
	Gui,1:submit,nohide
	ControlGet, Listx, List, , SysListView321,%mainwindowtitle%
	if listx<>
	{
		stringreplace,listx,listx,`t,%dlm%,all
		ifexist,%fx%
			filedelete,%fx%
		fileappend,%listx%,%fx%
		listx=
	}
ExitApp
;---------------------
;-------------- Fill Listview xy.CSV -----------
Fill:
	Gui,1:submit,nohide
	LV_Delete()
	FileRead,aac,  *P65001 %fx%
	for each, Line in StrSplit(aac, "`n", "`r")
	{
		if line=
			continue
			Waypoint%c1%=%c1%
 			acao%c1%=%c2%
  			direcao%c1%=%c3%
  			mark%c1%=%c4%
		c1=
		c2=
		c3=
		c4=
		stringsplit,C,line,%dlm%
		c1=%c1% ; <<< what are these meant to accomplish?
		c2=%c2%
		c3=%c3%
		c4=%c4%
		if (c3="WALK")
			LV_Add("icon" . c4, c1, c2, c3, c4) ; this replaces all 20 of the if statements
		if (c3="NORTH")
			LV_Add("icon21",c1,c2,c3,c4)
		if (c3="SOUTH")
			LV_Add("icon21",c1,c2,c3,c4)
		if (c3="WEST")
			LV_Add("icon21",c1,c2,c3,c4)
		if (c3="EAST")
			LV_Add("icon21",c1,c2,c3,c4)
	}
	waypoint:=C1
return
;----------------------------------------------------


WALK_WP:
	Gui, 2:Add, GroupBox, x2 y-1 w510 h120 , Choose your mark
	loop, 10 ; ---> adds the first 10 images of the line
		Gui, 2:Add, Picture, % "x" . (12 + 50 * (Mod(A_Index - 1, 10))) . " y19 w40 h40 gAdd_Walk_Mark" . (A_Index < 10 ? "0" : "") . A_Index, %A_ScriptDir%\files\Marks\mark%A_Index%.png
	loop, 9 ; ---> add picture 11-19 in bottom line
	Gui, 2:Add, Picture, % "x" . (12 + 50 * (Mod(A_Index - 1, 10))) . " y69 w40 h40 gAdd_Walk_Mark1" . A_Index, %A_ScriptDir%\files\Marks\mark1%A_Index%.png
	;------ add picture 20
	Gui, 2:Add, Picture, x462 y69 w40 h40 gAdd_Walk_Mark20, %A_ScriptDir%\files\Marks\mark20.png
	Gui, 2:Show, x147 y105 h126 w519, Choose your Mark
Return



; verify that this works:   ---- > Works perfectly :_)
NORTH:
SOUTH:
WEST:
EAST:
	gui, submit, nohide
	Action = %ATITUDE%
	Bush_Direction = %A_ThisLabel% ; A_ThisLabel will be NORTH, SOUTH, WEST, EAST depending on which was called
	Waypoint += 1
	Gui, 1:Default
	Gui, 1:ListView, Waypoint
	LV_Add("icon21",Waypoint,Action,Bush_Direction,21)
Return
;============================================================================




Add_Walk_Mark01:
Add_Walk_Mark02:
Add_Walk_Mark03:
Add_Walk_Mark04:
Add_Walk_Mark05:
Add_Walk_Mark06:
Add_Walk_Mark07:
Add_Walk_Mark08:
Add_Walk_Mark09:
Add_Walk_Mark10:
Add_Walk_Mark11:
Add_Walk_Mark12:
Add_Walk_Mark13:
Add_Walk_Mark14:
Add_Walk_Mark15:
Add_Walk_Mark16:
Add_Walk_Mark17:
Add_Walk_Mark18:
Add_Walk_Mark19:
Add_Walk_Mark20:
	IconNum := LTrim(SubStr(A_ThisLabel, -1), "0") ; get the last 2 characters of A_ThisLabel and strip off leading 0
	gui, 2: Destroy
	Action = Walk
	Bush_Direction = Walk
	Waypoint += 1
	Gui, 1:Default
	Gui, 1:ListView, Waypoint
	LV_Add("icon" . IconNum,Waypoint,Action,Bush_Direction,IconNum)
return




;-------------- here is the first attempt to make everything work, but like I said
; I have no idea how to extract the information from the listview, so I used the label "fill" to attach the data of each column to a variable
;
;
;Waypoint%c1%=%c1%
;acao%c1%=%c2%
;direcao%c1%=%c3%
;mark%c1%=%c4%
;this means that i can consult any waypoint using several variables like "waypoint1" or "waypoint4" the values ​​will correspond to line 1 with the value of waypoint 1 and line 4 with the value of waypoint 4 respectively
;but I thought it was really bad, do you have any other ideas on how to execute the commands placed in the listview? going in order of each line, in line 1, will check the action of Listview "Waypoint" and will do something according to what is in "Action" after performing these 2 actions, will go to line 2, and so on

;little test, but fail
;I tried to create a system to advance the labels as actions were completed, but it’s totally wrong
START_TEST: 
loop
{ 
sleep, 100
WinActivate, PXG Client ahk_class pxgclient
ImageSearch, FoundX, FoundY, 1738, 89, 1920, 278, %A_ScriptDir%\files\Marks\Background\mark%mark1%.png
  if (acao1 = "Walk")
  {
  Click, %FoundX%, %FoundY%
  ImageSearch, FoundX, FoundY, 1738, 89, 1920, 278, %A_ScriptDir%\files\Marks\Background\mark%mark1%.png
  If ErrorLevel = 1
  { 
  acao1+=1
  mark1+=1
  }
  }
} 













2GuiClose:
	Gui, 2: Destroy
return

I tried to make it follow the logic of the listview, but it was very bad, any mistake it is totally lost, is there any way to help me? if it’s better for you to understand my final result, I can attach a video from youtube, where someone else used the auto hotkey to do what I want, the same way I’m creating, with listview etc., exactly the same, I believe that if you watch the video will perfectly understand what I seek to accomplish

obviously his is very complete, mine is much simpler, but even if the video is in portuguese, focus on what the program does



https://youtu.be/atf6wB6Qx7M?t=116 [Mod edit: Link fixed.]

in this part of the video you can see the listview, and later it puts everything to run, but in the game's minimap, the clicks it gives according to the information in the listview


can you help me? :)
User avatar
boiler
Posts: 16902
Joined: 21 Dec 2014, 02:44

Re: ListView PROBLEM

03 Aug 2020, 15:39

Thanks for putting together the information to try to help me understand your goal. Regarding creating code, your first effort needs to be trying to find out how to do something by reading the documentation and trying to implement it, then ask me if you get stuck. I know you tried to do that, but you made this comment in your script:

Code: Select all

; I have no idea how to extract the information from the listview, so I used the label "fill" to attach the data of each column to a variable
...and I would point out that the ListView documentation contains a section called Getting Data Out of a ListView, and it is only 3 lines long. And one of those lines says:
LV_GetText: Retrieves the text at the specified row and column.
...and another line in that section says that LV_GetCount() tells you how many rows there are in the ListView.

You should be seeing that and writing some code to try to extract the information, then ask if you run into problems. Here's a starting point for taking what we just saw and extracting info out of a ListView:

Code: Select all

loop, % LV_GetCount()
{
	LV_GetText(IconNum, A_Index, 4) ; A_Index is the row number, 4 is the column number
	; IconNum will contain the number of the icon because we put it in that column
	; you can get the info from the other columns the same way
	; you can either act on each piece of information within this loop, or you can save them to variables (an array of objects would be best) to use after you exit this loop.
}
I think that's what you said before -- that the ListView contains the actions that you want to take one-by-one, correct?

One other thing to note about your code. You have if (acao1 = "Walk") and then later you have acao1+=1, which adds 1 to the value contained in the variable acao1. If aca01 contains a word like "walk", how do you add 1 to it? Think about what the variables contain and what you are trying to change them to.
henriquehassi
Posts: 24
Joined: 29 Jul 2020, 17:11

Re: ListView PROBLEM

04 Aug 2020, 11:55

@boiler
and then Boiler, I again hahaha, so the project worked very well, I managed to perfectly reproduce all the actions thanks to you, now I want to add two new things


a way to delete waypoints, in case I add something wrong

and also a save / load system to be able to save and load waypoints, can you help me ???
User avatar
boiler
Posts: 16902
Joined: 21 Dec 2014, 02:44

Re: ListView PROBLEM

04 Aug 2020, 23:10

henriquehassi wrote: a way to delete waypoints, in case I add something wrong
If that's the same thing as deleting a row from the ListView, you can create a "Delete" button in your GUI (or a hotkey) that would call this subroutine to delete the selected row (the one that has "focus"):

Code: Select all

DeleteRow:
	MsgBox, 4132, Delete Row, Are you sure you want to delete the selected row?
	IfMsgBox, Yes
		LV_Delete(LV_GetNext(, "F"))
return


henriquehassi wrote: a save / load system to be able to save and load waypoints, can you help me ???
There is code in an earlier post from @garry that did that. You would just have to modify it a bit because we added a column since then, but that approach should work.
henriquehassi
Posts: 24
Joined: 29 Jul 2020, 17:11

Re: ListView PROBLEM

05 Aug 2020, 14:20

@boiler
yes, he posted for the script to load the last script, in case I wanted something like 1 button for me to select which of the files will be read at that moment, you know? for the user to create different Saves, and use each one at any time

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 51 guests