Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

Search Pixel Color From Memory Image


  • Please log in to reply
17 replies to this topic

#1 Greenseed

Greenseed

    Adventurer

  • Active Members
  • PipPip
  • 144 posts

Posted 26 January 2008 - 01:27 AM

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 ;)


AutoIt         
#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

GreenseedMCSE+I, CCNA, A+Canada, QuebecMake Love Around You.







#2 Froed

Froed

    Seeker

  • New Members
  • 2 posts

Posted 30 January 2008 - 06:55 PM

Thank you, this was helpful.

#3 nomenator

nomenator

    Seeker

  • New Members
  • 3 posts

Posted 31 January 2008 - 04:29 AM

THis is so amazing, as I was just thinking about this like 5 seconds before I decided to register on the forum and ask about it. =) This thread is going into my favourite links list. =)

#4 Manadar

Manadar

         

  • MVPs
  • 10,842 posts

Posted 31 January 2008 - 12:54 PM

Very nice!! This is very useful for OCR.

I have transformed this into an UDF and made sure I thanked you plenty of times. :D

Get Pixel from Memory-UDF

Edited by Manadar, 31 January 2008 - 02:06 PM.


#5 BillLuvsU

BillLuvsU

    Useless Member

  • Active Members
  • PipPipPipPipPipPip
  • 1,561 posts

Posted 31 January 2008 - 09:45 PM

Cool stuff.I was just planning on makin a GH3 bot last night. xD I'm getting tired of attempting to beat Through The Fire and Flames. (Can't get past the red blue oarnge repeated sweep at the end, my pinkie's just not strong enough! :cry:)

Posted Image

Working on the next big thing.Currently Playing: Halo 4, League of LegendsXBL GT: iRememberYhslaw

#6 LiLShinta

LiLShinta

    Wayfarer

  • Active Members
  • Pip
  • 58 posts

Posted 07 May 2008 - 03:53 AM

what is this gdi.dll?

#7 Malkey

Malkey

  • Active Members
  • PipPipPipPipPipPip
  • 1,512 posts

Posted 07 May 2008 - 04:20 AM

what is this gdi.dll?

gdi32.dll and gdiplus.dll are two of the many dll files found at C:\WINDOWS\system32 on MSWindow systems. They come with the Windows installation.
Look at the thread :-

http://www.autoitscript.com/forum/index.ph...st&p=364168

It is very informative.

#8 LiLShinta

LiLShinta

    Wayfarer

  • Active Members
  • Pip
  • 58 posts

Posted 07 May 2008 - 06:45 AM

ahmm..how about the color... how did autoit know if the right color is met to send keys..

#9 Manadar

Manadar

         

  • MVPs
  • 10,842 posts

Posted 07 May 2008 - 08:40 AM

ahmm..how about the color... how did autoit know if the right color is met to send keys..

This is probably a bit more descriptive: http://www.autoitscript.com/forum/index.php?showtopic=63318

#10 LiLShinta

LiLShinta

    Wayfarer

  • Active Members
  • Pip
  • 58 posts

Posted 08 May 2008 - 04:10 AM

but the link is error on your udf.

#11 BAM5

BAM5

    Wayfarer

  • Active Members
  • Pip
  • 90 posts

Posted 14 May 2008 - 04:49 AM

WOOT, Well I'm happy somebody finally got the pixel get color function in gdi to work, I've tried months ago for like a week then finally gave up, I guess I was calling the wrong function... :/

#12 uzi17

uzi17

    Seeker

  • Active Members
  • 16 posts

Posted 02 November 2008 - 10:23 AM

hmm i was googling for a gh3 PC bot and it took me here lol

are there any gh3 pc bots out? if so care to share? :mellow:

#13 RATIOFighter

RATIOFighter

    Seeker

  • New Members
  • 2 posts

Posted 10 June 2010 - 02:02 PM

Thanks. Have been searching on how to do this.

#14 yahaosoft

yahaosoft

    Seeker

  • Active Members
  • 18 posts

Posted 18 December 2012 - 09:16 PM

it give me a lot of help,say THANK YOU! :ILA2:
Thanksgiving...

#15 Jos

Jos

    ...

  • Developers
  • 23,227 posts

Posted 18 December 2012 - 09:23 PM

Could you please stop resurrecting old threads just because you are happy you could use them?

Thanks
Jos

Visit the SciTE4AutoIt3 Download page for the latest versions                                                                 Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)


#16 JScript

JScript

    I'm back ... I miss, why not!

  • Active Members
  • PipPipPipPipPipPip
  • 1,219 posts

Posted 18 December 2012 - 09:51 PM

Could you please stop resurrecting old threads just because you are happy you could use them?

Thanks
Jos

I think this policy of not resuscitating old post very strange, see:
The date of this topic is: Posted 25 January 2008 - 11:27 PM

@Manadar created this: Get or Read Pixel from Memory UDF - PixelGetColor .au3 in: Posted 31 January 2008 - 12:03 PM
And nobody complained about resurrect it!

I would be very happy if someone answered anything in my thread that was quite old, sure I would reply and update content!

Edit: If we can not resurrect old threads, it makes no sense to store them in the database.

Just an opinion,

JS

Edited by JScript, 18 December 2012 - 09:54 PM.

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)
Spoiler

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!       


#17 Jos

Jos

    ...

  • Developers
  • 23,227 posts

Posted 18 December 2012 - 09:54 PM

I have no issue when the post is relevant but there is no relevancy and not contribution to the thread here.
Other than that we will not discuss nor negotiate anything around our forums rules. They have evolved over the past years into what they are now.


Jos

Visit the SciTE4AutoIt3 Download page for the latest versions                                                                 Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)


#18 JohnOne

JohnOne

    John

  • Active Members
  • PipPipPipPipPipPip
  • 12,279 posts

Posted 18 December 2012 - 10:09 PM

Just hit the rate star or/and the up button of the Person you wish to thank (if that's all you want to do)

AutoIt Absolute Beginners Require a serial
 
 
OMG! Women are the cows of people.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users