Jump to content

PixelGetColor not working in game


Guest Zeliard2000
 Share

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • Moderators

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.

Link to comment
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 :) .

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...