Jump to content

ImageSearch - (Locked)


Recommended Posts

@FrancescoDiMuro

Yeh sorry xD

#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=..\vip.ico
#AutoIt3Wrapper_UseX64=y
#AutoIt3Wrapper_Run_Au3Stripper=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Array.au3>
#include <ImageSearch2015.au3>
#include <Date.au3>

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=c:\users\lok\documents\afk.kxf
$AntiAFK = GUICreate("AFK", 195, 212, -1, -1)
$logChat = GUICtrlCreateEdit("", 8, 8, 185, 201, BitOR($GUI_SS_DEFAULT_EDIT,$ES_READONLY))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


Global $a = 0
Global $b = 0
$x1 = 0
$y1 = 0
$refil = 0
Local $count = 0

$0l = "C:\Users\LoK\Desktop\ImageSearch\afkImg\0l.bmp"
$1l = "C:\Users\LoK\Desktop\ImageSearch\afkImg\1l.bmp"
$2l = "C:\Users\LoK\Desktop\ImageSearch\afkImg\2l.bmp"
$3l = "C:\Users\LoK\Desktop\ImageSearch\afkImg\3l.bmp"
$4l = "C:\Users\LoK\Desktop\ImageSearch\afkImg\4l.bmp"
$5l = "C:\Users\LoK\Desktop\ImageSearch\afkImg\5l.bmp"
$6l = "C:\Users\LoK\Desktop\ImageSearch\afkImg\6l.bmp"
$7l = "C:\Users\LoK\Desktop\ImageSearch\afkImg\7l.bmp"
$8l = "C:\Users\LoK\Desktop\ImageSearch\afkImg\8l.bmp"
$9l = "C:\Users\LoK\Desktop\ImageSearch\afkImg\9l.bmp"

$0r = "C:\Users\LoK\Desktop\ImageSearch\afkImg\0p.bmp"
$1r = "C:\Users\LoK\Desktop\ImageSearch\afkImg\1p.bmp"
$2r = "C:\Users\LoK\Desktop\ImageSearch\afkImg\2p.bmp"
$3r = "C:\Users\LoK\Desktop\ImageSearch\afkImg\3p.bmp"
$4r = "C:\Users\LoK\Desktop\ImageSearch\afkImg\4p.bmp"
$5r = "C:\Users\LoK\Desktop\ImageSearch\afkImg\5p.bmp"
$6r = "C:\Users\LoK\Desktop\ImageSearch\afkImg\6p.bmp"
$7r = "C:\Users\LoK\Desktop\ImageSearch\afkImg\7p.bmp"
$8r = "C:\Users\LoK\Desktop\ImageSearch\afkImg\8p.bmp"
$9r = "C:\Users\LoK\Desktop\ImageSearch\afkImg\9p.bmp"

$afkMenu = "C:\Users\LoK\Desktop\ImageSearch\afkImg\afkMenu.bmp"
$ForYourInfoWindow = "C:\Users\LoK\Desktop\ImageSearch\afkImg\ForYourInfo.bmp"
$backToHunt = "C:\Users\LoK\Desktop\ImageSearch\cataImg\backToHunt.bmp"
$leaveHunt = "C:\Users\LoK\Desktop\ImageSearch\cataImg\leaveHunt.bmp"
$taskWindow = "C:\Users\LoK\Desktop\ImageSearch\task\task.bmp"

Local $ImgArrayL[] = [$1l, $2l, $3l, $4l, $5l, $6l, $7l, $8l, $9l, $0l]
Local $ImgArrayR[] = [$1r, $2r, $3r, $4r, $5r, $6r, $7r, $8r, $9r, $0r]

Func Cancel($iRespand)
    If $iRespand = 2 Then
        Exit
    EndIf
EndFunc   ;==>Cancel

Func PressExit()
    Exit
EndFunc   ;==>PressExit

Func Answer()
    For $c = 0 To $a + $b - 2
        ControlSend("[CLASS:Client]", "", "", "{DOWN}")
    Next
    Sleep(200)
    ControlSend("[CLASS:Client]", "", "", "{ENTER}")
    Sleep(500)
    ControlSend("[CLASS:Client]", "", "", "{ENTER}")
EndFunc   ;==>Answer

Func Task($d)
    $count += 1
    For $c = 0 To $d
        ControlSend("[CLASS:Client]", "", "", "{DOWN}")
    Next
    Sleep(500)
    If WinActive("[CLASS:Client]", "") Then
        MouseClick("left", 1044, 662, 1, 0)
    Else
        WinActivate("[CLASS:Client]", "")
        Sleep(200)
        MouseClick("left", 1044, 662, 1, 0)
    EndIf
    Sleep(500)
    ControlSend("[CLASS:Client]", "", "", "{ENTER}")
    Sleep(2000)
    If $count < 3 Then
        ControlSend("[CLASS:Client]", "", "", "task")
        Sleep(200)
        ControlSend("[CLASS:Client]", "", "", "{ENTER}")
        Sleep(1000)
    ElseIf $count = 3 Then
        $count = 0
    EndIf
EndFunc   ;==>Task

