Miliardsto

PixelGetColor - wrong colors

18 posts in this topic

#1 ·  Posted (edited)

Hello i have problem with function PixelGetColor. On my computer it working fine but in some cases it not working.

And Im clicking on the active window on red color and it give me the same color still. But in other computers when clicking on the same color red it gives other values and returned color in MsgBox is not red.

Dont know is it a real main thing what causing problem but,

I noticed that problem was on one windows 10.

I have windows 8 and working well. On other windows 10 works well to

Maybe it is caused by windows aero or something like that

How to deal with it?

There is a code

HotKeySet("{PAUSE}", "MouseCord")


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd



Func MouseCord()

    Global $MousePos = MouseGetPos()
    $clickedColor = PixelGetColor($MousePos[0], $MousePos[1])
    MsgBox(0, "Done", $clickedColor)


EndFunc

 

 

Edited by Miliardsto

Share this post


Link to post
Share on other sites



up. it worked on my friend windows 10.  dont know what was causing that this function doesnt work

Share this post


Link to post
Share on other sites

I dont know what your question exactly mean

Share this post


Link to post
Share on other sites

If you take the position of the mousepointer and check for the pixel colour, isn't it than likely that it returns the colour of the mouspointer in stead of the color of the original pixel?

Jos


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

Share this post


Link to post
Share on other sites

Just run the code below. if u click on white color it returns FFFFF if u click on blue it returns blue in rgb, red click returns nearing to FF0000.

As I said in these computers where this function not working it returns always other color if u clicking the same color.

 

 

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Timers.au3>
#include <MsgBoxConstants.au3>
#include <TabConstants.au3>
#include <ColorConstants.au3>

HotKeySet("{PAUSE}", "MouseCord")


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd



Func MouseCord()

    Global $MousePos = MouseGetPos()
    $clickedColor = Hex(PixelGetColor($MousePos[0], $MousePos[1]))
    MsgBox(0, "Done", $clickedColor)


EndFunc

 

Share this post


Link to post
Share on other sites

Please make a screenshot and post it here!

I think of problems with MouseCoordMode/ PixelCoordMode.

Share this post


Link to post
Share on other sites

in the top of my script is

Opt("MouseCoordMode", 0)
Opt("PixelCoordMode", 0)

there is no difference on my computer if it set to 1 or 0

if i click on red it gives me red

Share this post


Link to post
Share on other sites

Why don´t you post a screenshot?

Share this post


Link to post
Share on other sites

for what reason? what u want see. 10 screenshots when i click on the same position and it gives differents colors?

Share this post


Link to post
Share on other sites
11 hours ago, Miliardsto said:

 

for what reason? what u want see. 10 screenshots when i click on the same position and it gives differents colors?

 

Yes! There IS a reason, and I want to see it! 

You asked for help and support us with...nothing. Waste our time is not very solution-oriented...

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

Jos is correct it is returning the pixel at the very tip of your mouse pointer.

problem solved here.

 

Edited by Nitrolord

Share this post


Link to post
Share on other sites

#16 ·  Posted

lol . it not solve the problem. its not problem in 3 pixels right or down. 

 

cLICK ON THE same color - still same color - gives different colors

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

and Miliardsto refuses to give the name of the application. So, I have no choice but to assume it is for a game and that is against forum rules. Time to put up or stop. The name of the application you are wanting to automate please.

Edited by Bert

Share this post


Link to post
Share on other sites

#18 ·  Posted

52 minutes ago, Miliardsto said:

lol . it not solve the problem. its not problem in 3 pixels right or down. 

 

cLICK ON THE same color - still same color - gives different colors

I will do a *click* for this threat as it seems all important information is exchanged that you are willing to share.

