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
Code: Select all
+a::
; 0x20138
james:= 0x170710
winname:=[]
winname[1]:= james
;MsgBox % winname[1]
WinActivate, ahk_id %winname[1]% ; %james% works!!
return
return
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: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.
Code: Select all
WinActivate, % "ahk_id " winname[1]
Thank you so much!!gregster wrote:Welcome to the forum!
To use an array variable directly in this context, you will have to force expression mode via % :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: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.Code: Select all
WinActivate, % "ahk_id " winname[1]
Users browsing this forum: mikeyww and 152 guests