Sign in to follow this  
Followers 0
Forge

Where to declare it?

8 posts in this topic

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

Share this post


Link to post
Share on other sites



Don't worry.Put them anywhere.

Like the other functions you made.

Share this post


Link to post
Share on other sites

it gives the error that they aren't decleared.

Share this post


Link to post
Share on other sites

Error: Variable used without being declared.

Share this post


Link to post
Share on other sites

What is the complete error message?

Share this post


Link to post
Share on other sites

What do you want to do?

Because when you press SHIFT+F4(Left), of course, only $left is assigned.

$top, $down, $right aren't declared.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
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
Sign in to follow this  
Followers 0