Jump to content

pixelsearch help


Recommended Posts

Okay, when i run this, nothing happens except for my msgbox. When i remove the If Not @error Then line, it gives me an error saying Error: Subscript used with non-Array Variable.

Here is the code:

MsgBox(0, "Insomnia Bot v2","Bot Launched - Taking effect in 10 seconds",10)

while 1=1

sleep(10000)

$coord = PixelSearch(0, 0, 100, 300, 0xF7A273)

If Not @error Then

Send("{F11}")

sleep(1000)

MouseMove($coord[0],$coord[1],0)

MouseClick("right",$coord[0],$coord[1],1)

EndIf

if (PixelGetColor(254,87) = 0x5A3000) then

sleep(3000)

MouseMove(325,348,0)

MouseClick("left",325,348,2)

sleep(3000)

MouseMove(645,229,0)

MouseClick("left",645,229,2)

EndIf

WEnd

how do i fix it? ty

Link to comment
Share on other sites

Okay, when i run this, nothing happens except for my msgbox. When i remove the If Not @error Then line, it gives me an error saying Error: Subscript used with non-Array Variable.

Here is the code:

MsgBox(0, "Insomnia Bot v2","Bot Launched - Taking effect in 10 seconds",10)

while 1=1

sleep(10000)

$coord = PixelSearch(0, 0, 100, 300, 0xF7A273)

If Not @error Then

Send("{F11}")

sleep(1000)

MouseMove($coord[0],$coord[1],0)

MouseClick("right",$coord[0],$coord[1],1)

EndIf

if (PixelGetColor(254,87) = 0x5A3000) then

sleep(3000)

MouseMove(325,348,0)

MouseClick("left",325,348,2)

sleep(3000)

MouseMove(645,229,0)

MouseClick("left",645,229,2)

EndIf

WEnd

how do i fix it? ty

Maybe you could try this:

MsgBox(0, "Insomnia Bot v2","Bot Launched - Taking effect in 10 seconds",10)
while 1
    sleep(10000)
    $coord = PixelSearch(0, 0, 100, 300, 0xF7A273)
    If @error Then
        Msgbox(0,'Error','Could not find the pixel')
        Endif
    Else
        Send("{F11}")
        sleep(1000)
        MouseMove($coord[0],$coord[1],0)
        MouseClick("right",$coord[0],$coord[1],1)
    EndIf
    if PixelGetColor(254,87) = 0x5A3000 then
        sleep(3000)
        MouseMove(325,348,0)
        MouseClick("left",325,348,2)
        sleep(3000)
        MouseMove(645,229,0)
        MouseClick("left",645,229,2)
    EndIf
WEnd
Link to comment
Share on other sites

Maybe you could try this:

MsgBox(0, "Insomnia Bot v2","Bot Launched - Taking effect in 10 seconds",10)
while 1
    sleep(10000)
    $coord = PixelSearch(0, 0, 100, 300, 0xF7A273)
    If @error Then
        Msgbox(0,'Error','Could not find the pixel')
        Endif
    Else
        Send("{F11}")
        sleep(1000)
        MouseMove($coord[0],$coord[1],0)
        MouseClick("right",$coord[0],$coord[1],1)
    EndIf
    if PixelGetColor(254,87) = 0x5A3000 then
        sleep(3000)
        MouseMove(325,348,0)
        MouseClick("left",325,348,2)
        sleep(3000)
        MouseMove(645,229,0)
        MouseClick("left",645,229,2)
    EndIf
WEnd

the problem is, it never finds the pixel... lol

Link to comment
Share on other sites

the problem is, it never finds the pixel... lol

Then play with these vars:

$coord = PixelSearch(0, 0, 100, 300, 0xF7A273)oÝ÷ ØƲmç!jx¶¬jëh×6$coord = PixelSearch(0, 0, 100, 300, 0xF7A273, 10)
That gives it a range of 10 to search for. Or perhaps those coordinates aren't right, and if the bot shouldn't wait 10 secs everytime you perhaps might want to take sleep(10000) outside the while loop
Link to comment
Share on other sites

Global $test=1
While $test=1
$coord = PixelSearch(0, 0, 100, 300, 0xF7A273, 10)
if not @error then $test=0
;some stuff here
Wend


Endfunc

thanks i found a way

another question - how do i make it so that once it has detected the pixel and done wat i want with it, it gets ignored from then on?

Thats how i would do it but its possible on multiple ways:
Link to comment
Share on other sites

Global $test=1
While $test=1
$coord = PixelSearch(0, 0, 100, 300, 0xF7A273, 10)
if not @error then $test=0
;some stuff here
Wend


Endfunc

Thats how i would do it but its possible on multiple ways:

but would that ignore that very specific pixel or all pixels of that color? i just want it to ignore that very specific one so that it can then target the same pixel but in other spots
Link to comment
Share on other sites

when the pixelsearch finds pixel you want within the parameters youset it return an array.....????

#include <array.au3>
dim $array[101]
$c=0
$coord = PixelSearch(0, 0, 100, 300, 0xF7A273, 10)
if not @error then 
$c+=2
$array[$c-1]=$coord[0]
$array[$c]=$coord[1]
if _ArraySearch($array,$coord[0])=0 and _ArraySearch($array,$coord[1])=0 Then
    ;do whatever becasue the colour found @ $coord[0]&[1] hasnt been found
EndIf
EndIf

youll need to incorperate this into your script, this will work, but you need your loops ect put in the right place.... build on what i have posted

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...