Jump to content

Where to declare it?


Recommended Posts

Func Left()
$left = MouseGetPos()
EndFunc
Func Top()
$Top = MouseGetPos()
EndFunc
Func Down()
$Down = MouseGetPos()
EndFunc
Func Right()
$Right = MouseGetPos()
EndFunc
AutoItSetOption("SendKeyDelay", 10)
HotKeySet ("+{F1}", "StartScan")
HotKeySet ("+{F2}", "StopScan")
HotKeySet ("+{F3}", "ExitScanner")

HotKeySet ("+{F4}", "Left")
HotKeySet ("+{F5}", "Top")
HotKeySet ("+{F6}", "Down")
HotKeySet ("+{F7}", "Right")

While 1
Sleep (100)
Wend
Func StartScan()
ScanGreenhp()
sleep(20)
ScanMiddleGreenhp()
sleep(20)
ScanRedhp()
sleep(20)
AntiAFK()
sleep(20)
Endfunc

Func StopScan()
While 1
Sleep(6000)
WEnd
Endfunc

Func AntiAFK()
 send ("^{UP}")
 Sleep(100)
 send ("^{Down}")
Endfunc

Func ScanGreenHp()
Do
 $coord = PixelSearch( $left[1], $top[0], $down[0], $right[1], 0x00C400)
Until NOT @error
send ("{PRINTSCREEN}")
send ("^{L}")
MsgBox (0, "Logged!", "You logged at " & @Hour & ":" & @min & ":" & @sec & ". Screenshot available on clipboard (Open Paint and Ctrl-V)")
EndFunc

Func ScanMiddleGreenHp()
Do
 $coord = PixelSearch( $left[1], $top[0], $down[0], $right[1], 0x68C468)
Until NOT @error
send ("{PRINTSCREEN}")
send ("^{L}")
MsgBox (0, "Logged!", "You logged at " & @Hour & ":" & @min & ":" & @sec & ". Screenshot available on clipboard (Open Paint and Ctrl-V)")
EndFunc

Func ScanRedHp()
Do
 $coord = PixelSearch( $left[1], $top[0], $down[0], $right[1], 0x0000FF)
Until NOT @error
send ("{PRINTSCREEN}")
send ("^{L}")
MsgBox (0, "Logged!", "You logged at " & @Hour & ":" & @min & ":" & @sec & ". Screenshot available on clipboard (Open Paint and Ctrl-V)")
EndFunc
Func ExitScanner()
Msgbox (0, "Exit", "Exiting Forge AutoLog")
Exit
EndFunc

`Don't tell me the code is bad, I know. Just tell me where to put the functions Left() Right() Top() Down()..

Thank you

Link to comment
Share on other sites

it gives the error that they aren't decleared.

Which is normal as a variable has to be assigned/declared before usage.

Your code is definitetly working from AutoIt3 poit of view. when you hit the Shift+F4 key the Left() function is called and the array variable is initialize.

$left[0]=Xmouse position , $left[]=Ymouse position .

Your problem come from the fact that setting for the first time $left in the Function left() just set a local variable which is not visible in the main and in othe function.

You have to change $left= to global $left=

or to declare Global $left[2] ... at the beginning.

Link to comment
Share on other sites

Guest Guest

At the beggining use

Dim or Global, use Dim if you plain to use variables inside only the main script. Global if you need their value inside the Func also.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...