What i'm trying to achieve: Using the same instance in the entire script.
What i'm trying to achieve but doesn't seem to work. Nothing seems to execute
Code: Select all
#NoEnv
#SingleInstance, Force
SendMode, Input
SetBatchLines, -1
SetWorkingDir, %A_ScriptDir%
#Include, GridClass.ahk
MyGrid := new Grid() ;i've tried making this global aswell, same outcome
func1() {
MyGrid.clickcell(5)
}
func2() {
MyGrid.ShowCoordinates()
}
func3() {
MyGrid.RandomPattern()
}
1::
func1()
return
2::
func2()
return
3::
func3()
return
Code: Select all
#NoEnv
#SingleInstance, Force
SendMode, Input
SetBatchLines, -1
SetWorkingDir, %A_ScriptDir%
#Include, GridClass.ahk
func1() {
MyGrid := new Grid()
MyGrid.clickcell(5)
}
func2() {
MyGrid := new Grid()
MyGrid.ShowCoordinates()
}
func3() {
MyGrid := new Grid()
MyGrid.RandomPattern()
}
1::
func1()
return
2::
func2()
return
3::
func3()
return
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance, Force
class Grid {
;other code in here;
ClickCell(cellNumber) {
}
RandomPattern() {
}
ShowCoordinates() {
}
}