Jump to content

Need Help Making A Script


Melkor2
 Share

Recommended Posts

In a 1x1" area on a 24" monitor, not sure what pixel size that is, 1024 window I want a script to click around within that area untill it sees red at X511 Y60, then left click mouse.

It will then wait 1:30 seconds and check pixel color at X456 Y60, If it's red, wait 10 seconds, check color, if red, wait etc.

Once there is no more red at X456 Y39 it will then sleep 5 seconds and check if there is white at X469 Y39 If there is white, repeat 5 second wait and test, if there is no white, loop script.

Edited by Melkor2
Link to comment
Share on other sites

In a 1x1" area on a 24" monitor, not sure what pixel size that is, 1024 window I want a script to click around within that area untill it sees red at X511 Y60, then left click mouse.

It will then wait 1:30 seconds and check pixel color at X456 Y60, If it's red, wait 10 seconds, check color, if red, wait etc.

Once there is no more red at X456 Y39 it will then sleep 5 seconds and check if there is white at X469 Y39 If there is white, repeat 5 second wait and test, if there is no white, loop script.

Look up the following in the help file:

MouseClick()

PixelGetColor()

Sleep()

If/Else/Then

While/WEnd

Play with the example scripts listed in the help file, then code your script. If you get stuck, post your code and you'll get lots of help.

:D

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
Link to comment
Share on other sites

This is what we've come up with so far, not all code credited to myself. Still no-go. Am I correct that this will start at pixel 500,500 then search a radius of 100 pixels each direction? Bugger wont even load up, I get AUT icon pop up for about 7 seconds then dissapear.

Func _Find()
$x = '500'
$y = '500'
Do
Mousemove($x, $y)
Sleep(100)
Mouseclick("right")
Sleep(100)
$pixeltest = PixelGetColor (511 , 60)
$x = $x + 1
If $x = '100' then
$y = $y + 1
$x = '500'
If $y = '100' then
$y = '500'
endif
endif
Until $pixeltest = '16724736'
endfunc

Func _checkhealth()
Do
$Pixeltest = Pixelgetcolor( 456, 60)
sleep(500)
Until Not $pixeltest = '16724736'
endfunc

While 1
_Find()
Send("2")
sleep(1300)
_checkhealth()
wend
Edited by Melkor2
Link to comment
Share on other sites

I'm sure there is a better way to do this. But I rearrange so search 100 each direction, horizontal then vertical on the 500.

Func _Find()
    $x = '400'
    $y = '500'
    $check = 'h'
    Do
        Mousemove($x, $y)
        Sleep(100)
        ;Mouseclick("right")
        Sleep(100)
        $pixeltest = PixelGetColor (511 , 60)
        If $check = 'h' Then
            If $x <= 600 then 
                $x = $x + 1
                $y = 500
            Else
                $check = 'v'
                
                $y=400
            EndIf
        ElseIf $check = 'v' Then
            if $y <=600 Then
                $y = $y + 1
                $x = 500
            Else
                $check = 'h'
                $x=400
            EndIf
        endif
    Until $pixeltest = '16724736'
endfunc

Func _checkhealth()
    Do
        $Pixeltest = Pixelgetcolor( 456, 60)
        sleep(500)
    Until Not $pixeltest = '16724736'
endfunc

While 1
    _Find()
    Send("2")
    sleep(1300)
    _checkhealth()
wend
Link to comment
Share on other sites

Melkor2, i suggest you debug your script one step at a time, ensuring each stage / function performs what you want before you move on.

use the help documents, and search for the functions mentioned above for the proper syntax.

example...

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

Global $x = 500
Global $y = 500

Func _Find()
    While 1
        Sleep(1000)
        MouseClick("right", $x, $y, 1, 5)
        Sleep(200)
        $x_temp = $x - 100
        $y_temp = $y - 100
        For $x_temp = 400 to 600
            For $y_temp = 400 to 600
                ;mousemove just to show you the pixelgetcolor location
                MouseMove($x_temp, $y_temp, 0)
                ;tooptip to show you co'rds
                ToolTip("searching: " & $x_temp & " x " & $y_temp, 0, 0)
                $pixeltest = PixelGetColor($x_temp, $y_temp)
                If $pixeltest = 16724736 Then
                    Return
                EndIf
            Next
        Next
        ;use msgbox to help you evaluate where abouts your code is while running
        MsgBox(0, "", "pixel 16724736 not found." & @CRLF & "push esc to exit at any time", 3)
    WEnd
