Jump to content

Recommended Posts

Posted

Could somebody please show me how I would pixelsearch for a colour and then click on it? I know how to code the search and click bits but cant make them work :rolleyes:

Thanks.

Posted (edited)

Sleep(3000)

$pixel = 9626367
$xy = PixelSearch(0,0,@DesktopWidth,@DesktopHeight,$pixel);Searches entire desktop
If @error Then
    MsgBox(0,"Error","Cant find that Pixel")
Else
    MouseMove($xy[0],$xy[1], 30)
    MouseClick("Left",$xy[0],$xy[1])
EndIf

Edited by ofLight

There is always a butthead in the crowd, no matter how hard one tries to keep them out.......Volly

Posted

Sleep(3000)

$pixel = 9626367
$xy = PixelSearch(0,0,@DesktopWidth,@DesktopHeight,$pixel);Searches entire desktop
If @error Then
    MsgBox(0,"Error","Cant find that Pixel")
Else
    MouseMove($xy[0],$xy[1], 30)
    MouseClick("Left",$xy[0],$xy[1])
EndIf
Thanks for your help ofLight. I've been using this to help me but now I have another problem.......anyone?

I'm trying to make it wait until $ab = $pixel2 and then the subsequent clicks. Maybe the Until line is totally wrong??

Any help appreciated, thanks.

$pixel2 = 0x959595

$ab = PixelSearch(1307,112,1309,114,$pixel2)
Do
    Sleep(100)

until ($ab[0] & $ab[1]) = ?????????; problem I think is this line.....
Sleep(500)
If @error Then
    MsgBox(0,"Error","Cant find that Pixel")
Else
    MouseMove($ab[0],$ab[1])

    sleep(500)
    MouseClick("left",$ab[0],$ab[1])
EndIf
Posted (edited)

I'm not certain what you're asking, but it looks like you want to keep searching for the color until it's found, then click it? The way your Do...Until statement was written, nothing was ever changing, all you were doing was sleeping :rolleyes:

Maybe something like this?

$pixel2 = 0x959595
$ab = ""

While Not IsArray($ab)
    $ab = PixelSearch(1307, 112 ,1309 ,114, $pixel2)
    Sleep(10)
WEnd

MsgBox(0, "", "Color found!")
Sleep(500)
MouseMove($ab[0], $ab[1])
sleep(500)
MouseClick("left", $ab[0], $ab[1])
Edited by mikehunt114
IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]
Posted

I'm not certain what you're asking, but it looks like you want to keep searching for the color until it's found, then click it? The way your Do...Until statement was written, nothing was ever changing, all you were doing was sleeping :rolleyes:

Maybe something like this?

$pixel2 = 0x959595
$ab = ""

While Not IsArray($ab)
    $ab = PixelSearch(1307, 112 ,1309 ,114, $pixel2)
    Sleep(10)
WEnd

MsgBox(0, "", "Color found!")
Sleep(500)
MouseMove($ab[0], $ab[1])
sleep(500)
MouseClick("left", $ab[0], $ab[1])
Thanks that worked great BUT I want to put a While/Wend around my whole script so that it'll repeat until there's no more 0xFFFF00. Here is the whole code.....can anyone please help? Thanks

$pixel = 0xFFFF00
$xy = PixelSearch(1230,200,1232,280,$pixel) 
If not @error Then
   
    MouseMove($xy[0],$xy[1])
    MouseClick("right",$xy[0],$xy[1])
    Sleep(500)
    MouseClick("left", $xy[0] + Random(44,100), $xy[1] + 10 )   
    Sleep(2000)
    $pixel = 0xFFFF00
    $xy = PixelSearch(1230,200,1232,280,$pixel)
    MouseClick("left",$xy[0],$xy[1])
    Sleep(500)
    MouseMove(random(300,1210),Random(100,310))
EndIf

$pixel2 = 0x959595
$ab = ""

While Not IsArray($ab)
    $ab = PixelSearch(1307, 112 ,1309 ,114, $pixel2)
    Sleep(10)
Wend
Sleep(500)
If @error Then
    MsgBox(0,"Error","Cant find that Pixel")
