how to activate window, unique id is stored in array [very simple code posted] Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
alware
Posts: 8
Joined: 01 Jun 2018, 02:25

how to activate window, unique id is stored in array [very simple code posted]

02 Jun 2018, 08:49

here is my code.. i want to activate the window but doesn't work when i put %winname[1]% instead of %james%
any help??

Code: Select all

+a::
; 0x20138
james:= 0x170710
winname:=[]
winname[1]:= james

;MsgBox % winname[1]
WinActivate, ahk_id %winname[1]% ; %james% works!!

return

return
gregster
Posts: 9096
Joined: 30 Sep 2013, 06:48

Re: how to activate window, unique id is stored in array [very simple code posted]  Topic is solved

02 Jun 2018, 14:31

Welcome to the forum!

To use an array variable directly in this context, you will have to force expression mode via % :
https://autohotkey.com/docs/Variables.htm#Expressions wrote: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.
Since ahk_id is no variable but literal text, you will have to put this string between quotation marks, if you use it in an expression:

Code: Select all

WinActivate, % "ahk_id " winname[1]
alware
Posts: 8
Joined: 01 Jun 2018, 02:25

Re: how to activate window, unique id is stored in array [very simple code posted]

06 Jun 2018, 02:20

gregster wrote:Welcome to the forum!

To use an array variable directly in this context, you will have to force expression mode via % :
https://autohotkey.com/docs/Variables.htm#Expressions wrote: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.
Since ahk_id is no variable but literal text, you will have to put this string between quotation marks, if you use it in an expression:

Code: Select all

WinActivate, % "ahk_id " winname[1]
Thank you so much!!

"ahk_id" part was the problems!! thx for help!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: mikeyww and 152 guests