Jump to content

Advice and help on pixelgetcolor


Recommended Posts

I'm hoping to make my own pixelgetcolor script. If someone has experience on this or knows some issues I might run into please let me know.

I am trying to make tooltip script for the mouse that will (if possible) get the color of the pixel relative to the mouse location with 100% accuracy. In the past I had an issue with some of these scripts, but I'm not sure if it was the code that was used, or if it was possibly a limitation of the computer and autoit script. The issue I'm referring to -- the tooltip script would sometimes report the wrong hex color.

For better accuracy, is it better to use hex color or decimal color?

 

Why does a tooltip title require IE5? That is internet explorer 5, correct? Does that mean I just need that installed on my computer?

In the guide for pixelgetcolor it shows:

PixelGetColor ( x , y [, hwnd] )

what does hwnd do in more detail or can you give me an example?

Edited by element72
Link to comment
Share on other sites

Hi,
Welcome to the autoit forum :)
 

Local $iColor = 0, $aMgp = 0

While 1
    $aMgp = MouseGetPos()
    $iColor = PixelGetColor($aMgp[0], $aMgp[1])
    ToolTip("Color: 0x" & Hex($iColor, 6), $aMgp[0] + 10, $aMgp[1] + 10)
    Sleep(10)
WEnd

 
 

For better accuracy, is it better to use hex color or decimal color?

It's the same thing, the only difference is that it's not written on the same base (Decimal = base 10, Hex = base 16).
 
 

That is internet explorer 5, correct? Does that mean I just need that installed on my computer?

 Correct. I would be surprised you haven't IE 5 installed on your computer or it's older than XP.
 

what does hwnd do in more detail or can you give me an example?

It means it will take the top-left corner of the window as starting coords.

Br, FireFox.

Link to comment
Share on other sites

When it says requires IE5 it means that it requires at least IE5, not that you need IE5 installed on the computer. You'd be really hard pressed to find that version and then to get installed on a current OS would be a tough process if it worked at all.

EDIT: Looking at the help file, it clearly says IE5+, so that is already covered in there.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I'm having trouble trying to copy hexcolor and mouse coordinates to clipboard. Can you please give me more detail on what clipput and clipget are doing? Sorry, I'm such a noob :(

 

I'm using the code above that was provided by firefox.

Link to comment
Share on other sites

ClipPut($iColor)

Read the helpfile.

ok that reinforced what I knew. I still have the problem of copying certain values to the clipboard. I know it copies texts, but I'm having trouble getting it to copy hexcolor and mouse coordinates.

Edited by element72
Link to comment
Share on other sites

Be more descriptive.

I can only get the function to copy text.

 

 

 

HotKeySet("{ESC}", "Terminate")
HotKeySet("{c}", "Copy")


Local $iColor = 0, $aMgp = 0

While 1
    $aMgp = MouseGetPos()
    $iColor = PixelGetColor($aMgp[0], $aMgp[1])
    ToolTip("Color: 0x" & Hex($iColor, 6), $aMgp[0] + 10, $aMgp[1] + 10)
    Sleep(10)
WEnd

Func Copy()
    ; Add new data to the clipboard.
    ClipPut() = "0x" & Hex($iColor, 6)
    ; Display the data returned by ClipGet.
    MsgBox($MB_SYSTEMMODAL, "", "The following data is now stored in the clipboard: " & "Color: 0x" & Hex($iColor,6))
EndFunc   ;==>Terminate

Func Terminate()
    Exit
EndFunc   ;==>Terminate
Edited by element72
Link to comment
Share on other sites

 

Seriously? 

ClipPut() = "0x" & Hex($iColor, 6)

Thanks for all the help. I have one last thing I'm trying to do. I want to be able to play a video file or a music file as an alarm when my script detects a change. Can you give me advice on this? I've been reading that wav should be preferred over mp3. 

Is there a command like Run which executes programs, but instead for video or music files?

Edited by element72
Link to comment
Share on other sites

  • Moderators

element72,

Look in the Help file (always a good place to start!) and read about SoundPlay & _SoundPlay. ;)

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:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Ok how come i can't terminate the script while the sound is playing?

Edit: Maybe I should allow the music file to play while the script continues, but I halt the script using a sleep command with the same time duration as the sound file. This would allow me to terminate anytime while the sound file is playing, correct? 

Edited by element72
Link to comment
Share on other sites

  • Moderators

element72,

I suggest you play a shorter sound in a loop and check whether you need to exit each pass. :)

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:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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