#cs
    Func MoveMouse()
    local $temp = 0
    WinActivate("[CLASS:Client]", "")
    if ($a + $b) > 10 Then
    MouseClick("Left", 951, 527, 1)
    Sleep(200)
    MouseWheel("Down", 10)
    Sleep(1000)
    ElseIf ($a + $b) <= 10 Then
    $temp = $a + $b - 1
    Else
    $temp = $a + $b - 11
    EndIf
    MouseClick("left", 768, 470 + $temp * 14, 1)
    sleep(200)
    MouseMove(1137, 651)
    Sleep(200)
    MouseClick("left", 1137, 651, 1)
    Sleep(200)
    $ForYourInfo = _ImageSearchArea($ForYourInfoWindow, 1, 883, 460, 1046, 493, $x1, $y1, 40)
    If $ForYourInfo Then
    MouseClick("left", 1000, 583, 1)
    EndIf
    EndFunc
#ce

HotKeySet("+{ESC}", "PressExit")

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

    If ProcessExists("Tibia.exe") Then
        If WinGetState("[CLASS:Client]") = 39 Or WinGetState("[CLASS:Client]") = 47 Then
            Global $a = 0
            Global $b = 0
            $start = _ImageSearch($afkMenu, 1, $x1, $y1, 40) ; zmienić na area jak będe miał pos
            $leave = _ImageSearchArea($leaveHunt, 1, 1072, 598, 1248, 761, $x1, $y1, 40)
            $back = _ImageSearchArea($backToHunt, 1, 647, 485, 787, 612, $x1, $y1, 40)
            $task = _ImageSearchArea($taskWindow, 1, 797, 544, 861, 563, $x1, $y1, 40)
            ;$leave = _ImageSearch($leaveHunt, 1, $x1, $y1, 40)
            If $start Then
                Do
                    $result = _ImageSearchArea($ImgArrayL[$a], 1, 744, 437, 831, 468, $x1, $y1, 40)
                    ;$result = _ImageSearch($ImgArrayL[$a], 1, $x1, $y1, 40)
                    ;ConsoleWrite("A: " & $a + 1 & "   " & $result & @CRLF)
                    ;ConsoleWrite("Real a = " & $a & "   " & $result & @CRLF)
                    $a += 1
                    If ($a = 10) And ($result = 0) Then
                        $result = 1
                        $a = 0
                    EndIf
                Until $result = 1
                $result = 0
                Do
                    $result = _ImageSearchArea($ImgArrayR[$b], 1, 744, 437, 831, 468, $x1, $y1, 40)
                    ;$result = _ImageSearch($ImgArrayR[$b], 1, $x1, $y1, 40)
                    ;ConsoleWrite("Real b = " & $b & "   " & $result & @CRLF)
                    ;ConsoleWrite("B: " & $b + 1 & "   " & $result & @CRLF)
                    $b += 1
                    If ($b = 10) And ($result = 0) Then
                        $result = 1
                        $b = 0
                    EndIf
                Until $result = 1
                If ($a > 0) And ($b > 0) And ($a + $b >= 2) Then
                    GUICtrlSetData($logChat, _NowTime() & " Wynik: " & $a & " + " & $b & " = " & $a + $b & @CRLF, -1)
                    ;ConsoleWrite(_NowTime() & " Wynik: " & $a & " + " & $b & " = " & $a + $b & @CRLF)
                    Answer()
                ElseIf $a = 0 Or $b = 0 Then
                    If $a = 0 And $b = 0 Then
                        $iRespand = MsgBox(5, "Error!", "Script didn't recognize components of the sum.")
                        Cancel($iRespand)
                    ElseIf $a = 0 Then
                        $iRespand = MsgBox(5, "Error!", "Script didn't recognize 1st component of the sum.")
                        Cancel($iRespand)
                    ElseIf $b = 0 Then
                        $iRespand = MsgBox(5, "Error!", "Script didn't recognize 2nd component of the sum.")
                        Cancel($iRespand)
                    EndIf
                EndIf
            ElseIf $leave Then
                $refil += 1
                ControlSend("[CLASS:Client]", "", "", "{ENTER}")
                Sleep(500)
                ControlSend("[CLASS:Client]", "", "", "{DOWN}")
                Sleep(200)
                ControlSend("[CLASS:Client]", "", "", "{ENTER}")
                GUICtrlSetData($logChat, _NowTime() & " " & " Refil: " & $refil & @CRLF, -1)
                ;ConsoleWrite(_NowTime() & " " & " Refil: " & $refil & @CRLF)
            ElseIf $back Then
                ControlSend("[CLASS:Client]", "", "", "{DOWN}")
                Sleep(200)
                ControlSend("[CLASS:Client]", "", "", "{DOWN}")
                Sleep(200)
                ControlSend("[CLASS:Client]", "", "", "{DOWN}")
                Sleep(200)
                ControlSend("[CLASS:Client]", "", "", "{DOWN}")
                Sleep(200)
                ControlSend("[CLASS:Client]", "", "", "{ENTER}")
                Sleep(500)
                ControlSend("[CLASS:Client]", "", "", "{DOWN}")
                Sleep(200)
                ControlSend("[CLASS:Client]", "", "", "{DOWN}")
                Sleep(200)
                ControlSend("[CLASS:Client]", "", "", "{ENTER}")
                Sleep(500)
                ControlSend("[CLASS:Client]", "", "", "{ENTER}")
            ElseIf $task Then
                Task(4)
                Task(9)
                Task(10)
            EndIf
        EndIf
    EndIf
    Sleep(2000)
WEnd

I know it can be done better but well just started my fun with AutoIT few days ago.

Link to comment
Share on other sites

  • Developers

Welcome to the AutoIt forum.

Unfortunately you appear to have missed the Forum rules on your way in. Please read them now - particularly the bit about not discussing game automation - and then you will understand why you will get no help and this thread will now be locked.

See you soon with a legitimate question I hope.

The Moderation team

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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