Progress Background from associative array Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
HiSoKa
Posts: 480
Joined: 27 Jan 2020, 15:43

Progress Background from associative array

Post by HiSoKa » 05 Dec 2022, 08:40

Hello,
I am trying to retrieve the value of the progress color from the following array, but for some reason it is not working

Code: Select all

var := { VAR: {Color:"FF00FF"}}
for k, v in var
        Gui, Add, Progress,   Background%v.color%
Gui, Show

esc::
   ExitApp
But it works when I retrieve the color value from a normal variable as in the code below:

Code: Select all

Color := "FF00FF"
Gui, Add, Progress,  Background%color%
Gui, Show

esc::
   ExitApp
Is there a way to retrieve the color from the array as in the first code?

User avatar
mikeyww
Posts: 27115
Joined: 09 Sep 2014, 18:38

Re: Progress Background from associative array  Topic is solved

Post by mikeyww » 05 Dec 2022, 08:43

Code: Select all

var := {VAR: {Color:"FF00FF"}, VAR2: {Color: "FF2233"}}
For k, v in var
 Gui, Add, Progress, % "Background" v.Color
Gui, Show
Explained: Force an expression
An expression can be used in a parameter that does not directly support it (except OutputVar parameters) by preceding the expression with a percent sign and a space or tab. In [v1.1.21+], this prefix can be used in the InputVar parameters of all commands except the traditional IF commands (use If (expression) instead). This technique is often used to access arrays.

User avatar
HiSoKa
Posts: 480
Joined: 27 Jan 2020, 15:43

Re: Progress Background from associative array

Post by HiSoKa » 05 Dec 2022, 08:52

Thank you very much mickey for your quick reply, Problem solved :) :salute: .

Post Reply

Return to “Ask for Help (v1)”