Jump to content
Sign in to follow this  
ecstatic

Looping PixelSearch Not Working

Recommended Posts

ecstatic

Opt("WinWaitDelay",100)
Opt("WinTitleMatchMode",4)
Opt("WinDetectHiddenText",1)
Opt("MouseCoordMode",0)
AutoItSetOption ( "PixelCoordMode", 0 ); Do not change this parameter! It's needed for windowed D2.

$Monsters = 0xFF2C00

FUNC MonsterFinding()
Do
    $MonsterFind = PixelSearch( 0, 0, 800, 600,$Monsters)
If Not @error Then
    Sleep(50)
    MouseClick("right", $MonsterFind[0], $MonsterFind[1])
Until
$MonsterFind = PixelSearch( 0, 0, 800, 600,$Monsters) = @Error
Endif
    ENDFUNC

I am trying to make a function which will search for a diablo monster which has been modded orange (0xFF2C00) and it will shoot lightning (Mouse click right)

Until the monster is dead.

Which of my functions is incorrectly stated because it will not compile.

Thanks in advance

Edited by ecstatic

Share this post


Link to post
Share on other sites
zutto

Opt("WinWaitDelay",100)
Opt("WinTitleMatchMode",4)
Opt("WinDetectHiddenText",1)
Opt("MouseCoordMode",0)
AutoItSetOption ( "PixelCoordMode", 0 ); Do not change this parameter! It's needed for windowed D2.

$Monsters = 0xFF2C00

FUNC MonsterFinding()
Do
    $MonsterFind = PixelSearch( 0, 0, 800, 600,$Monsters)
If Not @error Then
    Sleep(50)
    MouseClick("right", $MonsterFind[0], $MonsterFind[1])
Until
$MonsterFind = PixelSearch( 0, 0, 800, 600,$Monsters) = @Error
Endif
    ENDFUNC

I am trying to make a function which will search for a diablo monster which has been modded orange (0xFF2C00) and it will shoot lightning (Mouse click right)

Until the monster is dead.

Which of my functions is incorrectly stated because it will not compile.

Thanks in advance

Until

$MonsterFind = PixelSearch( 0, 0, 800, 600,$Monsters) = @Error

should be

Until $MonsterFind = PixelSearch( 0, 0, 800, 600,$Monsters) = @Error

Edited by zutto

Share this post


Link to post
Share on other sites
ecstatic

thnx! that fixed one prob

Here are my compiling errors

C:\Documents and Settings\admin\Desktop\D2 Infinity\Other.au3(17,1) : ERROR: missing EndIf.
Until
^
C:\Documents and Settings\admin\Desktop\D2 Infinity\Other.au3(13,19) : REF: missing EndIf.
If Not @error Then
~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\admin\Desktop\D2 Infinity\Other.au3(18,1) : ERROR: syntax error
Endif
^
C:\Documents and Settings\admin\Desktop\D2 Infinity\Other.au3 - 2 error(s), 0 warning(s)

Heres my code

Opt("WinWaitDelay",100)
Opt("WinTitleMatchMode",4)
Opt("WinDetectHiddenText",1)
Opt("MouseCoordMode",0)
AutoItSetOption ( "PixelCoordMode", 0 ); Do not change this parameter! It's needed for windowed D2.

$Monsters = 0xFF2C00

FUNC MonsterFinding()
$MonsterFind = PixelSearch( 0, 0, 800, 600,$Monsters)
Do 
$MonsterFind = PixelSearch( 0, 0, 800, 600,$Monsters)
If Not @error Then
    Sleep(50)
    MouseClick("right", $MonsterFind[0], $MonsterFind[1])

Until $MonsterFind = PixelSearch( 0, 0, 800, 600,$Monsters) = @Error
Endif
    ENDFUNC

Am i doing something wrong or am i just having one of those moments >.<

I tired

Do $MonsterFind = PixelSearch( 0, 0, 800, 600,$Monsters)

Instead of

Do 
$MonsterFind = PixelSearch( 0, 0, 800, 600,$Monsters)

However it gave me this error

C:\Documents and Settings\admin\Desktop\D2 Infinity\Other.au3(11,4) : ERROR: syntax error
Do $MonsterFind
~~~^
C:\Documents and Settings\admin\Desktop\D2 Infinity\Other.au3 - 1 error(s), 0 warning(s)

The function for Do...Until

$i = 0
Do
    MsgBox(0, "Value of $i is:", $i)
    $i = $i + 1
Until $i = 10

^ is the Help definition Below is mine.

$MonsterFind = PixelSearch( 0, 0, 800, 600,$Monsters)
Do 
$MonsterFind 
If Not @error Then
    Sleep(50)
    MouseClick("right", $MonsterFind[0], $MonsterFind[1])
Until $MonsterFind = PixelSearch( 0, 0, 800, 600,$Monsters) = @Error

??? :D

Edited by ecstatic

Share this post


Link to post
Share on other sites
TerarinK

Opt("WinWaitDelay", 100)
Opt("WinTitleMatchMode", 4)
Opt("WinDetectHiddenText", 1)
Opt("MouseCoordMode", 0)
AutoItSetOption("PixelCoordMode", 0); Do not change this parameter! It's needed for windowed D2.

$Monsters = 0xFF2C00

Func MonsterFinding()
    $MonsterFind = PixelSearch(0, 0, 800, 600, $Monsters)
    Do
        $MonsterFind = PixelSearch(0, 0, 800, 600, $Monsters)
        If Not @error Then
            Sleep(50)
            MouseClick("right", $MonsterFind[0], $MonsterFind[1])
        EndIf
    Until $MonsterFind = PixelSearch(0, 0, 800, 600, $Monsters) = @error
EndFunc   ;==>MonsterFinding

Your EndIf is on the outside of the Until so I corrected it


0x576520616C6C206469652C206C697665206C69666520617320696620796F75207765726520696E20746865206C617374207365636F6E642E

Share this post


Link to post
Share on other sites
TerarinK

Just to note your have three things you are matching on your Until.

I would try:

Opt("WinWaitDelay", 100)
Opt("WinTitleMatchMode", 4)
Opt("WinDetectHiddenText", 1)
Opt("MouseCoordMode", 0)
AutoItSetOption("PixelCoordMode", 0); Do not change this parameter! It's needed for windowed D2.

$Monsters = 0xFF2C00

Func MonsterFinding()
    Do
        Sleep(100)
        $MonsterFind = PixelSearch(0, 0, 800, 600, $Monsters)
        If Not @error Then
            MouseClick("right", $MonsterFind[0], $MonsterFind[1])
        EndIf
    Until 1 
EndFunc   ;==>MonsterFinding

It'll decrease the speed but get everything regardless within 100 mmsec and your not doing two of the pixelsearch-es also why do you have it exiting when you find nothing? I would setup a HotKey for turning the function on or off in place of the 1 just because that would be the simplest method used. Also you don't need to wait 50 mmsec to click.


0x576520616C6C206469652C206C697665206C69666520617320696620796F75207765726520696E20746865206C617374207365636F6E642E

Share this post


Link to post
Share on other sites
ecstatic

Thank you very much! Its for a fully automated bot so the person wouldnt be there to use the hotkey

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  

×