Sign in to follow this  
Followers 0
Poker

Colour script?

6 posts in this topic

Hey!

Could some1 help me make a script for colour detection?

I want the script to search for a colour within a certain range, and area. When it finds the colour, execute a simple command like sending a "1" or "2".

The code is a script, Ive tried to modify for the use above, but I cant get it to work.

WinWaitActive("World of Warcraft")
                 
          
HotKeySet("{F2}", "Start")
HotKeySet("!{F2}","Quit")

TogglePause()

func Start()
HotKeySet("{F2}")
HotKeySet("{F2}", "TogglePause")
ToolTip('Swap off-weapon started.',0,20)
While 1
PixelSearch( 930, 200, 940, 210, 0x950B0B )
If Not @error Then
Sleep(1000)
EndIf
If Then
Send ("{2}")
EndIf
WEnd
Endfunc


Func TogglePause()
ToolTip('Swap off-weapon Stopped.',0,20)
HotKeySet("{F2}")
HotKeySet("{F2}", "Start")
While 1
sleep(100)
WEnd
EndFunc

func Quit()
Exit
EndFunc

Share this post


Link to post
Share on other sites



Soz, cant really seem to get it working.

Anyways the script shouldnt be more complex than:-

1. Search for red colour in an area of the screen.

2. If the colour is found, then send one key stroke.

3. If the colour isnt there, then wait for no more than 1 sec. then start over with the searching.

Hope you could help me:)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

maybe...

Func Start()
    HotKeySet("{F2}")
    HotKeySet("{F2}", "TogglePause")
    ToolTip('Swap off-weapon started.', 0, 20)
    While 1
        PixelSearch(930, 200, 940, 210, 0x950B0B)
        If Not @error Then
            Send("{2}")
        EndIf
        Sleep(1000)
    WEnd
EndFunc ;==>Start

EDIT...

i noticed you searching a large screen.. no color variation, and not skipping pixels to speed up the search

you need to read-up on pixelsearch in help

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

#NoTrayIcon
#Include <Misc.au3>
Opt("MustDeclareVars", 1)

Dim $dll = DllOpen("user32.dll")
Dim $pos[2]
Dim $kicks

While 1; main loop
    HotKeySet("{F9}", "Terminate")
    
    Do
        Sleep(100)
    Until _ispressed ("77", $dll) = 1; do nothing until F8 is pressed
   
    For $kicks = 0 To 3; 4 balls - 4 cycles
        $pos = GetCoordinate()
        Sleep(2000)
        TapThatBar($pos)
        Sleep(2000)
    Next    
WEnd

DllClose($dll)

Exit

Func GetCoordinate(); sets the position of the pixel to check
    Dim $pos
    While _ispressed (01, $dll) = 0; detect left mouse click
        $pos = MouseGetPos()
        Sleep(50)
    WEnd
    Return $pos
EndFunc

Func TapThatBar($pos); sends a {space} when the target pixel is white 
    Local $pix_color
    Do 
        $pix_color = PixelGetColor($pos[0], $pos[1])
    Until $pix_color = 16777215
    Send("{SPACE}")
EndFunc

Func Terminate()
    Exit 0
EndFunc

I wrote the above to detect when a given pixel (set by mouse click) was white. Once said rascal turned white, the code "TapsThatBar" (space bar). I am sure that you can get it to check a given area with a little tweaking. Good luck :o

BTW - I'm new to this, so if anyone can offer pointers on my code (better practices, bad habits, etc.) feel free to comment.

Cheers,

Def

Share this post


Link to post
Share on other sites

maybe...

Func Start()
    HotKeySet("{F2}")
    HotKeySet("{F2}", "TogglePause")
    ToolTip('Swap off-weapon started.', 0, 20)
    While 1
        PixelSearch(930, 200, 940, 210, 0x950B0B)
        If Not @error Then
            Send("{2}")
        EndIf
        Sleep(1000)
    WEnd
EndFunc;==>Start

EDIT...

i noticed you searching a large screen.. no color variation, and not skipping pixels to speed up the search

you need to read-up on pixelsearch in help

8)

I shouldnt be searching a larger area of the screen, only 10x10 pixel. And the colour variation have to be so small, cause it should only send "2" when a specific red is found within that area.

BTW I havent tested your script to the max yet, but the initial testing is looking good :o

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  
Followers 0