Jump to content

help with botting


Recommended Posts

how to do this action?

post-50212-1244504509_thumb.jpg

Edited by toader

[center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Don't utter a single word[/font][/center][center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Just shut your pretty mouth[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you again[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you[/font][/center][center][font=courier new,courier,monospace]In hell[/font][/center]

Link to comment
Share on other sites

$catch2 = $catch1 - $catch

Well, AutoIt can't perform array calculations like that it seems, you need to create a loop and create each member of the new array manually. The arrays are 2-dimensional ...

Edited by Inverted
Link to comment
Share on other sites

how to add $catch2 in array?

_ArrayAdd($catch2) << that do error (((

#include <Array.au3>
Global $search_color2 = 0xEE2222
Global $count2 = 0
Global $search_color = 0x000000
Global $count = 0
Dim $catch[8][2]
For $x = 250 To 720
    For $y = 100 To 450
        If PixelGetColor($x, $y) = $search_color Then
            $catch[$count][0] = $x
            $catch[$count][1] = $y
            MsgBox(0, '', "x= " & $x & @CRLF & "Y= " & $y & @CRLF)
            $count += 1
        EndIf
    Next
Next
Dim $catch2[1][2]
For $x2 = 250 To 720
    For $y2 = 100 To 450
        If PixelGetColor($x2, $y2) = $search_color2 Then
            $catch2[$count2][0] = $x2
            $catch2[$count2][1] = $y2
            MsgBox(0, '', "x= " & $x & @CRLF & "Y= " & $y & @CRLF)
            $count += 1
        EndIf
    Next
Next
_ArrayDisplay($catch)
_ArrayAdd($catch2)
_ArrayDisplay($catch)
Exit

[center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Don't utter a single word[/font][/center][center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Just shut your pretty mouth[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you again[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you[/font][/center][center][font=courier new,courier,monospace]In hell[/font][/center]

Link to comment
Share on other sites

You might want to re-read _ArrayAdd() in the help file.

It only works with single dimension arrays and it requires both the Array Name and the Value to add

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

You might want to re-read _ArrayAdd() in the help file.

It only works with single dimension arrays and it requires both the Array Name and the Value to add

ohhh thanks now it dont do error but do not add too(((( only repeat first array((

_ArrayDisplay($catch)
_ArrayAdd($catch, $catch2)
_ArrayDisplay($catch)

[center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Don't utter a single word[/font][/center][center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Just shut your pretty mouth[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you again[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you[/font][/center][center][font=courier new,courier,monospace]In hell[/font][/center]

Link to comment
Share on other sites

ohhh thanks now it dont do error but do not add too(((( only repeat first array((

_ArrayDisplay($catch)
_ArrayAdd($catch, $catch2)
_ArrayDisplay($catch)
RE-read my first reply and notice the part about single dimension arrays $catch is 2 dimensional

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

RE-read my first reply and notice the part about single dimension arrays $catch is 2 dimensional

sry im so stupid i know it.. its bc i do not sleep long time i work on program and cant sleep if not finished((

if u say about

Dim $catch2[2][2]

i do this and script only show first array and after re show first array but not add $catch2 and i cant understand why :D

#include <Array.au3>

Global $search_color = 0x000000
Global $count = 0
Dim $catch[9][2]
For $x = 250 To 720
    For $y = 100 To 450
        If PixelGetColor($x, $y) = $search_color Then
            $catch[$count][0] = $x
            $catch[$count][1] = $y
;~             MsgBox(0, '', "x= " & $x & @CRLF & "Y= " & $y & @CRLF)
            $count += 1
        EndIf
    Next
Next

Global $search_color2 = 0xEE2222
Global $count2 = 0
Dim $catch2[2][2]
For $x2 = 250 To 720
    For $y2 = 100 To 450
        If PixelGetColor($x2, $y2) = $search_color2 Then
            $catch2[$count2][0] = $x2
            $catch2[$count2][1] = $y2
            MsgBox(0, '', "x= " & $x & @CRLF & "Y= " & $y & @CRLF)  ; <<< don't show this msgbox
            $count += 1
        EndIf
    Next
Next
_ArrayDisplay($catch)
_ArrayAdd($catch, $catch2)   ; <<< and dont add $catch2
_ArrayDisplay($catch)
Exit
Edited by toader

[center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Don't utter a single word[/font][/center][center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Just shut your pretty mouth[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you again[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you[/font][/center][center][font=courier new,courier,monospace]In hell[/font][/center]

Link to comment
Share on other sites

Both of your arrays are 2 dimension arrays and _ArrayAdd() will NOT work with anything except a 1 dimension array.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

;normal script
#include <Array.au3>
Global $search_color = 0x4900FA
Dim $catch[1][2]
$catch[0][0] = 0
For $x = 85 To 850
    For $y = 150 To 850
        If PixelGetColor($x, $y) = $search_color Then
            ReDim $catch[$catch[0][0] + 2][2]
            $catch[0][0] = $catch[0][0] + 1
            $catch[$catch[0][0]][0] = $x
            $catch[$catch[0][0]][1] = $y
            ;MsgBox(0, '', "x= " & $x & @CRLF & "Y= " & $y & @CRLF)
        EndIf
    Next
Next
_ArrayDisplay($catch)
Exit

Edited by wolf9228

صرح السماء كان هنا

 

Link to comment
Share on other sites

;normal script
#include <Array.au3>
Global $search_color = 0x4900FA
Dim $catch[1][2]
$catch[0][0] = 0
For $x = 85 To 850
    For $y = 150 To 850
        If PixelGetColor($x, $y) = $search_color Then
            ReDim $catch[$catch[0][0] + 2][2]
            $catch[0][0] = $catch[0][0] + 1
            $catch[$catch[0][0]][0] = $x
            $catch[$catch[0][0]][1] = $y
            ;MsgBox(0, '', "x= " & $x & @CRLF & "Y= " & $y & @CRLF)
        EndIf
    Next
Next
_ArrayDisplay($catch)
ExitoÝ÷ Ûú®¢×¢q©íºw^®ËZÛaË®*m׬¶+ZÛaj×âÛ5r+v)Úµí?Ñú+­ȭwvØb±ú+§+ZÚ²Ø^¢·¦ÊX¤zØb±«­¢+Ø¥¹±Õ±ÐíÉÉä¹ÔÌÐì()±½°ÀÌØíÍÉ¡}½±½ÈôÁàÀÀÀÀÀÀ)±½°ÀÌØí½Õ¹ÐôÀ)¥´ÀÌØíÑ¡låulÉt)½ÈÀÌØíàÄôÈÔÀQ¼ÜÀÀ(½ÈÀÌØíäÄôÄÀÀQ¼ÐÔÀ(%A¥á±Ñ
½±½È ÀÌØíàÄ°ÀÌØíäĤôÀÌØíÍÉ¡}½±½ÈQ¡¸(ÀÌØíÑ¡lÀÌØí½Õ¹ÑulÁtôÀÌØíàÄ(ÀÌØíÑ¡lÀÌØí½Õ¹ÑulÅtôÀÌØíäÄ(íø5Í   ½à À°ÌäìÌäì°ÅÕ½ÐíàôÅÕ½ÐìµÀìÀÌØíàµÀì
I1µÀìÅÕ½ÐídôÅÕ½ÐìµÀìÀÌØíäµÀì
I1¤(ÀÌØí½Õ¹Ð¬ôÄ(¹%(9áÐ)9áÐ((íø¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬(($ÀÌØí¡ÈôA¥á±MÉ  ÈÔÀ°ÄÀÀ°ÜÀÀ°ÐÔÀ°ÁáÈÈÈȤ($ÀÌØíàÈôÀÌØí¡ÉlÁt($ÀÌØíäÈôÀÌØí¡ÉlÅt((íø¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬()Õ¹A¥á±}¥Íѹ ÀÌØíàÄ°ÀÌØíäÄ°ÀÌØíàÈ°ÀÌØíäȤíAåÑ¡½ÉÌÑ¡½É´½ÈÉ(1½°ÀÌØí°ÀÌØí°ÀÌØí(%ÀÌØíàÈôÀÌØíàĹÀÌØíäÈôÀÌØíäÄQ¡¸(IÑÕɸÀ(±Í(ÀÌØíôÀÌØíäÈ´ÀÌØíäÄ(ÀÌØíôÀÌØíàÈ´ÀÌØíàÄ(ÀÌØíôMÅÉÐ ÀÌØí¨ÀÌØí¬ÀÌØí¨ÀÌØí¤(IÑÕɸÀÌØí(¹%)¹Õ¹ìôôÐíA¥á±}¥Íѹ((íøôôôôôôôôôôôôôôôôôôôôôôô()}ÉÉå¥ÍÁ±ä ÀÌØíÑ ¤)}ÉÉå ÀÌØíÑ °A¥á±}¥Íѹ ¤¤)}ÉÉå¥ÍÁ±ä ÀÌØíÑ ¤)á¥Ð

but don't work :D

[center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Don't utter a single word[/font][/center][center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Just shut your pretty mouth[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you again[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you[/font][/center][center][font=courier new,courier,monospace]In hell[/font][/center]

Link to comment
Share on other sites

iv had a good look at what has been said, but i cant understand what exactly you are wanting ?

so far i understand you have generated an array of x and y of all the pixels of color 0x000000 (i understand this bit as the code looks oddly familiar :D ), but what are you asking to do next?

please re-explain what your hoping to do

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Link to comment
Share on other sites

iv had a good look at what has been said, but i cant understand what exactly you are wanting ?

so far i understand you have generated an array of x and y of all the pixels of color 0x000000 (i understand this bit as the code looks oddly familiar :D ), but what are you asking to do next?

please re-explain what your hoping to do

in the script that I wrote above, I wanted to show it.

ARRAY to found 8 points of color 0x000000 as x1, y1.

then SearchPixel to Found color 0xEE2222 as x2, y2.

then that function theorem pitagora to show most close to 0xEE2222 of the 8 tichek 0x000000

[center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Don't utter a single word[/font][/center][center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Just shut your pretty mouth[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you again[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you[/font][/center][center][font=courier new,courier,monospace]In hell[/font][/center]

Link to comment
Share on other sites

in the script that I wrote above, I wanted to show it.

ARRAY to found 8 points of color 0x000000 as x1, y1.

then SearchPixel to Found color 0xEE2222 as x2, y2.

then that function theorem pitagora to show most close to 0xEE2222 of the 8 tichek 0x000000

Here's a different approach.

I assume there is only one pink point so find that first.

then search around a small circle centred on the pink point looking for a black colour, but restricting the search to inside the rectangle where you are searching. Start with a radius of a ball diameter. If you find a black point then that is the nearest. If you don't find a black point then increase the radius of the circle by say half the diameter of a black ball and try again. That will be hundreds of times faster I expect and it doesn't need arrays.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Here's a different approach.

I assume there is only one pink point so find that first.

then search around a small circle centred on the pink point looking for a black colour, but restricting the search to inside the rectangle where you are searching. Start with a radius of a ball diameter. If you find a black point then that is the nearest. If you don't find a black point then increase the radius of the circle by say half the diameter of a black ball and try again. That will be hundreds of times faster I expect and it doesn't need arrays.

I tried to do yesterday but unfortunately I have not got nothing, I wrote a script that even I do not understand)))

but how to place that he was looking for a black color around the circle? I'm using the box because I do not know how the other)))

that script work 1 minute after do lag and only click in 1 place and dont wanna stop can only restart pc))

Global $Paused
HotKeySet("{F1}", "TogglePause")
HotKeySet("{ESC}", "Terminate")

$her = PixelSearch( 200, 120, 940, 370, 0xFFFFFF ) ;hero name $coord1[1]+65, $coord1[0]+25
$box = PixelSearch( 200, 120, 940, 370, 0xBBB083 ) ;box
$rat = PixelSearch( 200, 120, 940, 370, 0xFEAE2C ) ;rat name $coord2[1]+15, $coord2[0]+30

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

While 1

 $hl = $her[0]-50
 $ht = $her[1]-50
 $hr = $her[0]+50
 $hb = $her[1]+50
 $radar = PixelSearch( $hl, $ht, $hr, $hb, 0xFEAE2C )
 If Not @error Then
     Send("{SHIFTDOWN}")
     MouseClick("left", $rat[0]+30, $rat[1]+15)
     Send("{SHIFTUP}")
     Send("e")
     Sleep(2000)
 Else
     Radar2()
 EndIf
WEnd

Func Radar2()
 $hl = $her[0]-100
 $ht = $her[1]-100
 $hr = $her[0]+100
 $hb = $her[1]+100
 $radar = PixelSearch( $hl, $ht, $hr, $hb, 0xFEAE2C )
 If Not @error Then
     Send("{SHIFTDOWN}")
     MouseClick("left", $rat[0]+30, $rat[1]+15)
     Send("{SHIFTUP}")
     Send("e")
     Sleep(2000)
 Else
     Radar3()
 EndIf
EndFunc

Func Radar3()
 $hl = $her[0]-150
 $ht = $her[1]-150
 $hr = $her[0]+150
 $hb = $her[1]+150
 $radar = PixelSearch( $hl, $ht, $hr, $hb, 0xFEAE2C )
  If Not @error Then
     Send("{SHIFTDOWN}")
     MouseClick("left", $rat[0]+30, $rat[1]+15)
     Send("{SHIFTUP}")
     Send("e")
     Sleep(2000)
 Else
     Radar4()
 EndIf
EndFunc

Func Radar4()
 $hl = $her[0]-200
 $ht = $her[1]-200
 $hr = $her[0]+200
 $hb = $her[1]+200
 $radar = PixelSearch( $hl, $ht, $hr, $hb, 0xFEAE2C )
 If Not @error Then
     Send("{SHIFTDOWN}")
     MouseClick("left", $rat[0]+30, $rat[1]+15)
     Send("{SHIFTUP}")
     Send("e")
     Sleep(2000)
 Else
     Radar5()
 EndIf
EndFunc

Func Radar5()
 $hl = $her[0]-250
 $ht = $her[1]-250
 $hr = $her[0]+250
 $hb = $her[1]+250
 $radar = PixelSearch( $hl, $ht, $hr, $hb, 0xFEAE2C )
 If Not @error Then
     Send("{SHIFTDOWN}")
     MouseClick("left", $rat[0]+30, $rat[1]+15)
     Send("{SHIFTUP}")
     Send("e")
     Sleep(2000)
 Else
     Radar6()
 EndIf
EndFunc

Func Radar6()
 $hl = $her[0]-300
 $ht = $her[1]-300
 $hr = $her[0]+300
 $hb = $her[1]+300
 $radar = PixelSearch( $hl, $ht, $hr, $hb, 0xFEAE2C )
 If Not @error Then
     Send("{SHIFTDOWN}")
     MouseClick("left", $rat[0]+30, $rat[1]+15)
     Send("{SHIFTUP}")
     Send("e")
     Sleep(2000)
 Else
     Send("{SHIFTDOWN}")
     MouseClick("left", $rat[0]-20, $rat[1]-10)
     Send("{SHIFTUP}")
 EndIf
EndFunc
Edited by toader

[center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Don't utter a single word[/font][/center][center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Just shut your pretty mouth[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you again[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you[/font][/center][center][font=courier new,courier,monospace]In hell[/font][/center]

Link to comment
Share on other sites

well im still looking at the original request

#include <Array.au3>
Global $search_color = 0x000000
Global $count = 0
Global $catch[9][2]; =[[200,200],[300,300],[500,500]] just for me testing
Dim $her[2] = [0, 0]
find_pixels()
$her = PixelSearch(250, 100, 700, 450, 0xEE2222)
If Not @error Then
    $x2 = $her[0]
    $y2 = $her[1]
    MsgBox(0, 'test', "$catch no. " & find_close($x2, $y2) & " is the closest point")
EndIf
_ArrayDisplay($catch)
Exit
Func find_pixels()
    For $x1 = 250 To 700
        For $y1 = 100 To 450
            If PixelGetColor($x1, $y1) = $search_color Then
                If $count < UBound($catch, 1) Then
                    $catch[$count][0] = $x1
                    $catch[$count][1] = $y1
                    $count += 1
                Else
                    ConsoleWrite('Two many points for the array !' & @CRLF)
                EndIf
            EndIf
        Next
    Next
EndFunc   ;==>find_pixels
Func find_close($cl_x, $cl_y)
    $distance = 0
    $lowest_distance = 9999
    $lowest_count_num = 0
    For $loop = 0 To $count - 1
        $distance = Pixel_Distance($cl_x, $cl_y, $catch[$loop][0], $catch[$loop][1])
        If $distance < $lowest_distance Then
            $lowest_distance = $distance
            $lowest_count_num = $loop
        EndIf
    Next
    Return $lowest_count_num
EndFunc   ;==>find_close
Func Pixel_Distance($PDx1, $PDy1, $PDx2, $PDy2) ;Pythagoras theorem for 2D
    Local $a, $b, $c
    If $PDx2 = $PDx1 And $PDy2 = $PDy1 Then
        Return 0
    Else
        $a = $PDy2 - $PDy1
        $b = $PDx2 - $PDx1
        $c = Sqrt($a * $a + $b * $ B) 
        Return $c
    EndIf
EndFunc   ;==>Pixel_Distance

should do what you asked, but as has been mentioned there is most probably a better way to do this.

EDIT: added a bit of protection from overflow , mainly the array might go over 8 points.

Edited by JackDinn

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Link to comment
Share on other sites

I tried to do yesterday but unfortunately I have not got nothing, I wrote a script that even I do not understand)))

but how to place that he was looking for a black color around the circle? I'm using the box because I do not know how the other)))

that script work 1 minute after do lag and only click in 1 place and dont wanna stop can only restart pc))

Global $Paused
HotKeySet("{F1}", "TogglePause")
HotKeySet("{ESC}", "Terminate")

$her = PixelSearch( 200, 120, 940, 370, 0xFFFFFF ) ;hero name $coord1[1]+65, $coord1[0]+25
$box = PixelSearch( 200, 120, 940, 370, 0xBBB083 ) ;box
$rat = PixelSearch( 200, 120, 940, 370, 0xFEAE2C ) ;rat name $coord2[1]+15, $coord2[0]+30

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

While 1

 $hl = $her[0]-50
 $ht = $her[1]-50
 $hr = $her[0]+50
 $hb = $her[1]+50
 $radar = PixelSearch( $hl, $ht, $hr, $hb, 0xFEAE2C )
 If Not @error Then
     Send("{SHIFTDOWN}")
     MouseClick("left", $rat[0]+30, $rat[1]+15)
     Send("{SHIFTUP}")
     Send("e")
     Sleep(2000)
 Else
     Radar2()
 EndIf
WEnd

Func Radar2()
 $hl = $her[0]-100
 $ht = $her[1]-100
 $hr = $her[0]+100
 $hb = $her[1]+100
 $radar = PixelSearch( $hl, $ht, $hr, $hb, 0xFEAE2C )
 If Not @error Then
     Send("{SHIFTDOWN}")
     MouseClick("left", $rat[0]+30, $rat[1]+15)
     Send("{SHIFTUP}")
     Send("e")
     Sleep(2000)
 Else
     Radar3()
 EndIf
EndFunc

Func Radar3()
 $hl = $her[0]-150
 $ht = $her[1]-150
 $hr = $her[0]+150
 $hb = $her[1]+150
 $radar = PixelSearch( $hl, $ht, $hr, $hb, 0xFEAE2C )
  If Not @error Then
     Send("{SHIFTDOWN}")
     MouseClick("left", $rat[0]+30, $rat[1]+15)
     Send("{SHIFTUP}")
     Send("e")
     Sleep(2000)
 Else
     Radar4()
 EndIf
EndFunc

Func Radar4()
 $hl = $her[0]-200
 $ht = $her[1]-200
 $hr = $her[0]+200
 $hb = $her[1]+200
 $radar = PixelSearch( $hl, $ht, $hr, $hb, 0xFEAE2C )
 If Not @error Then
     Send("{SHIFTDOWN}")
     MouseClick("left", $rat[0]+30, $rat[1]+15)
     Send("{SHIFTUP}")
     Send("e")
     Sleep(2000)
 Else
     Radar5()
 EndIf
EndFunc

Func Radar5()
 $hl = $her[0]-250
 $ht = $her[1]-250
 $hr = $her[0]+250
 $hb = $her[1]+250
 $radar = PixelSearch( $hl, $ht, $hr, $hb, 0xFEAE2C )
 If Not @error Then
     Send("{SHIFTDOWN}")
     MouseClick("left", $rat[0]+30, $rat[1]+15)
     Send("{SHIFTUP}")
     Send("e")
     Sleep(2000)
 Else
     Radar6()
 EndIf
EndFunc

Func Radar6()
 $hl = $her[0]-300
 $ht = $her[1]-300
 $hr = $her[0]+300
 $hb = $her[1]+300
 $radar = PixelSearch( $hl, $ht, $hr, $hb, 0xFEAE2C )
 If Not @error Then
     Send("{SHIFTDOWN}")
     MouseClick("left", $rat[0]+30, $rat[1]+15)
     Send("{SHIFTUP}")
     Send("e")
     Sleep(2000)
 Else
     Send("{SHIFTDOWN}")
     MouseClick("left", $rat[0]-20, $rat[1]-10)
     Send("{SHIFTUP}")
 EndIf
EndFunc
You are searching inside a rectangle, then if not found you search inside a larger rectangle which means you search the first one again as well since it is contained by the larger rectangle so if the nearest black ball is a long way away you will search hundreds or maybe thousands of points withouit needing to.

Say the pink is at $px,$py.

Say the rectangle you are searching in is $topx,$topy,$botx,$boty

Say the radius of a ball is $rad.

Then I think you need something like this, but it just written as I thought it up and not tested, it's just to show the idea.

;returns 2 dim array with x,y of nearest point to $px,$py where searchCol found 
;only looking inside therectangle $topx, $topy, $botx, $boty
 Func nearest($px, $py, $topx, $topy, $botx, $boty, $rad, $searchCol)
 
     Local $inrect = True;the circle still has parts inside the search rect so keep looking
     Local $MaxRad = $botx - $topx
     Local $maxrad2 = $boty = $topy
     Local $arc, $res
     If $maxrad2 > $MaxRad Then $MaxRad = $maxrad2
 
     For $nowRad = $rad * 2 To $MaxRad Step $rad
         $inrect = False
         $arc = $rad / $nowRad
         For $ang = 0 To 3.142 * 2 - $arc Step $arc
             $sx = $px + $nowRad * Cos($ang)
             $sy = $py + $nowRad * Sin($ang);<========added $py +
             If Not ($sx < $topx Or $sx > $botx Or $sy < $topy Or $sy > $boty) Then
                 $res = PixelSearch($sx, $sy, $sx, $y, $searchCol)
                 If Not @error Then Return $res
                 $inrect = True
             EndIf
         Next
       ;if there were no pooints inside the rect the circle was too big
         If Not $inrect Then Return SetError(-1, -1, 0)
     Next
 
 EndFunc ;==>nearest

EDIT Corrected $sy =

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

wow greate script.. big thx.. but i cant understand how use it ^^ i run script and it after open is closed((

Global $searchCol = 0x000000
        Global $topx = 292
    Global $topy = 110
    Global $botx = 674
    Global $boty = 488
Func nearest($px, $py, $topx, $topy, $botx, $boty, $rad, $searchCol)
    $pink = PixelSearch($topx, $topy, $botx, $boty, 0xEEAAAA)
If Not @error Then
     Local $px = $pink[0]
     Local $py = $pink[1]
     Local $rad = 10
     Local $inrect = True;the circle still has parts inside the search rect so keep looking
     Local $MaxRad = $botx - $topx
     Local $MaxRad2 = $boty - $topy
     Local $arc, $res
     Local $x = $searchCol[0]
     Local $y = $searchCol[1]
     If $MaxRad2 > $MaxRad Then $MaxRad = $MaxRad2

     For $nowRad = $rad * 2 To $MaxRad Step $rad
         $inrect = False
         $arc = $rad / $nowRad
         For $ang = 0 To 3.142 * 2 - $arc Step $arc
             $sx = $px + $nowRad * Cos($ang)
             $sy = $py + $nowRad * Sin($ang);<========added $py +
             If Not ($sx < $topx Or $sx > $botx Or $sy < $topy Or $sy > $boty) Then
                 $res = PixelSearch($sx, $sy, $x, $y, $searchCol)
                 If Not @error Then Return $res
                 $inrect = True
             EndIf
         Next
       ;if there were no pooints inside the rect the circle was too big
         If Not $inrect Then Return SetError(-1, -1, 0)
     Next
EndIf

EndFunc ;==>nearest

EDIT:

Ohhh.. its so hard for my intelegent :D

Edited by toader

[center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Don't utter a single word[/font][/center][center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Just shut your pretty mouth[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you again[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you[/font][/center][center][font=courier new,courier,monospace]In hell[/font][/center]

Link to comment
Share on other sites

Try this. I have added a line to show you where it's searching, and added a delay so that it is slowed down so you can see it.

Global $searchCola = 0x000000
         Global $topxa = 292
     Global $topya = 110
     Global $botxa = 674
     Global $botya = 488
     Global $rada = 10;0
      $pink = PixelSearch($topxa, $topya, $botxa, $botya, 0xEEAAAA)
 If @error Then
     msgbox(262144,"Error","Could not find colour")
 Else
     
     ConsoleWrite("found colour at " & $pink[0] & ', ' & $pink[1] & @CRLF)
     
     nearest($pink[0], $pink[1], $topxa, $topya, $botxa, $botya, $rada, $searchCola)
  EndIf
 
 
 Func nearest($px, $py, $topx, $topy, $botx, $boty, $rad, $searchCol)
      Local $inrect = True;the circle still has parts inside the search rect so keep looking
      Local $MaxRad = Sqrt(($botx - $topx)^2 + ($boty - $topy)^2);<---changed this bit
      Local $arc, $res
 
      For $nowRad = $rad * 2 To $MaxRad Step $rad
          $inrect = False
          $arc = $rad / $nowRad
          For $ang = 0 To 3.142 * 2 - $arc Step $arc
              $sx = $px + $nowRad * Cos($ang)
              $sy = $py + $nowRad * Sin($ang)   
              
              If Not ($sx < $topx Or $sx > $botx Or $sy < $topy Or $sy > $boty) Then

 ;next two lines so you can see what happens as it searches for colour, remove for speed
                mousemove($sx+1,$sy+1,0)
                sleep(10)
                  $res = PixelSearch($sx, $sy, $sx, $sy, $searchCol)
                  If Not @error Then Return $res
                  $inrect = True
              EndIf
          Next
      ;if there were no points inside the rect the circle was too big
          If Not $inrect Then Return SetError(-1, -1, 0)
      Next
 
 
 EndFunc;==>nearest

edit:moved lines for showing search position to after If Not ($sx...

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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...