Jos


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

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

  • Similar Content

    • Nitrolord
      By Nitrolord
      I had this problem with PixelGetColor not giving me the same HEX Color as the AU3Info Tool and searched every were with no luck then had a OH DA moment LoL.
      The problem is that the
      "PixelGetColor ($mouseX[0], $mouseY[1])"
      is looking rite at the very tip of the mouse pointer not under it.  So you have to set a -3 after the [0] and [1].  
      "PixelGetColor ($mouseX[0] -3, $mouseY[1] -3)"
      to make it search next to the pointer not on the pointer.  You may have to adjust this a bit for your display but you should not have  to go more then -5.  -3 seems to work best for me.
      Example.au3
      #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 141, 127, 276, 231) $Input1 = GUICtrlCreateInput("", 8, 8, 121, 21) $Label1 = GUICtrlCreateLabel("Press or Hold F1 to get Hex color at Mouse X -3, Y-3 Pos,", 8, 40, 124, 73) GUISetState(@SW_SHOW) HotKeySet("{f1}","MousePos") Func MousePos() $aPos = MouseGetPos() $PGC = PixelGetColor($aPos[0] -3, $aPos[1] -3) GUICtrlSetData($Input1, "0x" & Hex($PGC, 6)) EndFunc While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd  
    • WoodGrain
      By WoodGrain
      Hi All,
      I've coded the small script below, but it can't seem to get the instance of Windows Media player as it keeps going to @error, I've not used com objects before so any assistance would be appreciate. I already have WMP open and minimised. I retrieved "WMPlayerApp" from the AutoIT info tool, I've included a copy below.
      I'm using these sources:
      https://msdn.microsoft.com/en-us/library/dd564085.aspx
      https://msdn.microsoft.com/en-us/library/dd564018.aspx
      $oWMP = ObjGet("", "WMPlayerApp") If @error Then MsgBox(0, "Can't get WMP", "Couldn't connect to the WMP instance") Exit EndIf $wmpPlayState = $oWMP.playState MsgBox(0, "Play State", $wmpPlayState) $wmpSongName = $oWMP.currentMedia.name MsgBox(0, "Play State", $wmpSongName) I've also seen references to the below, but I want to get an existing open WMP:
      ObjCreate("wmplayer.OCX") and have looked at the WMP.udf but can't see how it will do either of the functions I've coded above.
       
    • WoodGrain
      By WoodGrain
      Hi All,
      I run multiple AutoIT scripts concurrently, is there a way of distinguishing between them?
      When I look under Details in task manager I just see a bunch of "AutoIt3.exe" processes. Under the processes tab I again just see a bunch of "AutoIt v3 Script" or "AutoIt v3 Script (32 bit)" applications. When I hover my mouse over the tray icon I can see the tooltip "AutoIt - Current Time.au3" but am not sure how to reference this.
      For example if I run a script called "Current Time.au3", how can I determine from another au3 script if this "Current Time.au3" script is running and grab it's handle (using WinGetHandle() or similar)? Following from that l'd even like to pause/resume the script, if that's possible..
      Cheers!
    • Szmycu
      By Szmycu
      Hello i Have HP Bar in my game and it has 170px of width and then im gonna find start of this by mouse pos then i got $hpStart[0] = 661  $hpStart[1] = 230 ,  $hpEnd[0] = 839
      And there is from $hpStart[0] = 661 the same color - 0xCB423B but depends of my points of hp for example on pixel  $hpStart[0] = 745 would be another color not  0xCB423B and then i will know my my character got 50% of health points.
       
      I encountered problem here - for loop still looping to 839 and not founding this change in color for example on pixel $hpStart[0] = 745
      I would know actual $i counter and $hpEnd[0] then only i can calculate current health percent value 
       
      Please help me how to achieve that! Thanks for any help
       
      Func MouseCord() $MousePos = MouseGetPos() global $hpStart = $MousePos global $hpEnd = $hpStart $hpEnd[0] = $hpEnd[0] + 170 For $i = $hpStart[0] To $hpEnd[0] ; Looping from 661 to 839 $pixel = PixelGetColor($i,$hpStart[1]) If $pixel <> 0xCB423B Then $hpNowPer = ( $hpEnd[0] - $i ) / 170 $hpPoOdjeciu = 1 - $hpNowPer $hpNowPercent = Round($hpPoOdjeciu,2) ExitLoop ; - that not working EndIf Next EndFunc