Jump to content
Sign in to follow this  
Guest Zeliard2000

PixelGetColor not working in game

Recommended Posts

Guest Zeliard2000

Hi guys,

I've been trying to write a simple program that reads in the color of a certain pixel in game. Then if the pixel color matches, it performs a right-click. But the problem i'm having is that when using PixelGetColor, instead of reading a pixel from the game, it reads in a pixel from my Desktop background. Can someone help me with this, thanks.

Here's my code:

Global $Paused
HotKeySet("{CAPSLOCK}", "TogglePause")
Dim $v1
Dim $v2 = 11730944
While 1
    sleep(100)
    $v1 = PixelGetColor(3611, 847)
    If $v1 == $v2 Then
        MouseClick("right")
    EndIf
WEnd

Func TogglePause()
    $Paused = NOT $Paused
  While $Paused
      sleep(100)
  WEnd
EndFunc

Share this post


Link to post
Share on other sites
buzz44

I wish my monitor was 3611 pixels wide... Either typo or you have 3-4 monitors in wish case you'll have to do some experimenting depending if the game is full screen and at what resolution etc.

Edited by Burrup

qq

Share this post


Link to post
Share on other sites
SmOke_N

Try this if it's reading your desktop

Opt("PixelCoordMode", 0); set get color to active window
Opt("MouseCoordMode", 0); set mouseclick to active window

WinActivate("Your Game Title Here")
Global $Paused
HotKeySet("{CAPSLOCK}", "TogglePause")
Dim $v1
Dim $v2 = 11730944

While WinExist("Your Game Title Here")
    sleep(100)
    $v1 = PixelGetColor(3611, 847)
    If $v1 == $v2 Then
        MouseClick("right")
    EndIf
WEnd

Func TogglePause()
    $Paused = NOT $Paused
  While $Paused
      sleep(100)
  WEnd
EndFunc

Hope this helps.

Edited by ronsrules

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
Guest Zeliard2000

Try this if it's reading your desktop

Opt("PixelCoordMode", 0); set get color to active window
Opt("MouseCoordMode", 0); set mouseclick to active window

WinActivate("Your Game Title Here")
Global $Paused
HotKeySet("{CAPSLOCK}", "TogglePause")
Dim $v1
Dim $v2 = 11730944

While WinExist("Your Game Title Here")
    sleep(100)
    $v1 = PixelGetColor(3611, 847)
    If $v1 == $v2 Then
        MouseClick("right")
    EndIf
WEnd

Func TogglePause()
    $Paused = NOT $Paused
  While $Paused
      sleep(100)
  WEnd
EndFunc

Hope this helps.

<{POST_SNAPBACK}>

Hmm, i'll try it out, thanks for the help.

P.S. Yikes, now that I think about it, there's no way my monitor could have a 3611 resolution size in it. Adobe photoshop must be using some other kind of unit, thanks for pointing that out :) .

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  

×