Variable name inside a variable

Get help with using AutoHotkey and its commands and hotkeys
vdmir40
Posts: 1
Joined: 24 May 2020, 06:19

Variable name inside a variable

24 May 2020, 06:43

I tried googling it(and actually found one), but it was too hard to understand so I quickly created an account and I'm posting it.

I need to get multiple windows name in multiple variables, but since I can't put a variable name inside a variable, I don't know how I'm going to do it. doing %%varname%% doesn't work.

Code: Select all

...
WinCount = 1

; getting window name by pressing alt + a
!a::
WinGetTitle,%WinCount%,A ; Reason I used %WinCount%: to represent 1, I'll set it more and more 
MsgBox,,,Window name "%%WinCount%%" stored on var %WinCount%
WinCount = %WinCount% + 1
Basically the whole idea: I put the window title in a number which is 1 right now, and I press alt + a again and it stores the window name in 1 + 1 which is 2, and I wanted to make sure that it saves CORRECTLY. And the reason I'm doing this is there could be many names which have to be stored.
If the window name was Windows Explorer, I'm expecting something like this:

Code: Select all

Window name "Windows Explorer" stored on var 1
User avatar
boiler
Posts: 5554
Joined: 21 Dec 2014, 02:44

Re: Variable name inside a variable

24 May 2020, 06:53

Try this:

Code: Select all

WinCount := 1

; getting window name by pressing alt + a
!a::
WinGetTitle,%WinCount%,A ; Reason I used %WinCount%: to represent 1, I'll set it more and more 
MsgBox,,,% "Window name """ %WinCount% """ stored on var " WinCount
WinCount := WinCount + 1

Return to “Ask For Help”

Who is online

Users browsing this forum: eduardobedoya, Google [Bot], JKnight_xbt33 and 49 guests