Jump to content

PixelGetColor problem


Go to solution Solved by akroon,

Recommended Posts

Posted (edited)

Hi all i have a problem with function pixelgetcolor. This is the code.

#include <GUIConstantsEx.au3>#include <ColorConstants.au3>#include <WindowsConstants.au3>#include <GUIConstants.au3>#include <GuiEdit.au3>#include <File.au3>#include <INet.au3>#include <Color.au3>AutoItSetOption("MouseCoordMode", 2)GUICreate("My program",305,305)$pcheckinput=GUICtrlCreateInput("0 0 0000000",80,210,120,20)$colortaked=GUICtrlCreateGraphic(205,210,20,20)$handle = WinGetHandle("My program")If @error Then    MsgBox(4096, "Error", "Could not find program") ExitElse    MsgBox(0,"Success","program find successfully")EndIfGUISetState(@SW_SHOW)MsgBox(0,"Point checker","move mouse at the point and wait, the window will close in 5 seconds",5)$xy=MouseGetPos()GUICtrlSetData($pcheckinput,$xy[0]&" "&$xy[1]&" ")$xy=PixelGetColor($xy[0],$xy[1],$handle)GUICtrlSetData($pcheckinput,$xy,1)GUICtrlSetBkColor($colortaked,$xy)
The problem is that: the function pixelgetcolor don't return the pixelcolor of the window of "My program". This program is another program (not the program i'm running for check pixelcolor). How can solve this problem?

Thanx.

Edited by akroon
Posted

I tested your code and from what I understood, it worked just fine!

#include <GUIConstantsEx.au3>
#include <ColorConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>
#include <GuiEdit.au3>
#include <File.au3>
#include <INet.au3>
#include <Color.au3>
AutoItSetOption("MouseCoordMode", 2)
GUICreate("My program",305,305)
$pcheckinput=GUICtrlCreateInput("0 0 0000000",80,210,120,20)
$colortaked=GUICtrlCreateGraphic(205,210,20,20)
$handle = WinGetHandle("My program")
If @error Then    
   MsgBox(4096, "Error", "Could not find program")
   Exit
Else    
   MsgBox(0,"Success","program find successfully")
   EndIf
   GUISetState(@SW_SHOW)
   MsgBox(0,"Point checker","move mouse at the point and wait, the window will close in 5 seconds",5)
   $xy=MouseGetPos()
   GUICtrlSetData($pcheckinput,$xy[0]&" "&$xy[1]&" ")
   $xy=PixelGetColor($xy[0],$xy[1],$handle)
   GUICtrlSetData($pcheckinput,$xy,1)
   GUICtrlSetBkColor($colortaked,$xy)
   MsgBox(1,"",$handle)

 

Posted (edited)
  On 1/20/2014 at 9:58 PM, Palestinian said:

 

I tested your code and from what I understood, it worked just fine!

#include <GUIConstantsEx.au3>
#include <ColorConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>
#include <GuiEdit.au3>
#include <File.au3>
#include <INet.au3>
#include <Color.au3>
AutoItSetOption("MouseCoordMode", 2)
GUICreate("My program",305,305)
$pcheckinput=GUICtrlCreateInput("0 0 0000000",80,210,120,20)
$colortaked=GUICtrlCreateGraphic(205,210,20,20)
$handle = WinGetHandle("My program")
If @error Then    
   MsgBox(4096, "Error", "Could not find program")
   Exit
Else    
   MsgBox(0,"Success","program find successfully")
   EndIf
   GUISetState(@SW_SHOW)
   MsgBox(0,"Point checker","move mouse at the point and wait, the window will close in 5 seconds",5)
   $xy=MouseGetPos()
   GUICtrlSetData($pcheckinput,$xy[0]&" "&$xy[1]&" ")
   $xy=PixelGetColor($xy[0],$xy[1],$handle)
   GUICtrlSetData($pcheckinput,$xy,1)
   GUICtrlSetBkColor($colortaked,$xy)
   MsgBox(1,"",$handle)

 

Are you sure the color it get is correct? I get wrong color. You will see the color getted in guigraphich.

Edited by akroon
Posted (edited)

In order to get help, you need to clearly define the problem. More specificly this part:

"The problem is that: the function pixelgetcolor don't return the pixelcolor of the window of "My program". This program is another program (not the program i'm running for check pixelcolor). How can solve this problem?
Thanx."

You also need to describe what the problem really is: what result did you get - and what did you expect to get?

Edited by Xibalba
Posted

Are you by chance trying to pull the color from a 3D app?

MCR.jpg?t=1286371579

  Reveal hidden contents

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Posted
  On 1/22/2014 at 2:31 PM, akroon said:

Are you sure the color it get is correct? I get wrong color. You will see the color getted in guigraphich.

 

n4Wod.jpg

 

That's what I get when I use the script you provided, I pointed at the light blue color in the "au3" word.

Posted (edited)
 
  On 1/22/2014 at 10:51 PM, Damein said:

Are you by chance trying to pull the color from a 3D app?

 
 
No, it isn't
 
  On 1/23/2014 at 9:13 AM, Palestinian said:

n4Wod.jpg

 

That's what I get when I use the script you provided, I pointed at the light blue color in the "au3" word.

 

 

Try to use other little programm (like 500x500) maybe you get the right value becuase the browser is full screen. 

  On 1/23/2014 at 9:51 AM, JohnOne said:

Look at setting pixelcoordmode as well as mousecoordmode.

 

This is a good solution but i don't understand why adding handle variable at function doesn't work  :ermm:

Anyway i want get the pixel color while the window are not active. With AutoItSetOption i can only get the thinks of active windows. I really want solve this problem with PixelGetColour because it's the best way for my program. Maybe i add somenthink wrong at variable $handle ??

Please help me.

Edited by akroon
Posted
  On 1/24/2014 at 6:30 PM, JohnOne said:

So you want to get the colour of a pixel in a window that is not visible on the screen?

 

No, the windows is on the screen but is not active ("selected")

Posted

Ok i try to explain better. I have this "program" working at the corner of the screen, so i want get pixelcolor while the autoitprogram is working on another program. If you don't understand i can make some screenshot for show the situation.

  • Moderators
Posted

akroon,

 

  Quote

i can make some screenshot for show the situation

An excellent idea! :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted (edited)

post-84086-0-78312200-1390843936_thumb.p

Here's the screenshot

I want just this: the pixelgetcolor will work on the window not depending of its position ( i want be free to put where i want on the screen so can't use desktop mode)

Edited by akroon
Posted

Seeing you want to work with a webpage - you can use the IE controls built into AutoIt and do what you want with IE.

 

  On 1/22/2014 at 2:30 PM, akroon said:

No the "program" is .exe

 

Seeing you say that above when I asked you if the app was a web based application and you show a screenshot of a web browser later - that tells me you are really trying to NOT say what the name of the application is.

Cut the bullshit. What is the name of the application? So far you are wasting our time with your refusal to be straight with us.

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...