I have issue to deal with VarRef with instance parameters. In the ImageSearch I use local variables then I reatribute value to the parameters. Is there a way to get the VarRef of parameter like :
Code: Select all
ImageSearch( &Frame.FoundX, &Frame.FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, TSFrameTitlePath )
Code: Select all
#Requires AutoHotkey v2.0-beta
WindowTitle := "FrameName"
#HotIf WinActive(WindowTitle)
TSFrameTitlePath := "D:\Modding\Scripts\Auto\FrameTitle.bmp"
;Parameters
TSFrame := {}
TSFrame .FoundX := 0 ;311
TSFrame .FoundY := 0 ;168
TSFrame .FirstItemDX := 22 ;289
TSFrame .FirstItemDY := 177 ;345
TSFrame .CreateDX := 224 ;535
TSFrame .CreateDY := 603 ;771
SetFrameParameters(&TSFrame)
SelectFirstElement(&TSFrame)
SelectFirstElement(&Frame)
{
if( Frame.FoundX != 0 && Frame.FoundY != 0)
MouseMove((Frame.FoundX+Frame.FirstItemDX), (Frame.FoundY+Frame.FirstItemDY))
else
MsgBox("Woops.")
}
SetFrameParameters(&Frame)
{
WinActivate(WindowTitle)
;Frame location and widgets location
LFoundX := 0
LFoundY := 0
try
{
if( !ImageSearch( &LFoundX, &LFoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, TSFrameTitlePath) )
MsgBox("TSFrame not opend.")
else
Frame.FoundX := LFoundX
Frame.FoundY := LFoundY
}
catch as exc
MsgBox("Could not conduct the search due to the following error:`n" exc.Message)
}