Else
    MouseMove($ab[0],$ab[1])

    sleep(500)
    MouseClick("left",$ab[0],$ab[1])
EndIf
Posted

Thanks that worked great BUT I want to put a While/Wend around my whole script so that it'll repeat until there's no more 0xFFFF00. Here is the whole code.....can anyone please help? Thanks

$pixel = 0xFFFF00
$xy = PixelSearch(1230,200,1232,280,$pixel) 
If not @error Then
   
    MouseMove($xy[0],$xy[1])
    MouseClick("right",$xy[0],$xy[1])
    Sleep(500)
    MouseClick("left", $xy[0] + Random(44,100), $xy[1] + 10 )   
    Sleep(2000)
    $pixel = 0xFFFF00
    $xy = PixelSearch(1230,200,1232,280,$pixel)
    MouseClick("left",$xy[0],$xy[1])
    Sleep(500)
    MouseMove(random(300,1210),Random(100,310))
EndIf

$pixel2 = 0x959595
$ab = ""

While Not IsArray($ab)
    $ab = PixelSearch(1307, 112 ,1309 ,114, $pixel2)
    Sleep(10)
Wend
Sleep(500)
If @error Then
    MsgBox(0,"Error","Cant find that Pixel")
Else
    MouseMove($ab[0],$ab[1])

    sleep(500)
    MouseClick("left",$ab[0],$ab[1])
EndIf
Is it possible to have a While/Wend around the whole thing seeing as though the While here reads "While not"? Or can I have only 1 While/Wend statement?? Anyhow I need it to repeat itself in a loop.....
Posted

Is it possible to have a While/Wend around the whole thing seeing as though the While here reads "While not"? Or can I have only 1 While/Wend statement?? Anyhow I need it to repeat itself in a loop.....

You can nest While/WEnd, and other types of loops in AutoIt. Did you try it before asking...?

:rolleyes:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Posted

Yes I did try it to no avail.... obviously I put it in the wrong place.....???

I guess I'm missing something. Put While 1 at the top and WEnd at the bottom and the whole script will be looped indefinitely.

What else was there?

:rolleyes:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Posted

Hmmmm thats what I tried but had no luck - I kept getting a missing Wend message...

Seems to be working now, dunno what was wrong...... Now to start tweaking abit.....

Thanks

Posted

Could you clarify what you're trying to do? Maybe write out the steps you are trying to accomplish.

IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]
Posted

Ok got most of it going well but I'd like some help with 1 other bit plz.

What it is supposed to do is:

find yellow at a certain coord, click it.

if it doesnt find it I want it to click elsewhere, opening a menu.

Here's the script... its only part of the script but I'm having trouble with the 2nd case clause; tried if....else but still no luck. Why doesnt it work? Plz help.

CODE
Local $xy

$pixel = 0xFFFF00 ;yellow colour

$xy = PixelSearch(1230,200,1232,350,$pixel,2)

While @error

sleep(100)

WEnd

Select

Case MouseMove($xy[0],$xy[1])

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

Sleep(500)

MouseClick("left", $xy[0] + Random(44,100), $xy[1] + 10 )

Sleep(2000)

$pixel = 0xFFFF00

$xy = PixelSearch(1230,200,1232,280,$pixel)

MouseClick("left",$xy[0],$xy[1])

Sleep(500)

MouseMove(random(300,1210),Random(100,310))

Case $xy <> PixelSearch(1230,200,1232,350,$pixel,2)

MouseClick("left",161,154)

MouseClick("right",166,174)

EndSelect

Posted

Your setup seems a little wonky to me....neither one of your Cases make much sense. How about using a simple If statement?

HotKeySet("{ESC}", "Terminate")

Local $xy
$pixel = 0xFFFF00 ;yellow colour
While 1
    $xy = PixelSearch(1230,200,1232,350,$pixel,2) 
    If IsArray($xy) Then        ;$xy will be an array when the color is found
        ;click coords
        MouseClick("left", $xy[0], $xy[1], 1, 0)
    Else
        ;Click elsewhere....open a menu?

    EndIf
WEnd


Func Terminate()
    Exit 0
EndFunc
IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]

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
×
×
  • Create New...