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

    • astrionn
      By astrionn
      So I had this Idea of creating a tooltip which shows me my ping.
      That itself was made quickly and I thought too add a couple features.
      I want the tooltip background to be a different color depending on the ping. (good ping is green, medium ping is yellow,...)
      So how do I color in a tooltip? google brought me to this: 
       
      where in the comments I found this:
      $s = "LOW" ToolTip($s, 0, 0, "Battery Information");, $icon) $H_TOOLTIP1 = WinGetHandle($s) DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", $H_TOOLTIP1, "wstr", "", "wstr", "") DllCall("user32.dll", "int", "SendMessage", "hwnd", $H_TOOLTIP1, "int", 1043, "int", 2552550, "int", 0) Sleep(1000) Which I then used in my code with different color codes... Trial and Error brought me these that I wanted to use:
       
      The Problem is if I loop through my code it only sets the color for the 1st loop and then sticks to it.
      The real problem is tho that I don't exactly understand the dllcalls... And I guess that's why it isn't working
      So if someone would be so awesome to explain to me how they work, or at least can give me a list of these parameters then I would really appreciate that and learn something new
      Obviously a solution to my problem is awesome aswell ^^
      I run this under Windows 8.1
      There is my code in a paste.
      https://pastebin.com/q525f7mS
    • cosmos
      By cosmos
      I must be missing something but I can't seem to work out how to open the standard Windows Color dialog box?
      Basically the equivalent of InputBox but for colors (so that the user can select a color). I think there are some external UDFs for this, but are there any ways of doing it with included UDFs, standard AutoIt functions or interfacing with Windows directly?
      Usage info: I'm making a database-like program and there are Categories (which work similar to Tables), and the user will be able to select unique colors for Categories so when they display multiple Categories at once (like displaying multiple Tables with similar columns in one list ) they can easily differentiate the Categories at quick glance.
      Thanks!
    • chacoya121
      By chacoya121
      Local $count = 1 Local $x1= 100,$y1 = 100,$x2 = 110,$y2 = 110 $area = ($x2+$x1)*($y2+$y1) Local $array[$area][2] For $i = $x1 to $x2 Step 1 For $j = $y1 to $y2 Step 1 $color = PixelGetColor($i,$j) $scolor = Hex($color,6) $array[$count][2] = [$scolor,1] $position = _ArraySearch($array,$scolor,0,0,0,0,1) If $array[$position][0] = $scolor Then $array[$position][1] +=1 Else $count += 1 EndIf Next Next _ArrayDisplay($array) plz help adjust and shrink it down soo confusing playing with array
    • 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