endfunc
    
Func _checkhealth()
Do
    $Pixeltest = Pixelgetcolor(456, 60)
    sleep(500)
Until Not $pixeltest = '16724736'
endfunc

While 1
    _Find()
    MsgBox(0, "", "pixel 16724736 found!")
    Send("2")
    sleep(1300)
    _checkhealth()
wend

Func Terminate()
    Exit 0
EndFunc
Link to comment
Share on other sites

I think I fixed the mouse problem, it seems to now be clicking during the search. Although, I belive that my loop method at the check health back to function find is incorrect. This script is intended to be never-ending. I also belive that my method to produce right mouse clicks during the mousemove is very incorrect. Have a looksee :D

I've been working on this bugger all day =/

WinActivate ( "Dont you wish you knew what game i was playing", "")
MsgBox( 0,"Pwned", "Uber Macro Starting In 3 Seconds. Press ESC anytime to Terminate.", 3)
HotKeySet("{ESC}", "Terminate")
AutoItSetOption ( "PixelCoordMode", 0)
Global $x = 510
Global $y = 344

Func _Find()
    While 1
        Sleep(1000)
        Sleep(400)
        $x_temp = $x - 50
        $y_temp = $y - 50
               For $x_temp = 550 to 600
            For $y_temp = 300 to 350
                MouseMove($x_temp, $y_temp, 0)
                MouseClick("right", $x_temp, $y_temp, 10, 5)    
                ToolTip("searching: " & $x_temp & " x " & $y_temp, 0, 0)
                $pixeltest = PixelGetColor(459, 58)
                If $pixeltest = 0xD33116 Then
                    Return
                EndIf
            Next
        Next
    WEnd
endfunc
   
Func _checkhealth()
Do
    $Pixeltest = Pixelgetcolor(459, 58)
    sleep(500)
Until Not $pixeltest = '0xD33116'
Return Func _Find()
endfunc

While 1
    _Find()
    Send("2")
    sleep(1300)
    _checkhealth()
wend

Func Terminate()
    Exit 0
EndFunc
Edited by Melkor2
Link to comment
Share on other sites

a few things without going into to much detail,

- pointless having two sleep calls next to each other, just call it once, sleep(1400)

- you dont need to call mousemove() and then mouseclick(), mouseclick includes the movement of mouse

- in your MouseClick(), right clicking 10 times, is that necessary? and you have set the mousespeed to ,5. change this to 0.

shouldn't you search the entire search area before right clicking again? by including the rightclick within the pixel search

you are slowing the script down considerably. why not have it right click after finishing each loop of the pixel search.

(which is after both of the For loops have finished)

i suggest setting a hotkey, which does this

msgbox("", 0, PixelGetColor(459, 58))

to be certain that the colour of (459, 58)) is definatly 0xD33116 at that correct moment

i dont properly understand the syntax of NOT condition, so i'd cheap my way outa this one (yaya bad i know :D)

Do

$Pixeltest = Pixelgetcolor(459, 58)

sleep(500)

if $pixeltest = 0xD33116 then

;do nothing

else

Return ;note you can only send variables with return, you cannot return and enter a function!

;it will return to the while loop and call _find() next anyway

endfunc

Melkor2, i wish you best of luck, but you must study the help documents, i wont be offering any more assistance with this code.

you mentioned uber macro so i'm assuming its some sort of RTS game? please tell me its not world of crakcraft ^^

Link to comment
Share on other sites

It needs to right click the entire time its searching for a pixel, without a right click, no pixel will be shown. I actully should make it so its searching and clicking, not pixel searching. The pixel said above will always be in the same spot, so in reality it doesnt need to be "searched for" All the moving pixel search is doing is providing means for me to spam right clicks untill the target is found, which will activate the pixel.

I'll fix the sleep command I overlooked that.

I have studied the manuals, but that does not mean I fully understand yet.

I also dont understand your means of looping the entire script, and the documention is currently confusing me.

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