Sign in to follow this  
Followers 0
EvilRubberDuck

Analyze image still in clipboard

4 posts in this topic

Hey guys! So i want to get the pixel color in a certain position while the image is still in the clipboard. I found Greenseed bot, but first i don't know what the hell happens in that code, and second i don't know if it is useful to me. Anyone can help me?

Thanks

 

On 1/26/2008 at 1:27 AM, Greenseed said:

Hi everyone... long time i had not done a Autoit script :D

 

I was just lazy today.. and looking one of my friend playing Guitar Hero III.... im so bad at that game mouhaha! :P

 

 

So i started a Bot with PixelGetColor feature, but was not working, since each time i call that function, Autoit Take a complete screenShot from the GDI and search the pixel from there...

 

There is 5 Button, so that mean 5 ScreenShot... not good at all...

 

Then i managed to get 1 ScreenShot and after that reading pixel Color for my 5 region and then Send the right Key Press...

 

The bot is not perfect into that version... ;) since the goal here is to show off a script that can maybe be helpfull for other serious need :P i saw many ppl searching how to grab pixel color from memory ;)

 

 

 

#region opt and variable

Opt("SendKeyDelay", 0)          ;5 milliseconds
Opt("SendKeyDownDelay", 15)      ;1 millisecond
Opt("SendAttachMode",1)
Opt("TrayIconDebug", 0)         ;0=no info, 1=debug line info
Opt("TrayIconHide", 1)          ;0=show, 1=hide tray icon
Opt("WinDetectHiddenText", 0)   ;0=don't detect, 1=do detect

#include <GDIPlus.au3>
#include <ScreenCapture.au3>
#include <Color.au3>

ProcessSetPriority ( @AutoItPID, 4)

Global $MemoryContext

$Stop = false

HotKeySet("{END}", "end")
Hotkeyset("{INSERT}", "start")

while 1
    sleep(7)
wend

Func stop()
    $Stop = true
    Hotkeyset("{INSERT}", "start")
    
    DllCall("gdi32.dll", "int", "DeleteDC", "hwnd", $MemoryContext)
    _GDIPlus_ShutDown ()

    send("{z up}")
    send("{x up}")
    send("{c up}")
    send("{v up}")
    send("{b up}")  
EndFunc

Func end()
    DllCall("gdi32.dll", "int", "DeleteDC", "hwnd", $MemoryContext)
    _GDIPlus_ShutDown ()

    send("{z up}")
    send("{x up}")
    send("{c up}")
    send("{v up}")
    send("{b up}")  

    Exit
EndFunc

; Guitar Hero III: Legends of Rock
Func start()
        Hotkeyset("{INSERT}", "stop")
        _GDIPlus_Startup ()
        dim $down[5]
        local $detected
        $detected = false

        $MemoryContext = DllCall("gdi32.dll", "int", "CreateCompatibleDC", "int", 0)
        $MemoryContext = $MemoryContext[0]
        
        while not $Stop
            $HBITMAP = _ScreenCapture_Capture("", 200, 480, 600, 520,false)
            DllCall("gdi32.dll", "hwnd", "SelectObject", "int", $MemoryContext, "hwnd", $HBITMAP)

            ;Orange
            $Color = DLLCall("gdi32.dll","int","GetPixel","int",$MemoryContext,"int",65,"int",33)
            if BitAND($Color[0],0xFF0000) > 655360 then
                if not $down[0] then
                    send("{b down}")
                    $down[0] = true
                    $detected = true
                EndIf
            ElseIf $down[0] Then
                send("{b up}")
                $down[0] = false
            EndIf

            ;Blue
            $Color = DLLCall("gdi32.dll","int","GetPixel","int",$MemoryContext,"int",132,"int",33)
            if BitAND($Color[0],0xFF0000) > 655360 then
                if not $down[1] then
                    $detected = true
                    $down[1] = true
                    send("{v down}")
                EndIf
            ElseIf $down[1] Then
                send("{v up}")
                $down[1] = false
            EndIf
            
            ;Yellow
            $Color = DLLCall("gdi32.dll","int","GetPixel","int",$MemoryContext,"int",200,"int",34)
            if BitAND($Color[0],0xFF0000) > 655360 then
                if not $down[2] then
                    $down[2] = true
                    send("{c down}")
                    $detected = true
                EndIf
            ElseIf $down[2] Then
                send("{c up}")
                $down[2] = false
            EndIf
            
            ;Red
            $Color = DLLCall("gdi32.dll","int","GetPixel","int",$MemoryContext,"int",269,"int",33)
            if BitAND($Color[0],0xFF0000) > 655360 then
                if not $down[3] then
                    $down[3] = true
                    send("{x down}")
                    $detected = true
                EndIf
            ElseIf $down[3] Then
                send("{x up}")
                $down[3] = false
            EndIf           
            
            ;Green
            $Color = DLLCall("gdi32.dll","int","GetPixel","int",$MemoryContext,"int",336,"int",33)
            if BitAND($Color[0],0xFF0000) > 655360 then
                if not $down[4] then
                    $down[4] = true
                    send("{z down}")
                    $detected = true
                EndIf
            ElseIf $down[4] Then
                send("{z up}")
                $down[4] = false
            EndIf

            if $detected then
                send("n")
                $detected = false
                sleep(80)
            EndIf
            _WinAPI_DeleteObject($HBITMAP)
            sleep(7)
        wend
        $Stop = false
endfunc

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Looks like you'd need:

#include <GDIPlus.au3>

As an include for:

<snip>

To start up some required stuff memory wise, then:

<snip>

Which creates what you need for

<snip>

Which selects the object in memory to be processed (thanks MSDN) and then you can do:

<snip>

In which $x and $y are the pixel coordinates in the image that's in memory, which if you're taking a full size screenshot, while bill the pixel coordinates on the screen. Then, finally at the end of your script:

<snip>

To make sure after running it for a while your PC doesn't start running out of memory.

Edited by JLogan3o13

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

MY PROJECTS


Active: IRC UDF, WindowEx UDF
Discontinued: GithubBubbleSort UDF

Share this post


Link to post
Share on other sites

Thank You!!! I will not have much time tomorrow to test it, but when i do i will say something! :D

 

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

@EvilRubberDuck you seem not to have bothered to read the forum rules during your time here. Please do so now, especially the section on game automation, and you will see why this thread was locked. Do not post these types of questions again.

To other forum members, please exercise a little thought and common sense before responding to/assisting with blatant game automation threads..

Edited by JLogan3o13

When you're dead, you don't know you're dead - it's only difficult for those that know you. It's the same way when you're stupid...

My Scripts: SCCM UDFInclude Source with Compiled Script, Windows Firewall UDF

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0