Help about IniRead - If Var in

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
scriptors
Posts: 227
Joined: 25 Feb 2016, 09:01

Help about IniRead - If Var in

19 May 2021, 11:29

hi guys, some advice / help (just info I use AutoHotkey_H):

I have a macro that, before continuing, checks a series of colors (which unfortunately vary easily over time)
I would like to transfer the list of colors to a file.ini ....... and (but this will be a next step), when it happens that the color is not found, have a popup asking me whether to insert it in the list or not

I show you a piece of the script

Code: Select all

...
	WinGetPos, X, Y, , , " wname "
	xPixel := X + 415 ;screen coords X for chek
	yPixel := Y + 185 ;screen coords Y for chek
	Sleep 2000
;	IniRead, ColorList, C:\Users\scriptors\Desktop\NOX-AHK\SfondoPacchi.ini, SfondoPacchiStandard, colori
;	MsgBoX %ColorList% ; (NOT work)
	Loop
	{
		PixelGetColor, Res, %xPixel%, %yPixel%, RGB ; Note variable are calculated internally so %var%
		Sleep 50
;			if Res in ColorList
			if Res in 0x485662,0x485762,0x495762,0x495763,0x4A5863,0x444F5E,0x45515F,0x475661,0x485661,0x495662,0x4A5864,0x4C5968

				{ ; checks if GIFT PACK are finish
				break  ; Terminate the loop
				}
	Sleep 100
	SetControlDelay -1
	ControlClick, x470 y145, " wname ",,,, NA  
...
and this is .ini file

Code: Select all

[SfondoPacchiStandard]
colori=0x485662,0x485762,0x495762,0x495763,0x4A5863,0x444F5E,0x45515F,0x475661,0x485661,0x495662,0x4A5864,0x4C5968
User avatar
mikeyww
Posts: 27192
Joined: 09 Sep 2014, 18:38

Re: Help about IniRead - If Var in

19 May 2021, 11:46

To use the syntax with a variable, you can flank the variable in %. Example
scriptors
Posts: 227
Joined: 25 Feb 2016, 09:01

Re: Help about IniRead - If Var in

19 May 2021, 14:30

well, found first problem, the .ini file must have TEXT mode with quotes :oops:

[SfondoPacchiStandard]
colori="0x485662,0x485762,0x495762,0x495763,0x4A5863,0x444F5E,0x45515F,0x475661,0x485661,0x495662,0x4A5864,0x4C5968"

Code: Select all

...
	IniRead, ColorList, C:\Users\scriptors\Desktop\NOX-AHK\SfondoPacchi.ini, SfondoPacchiStandard, colori
	MsgBoX %ColorList% ; (NOW work)
...

Code: Select all

			if Res in %ColorList% ; (NOW work)
;			if Res in 0x485662,0x485762,0x495762,0x495763,0x4A5863,0x444F5E,0x45515F,0x475661,0x485661,0x495662,0x4A5864,0x4C5968

				{ ; checks if GIFT PACK are finish
				MsgBoX Color Found
				break  ; Terminate the loop
				}
of course you are right mikeyww :thumbup:

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 192 guests