AutoHotkey Community

It is currently May 25th, 2012, 9:00 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 21 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: February 23rd, 2005, 9:32 pm 
Offline

Joined: November 8th, 2004, 12:46 am
Posts: 1271
Image

Download

Pixelget2 will follow your cursor around the screen, showing the current pixel color in a small tooltip-like display nearby. The middle mouse button copies the current color to clipboard in RGB format, ready for pasting anywhere you like. Click on the tray icon to toggle GUI hide/show. User can customise font and background color via .ini file. :)

Changelog:
* Added hotkey for collecting colors [Ctrl]+[F] - writes the current color value to colors.txt - useful when want to get lots of colors, new values are appended to file automatically. (Thanks Titan for the idea!)
* Changed name of .ini file to avoid confusion with .txt file created in same directory.
* Added option to change hotkeys for collecting colors and copy to clipboard via .ini file.
* Added color mode option - user can now choose between pasting color values as hexidecimal or decimal.
* Pixelget2 now autoadjusts its position when the mouse is near the right/bottom edge of the screen to keep it showing on screen. (Thanks Titan!)

Code:
#SingleInstance force
setbatchlines, -1
SetWinDelay, -1
menu, tray, tip, pixelget2
CoordMode, Mouse, Screen
CoordMode, Pixel, Screen
toggle = 0

IniRead, FontColor, settings.ini, font, color
IniRead, BGColor, settings.ini, background, color
IniRead, Clpbrd, settings.ini, to clipboard, hotkey
IniRead, Cllct, settings.ini, collect colors, hotkey
IniRead, Mode, settings.ini, color mode, hex/dec
Hotkey, %Clpbrd%, Clipboard
Hotkey, %Cllct%, Collect
sleep, 100

Gui, +ToolWindow +AlwaysOnTop -SysMenu -Caption +Border
Gui, color, c%bgcolor%
Gui, Font, c%fontcolor% s8 wBold, Lucida Console
Gui, Add, Text, x2 y7 w66 +center vCurrentPixel, %color%
SetTimer, Get, 100

Menu, Tray, NoStandard ; only use this menu
Menu, Tray, Click, 1  ; Remove this line if you prefer double-click vs. single-click.
Menu, Tray, Add, &Show/Hide, View
Menu, Tray, Default, &Show/Hide
Menu, Tray, Add, &Edit Settings, Settings
Menu, Tray, Add, &Reload, Reload
Menu, Tray, Add, E&xit, Exit
return

Get:
MouseGetPos, MouseX, MouseY ; get mouse coords

if (MouseX >= (A_ScreenWidth * 0.90))
  textx := MouseX - 80
else
  textx := MouseX + 20

if (MouseY >= (A_ScreenHeight * 0.92))
  texty := MouseY - 40
else
  texty := MouseY + 20

PixelGetColor, color, %MouseX%, %MouseY%, RGB ; get pixel color
GuiControl, , CurrentPixel, %color%
Gui, Show, NoActivate w70 h25 x%textx% y%texty%, pixelget2
return

Clipboard:
  ControlGetText, color, Static1, pixelget2
  StringTrimLeft, color, color, 2
  if mode = dec
    gosub, hex2dec
  else
    Clipboard = %color%
    Return

Collect:
  ControlGetText, color, Static1, pixelget2
  StringTrimLeft, color, color, 2
  if mode = dec
  {
    gosub, hex2dec
    FileAppend, %color%`n, colors.txt
    return   
  }
  else
    Clipboard = %color%
    FileAppend, %color% `n, colors.txt
    return

^Q::
exitapp

View:
if toggle = 0
{
  toggle = 1
  Gui, Submit
  SetTimer, Get, off
  pause
  suspend
}
else
{
  toggle = 0
  SetTimer, Get, 100
  pause
  suspend
}
return

Settings:
run, settings.ini
return

Reload:
reload
return

Exit:
exitapp

hex2dec:
StringMid, r, color, 1, 2
StringMid, g, color, 3, 2
StringMid, b, color, 5, 2

red = 0x%r%
green = 0x%g%
blue = 0x%b%

SetFormat, integer, d
red += 0
green +=0
blue +=0
SetFormat, integer, hex

color = %red%`,%green%`,%blue%
Clipboard = %color%
return

_________________
"Anything worth doing is worth doing slowly." - Mae West
Image


Last edited by Serenity on April 14th, 2005, 7:30 pm, edited 17 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 23rd, 2005, 9:47 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5346
Location: UK
Cool, very handy.
What would be even more useful, some sorta hotkey to save the colours to colours.txt :D


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 23rd, 2005, 9:57 pm 
Offline

Joined: November 8th, 2004, 12:46 am
Posts: 1271
Nice idea Titan- the hotkey/hotstring could append each color pasted in rather than replacing the same one over, which would save having to paste each value in somewhere, especially if collecting more than a few colors at a time. :)

_________________
"Anything worth doing is worth doing slowly." - Mae West
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 23rd, 2005, 10:02 pm 
Offline

Joined: February 10th, 2005, 7:51 pm
Posts: 14
Location: Tallinn, Estonia
Code:
Gui, Show, NoActivate w70 h25 x%textx% y%texty%, pixelget2

needs screen coordinates :!:
Whenever a non maximized window is active, tooltip will jump to wrong coordinates with current code
Add:
Code:
CoordMode, Mouse, Screen
CoordMode, Pixel, Screen


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 23rd, 2005, 10:06 pm 
Offline

Joined: November 8th, 2004, 12:46 am
Posts: 1271
procyon, thanks! I'll update the executable now. I was wondering why it was moving around when other windows were open. :?

_________________
"Anything worth doing is worth doing slowly." - Mae West
Image


Report this post
Top
 Profile  
Reply with quote  
PostPosted: March 3rd, 2005, 5:53 am 
Offline

Joined: March 3rd, 2005, 5:43 am
Posts: 62
Hi Guys,

I'm a newbie here having lots of fun playing with AutoHotKey.
I wonder if anyone can explain the strange results I'm getting with PixelGet2 here. My screen resolution is 1024x768 on all my computers.

On one computer, when I maximize the window and move the mouse pointer to the top left corner of the screen, PixelGet2 displays x = -550 and y = 0.

On another computer when I do the same thing, it show x = 4 and y = 4.

How come it's not displaying x = 0, and y = 0 ?

Would appreciate a solution to this if anyone has one....

Thanks.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 3rd, 2005, 8:30 am 
Same with mine, but with MouseGetPos!
Quote:
when I maximize the window
I guess those coords are created as a result that the system is positioning a full screen (except the "Desktop" itself) window using kinda "cascading style" (4,4). But that behaviour seems not to be strict. I had results like 32000,32000 :shock:

:?:


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 3rd, 2005, 9:12 am 
Offline

Joined: November 8th, 2004, 12:46 am
Posts: 1271
This script is not meant to display screen coords but the rgb value of the current pixel in hexidecimal. Are you referring to the titlebar version? I've tested the titlebar script on 800x600 and 1024x768 and it works fine at those resolutions here.

_________________
"Anything worth doing is worth doing slowly." - Mae West
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 3rd, 2005, 9:39 am 
Offline

Joined: March 3rd, 2005, 5:43 am
Posts: 62
Yes, I'm refering to the titlebar version and I'm using it on computers running Windows XP Pro.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 3rd, 2005, 9:40 am 
Quote:
but the rgb value of the current pixel
I guess, Rajat's request was more in general, and yes you're correct. As long as you provide just the color code on a WYSIWYG-coord-basis (ie 0,0 the topmost left coord). Once you provide the coords itself together with the color code it could become tricky/irritating, isn't it ?

Expect you tell Rajat by phone "we've to change the color at 122,345 to light green" and the coords which have been detected at your screen are different to the one at his screen, regardless that you both look at the same pixel. :shock:


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 4th, 2005, 8:02 am 
Offline

Joined: November 8th, 2004, 12:46 am
Posts: 1271
Larry, BoBo, do you get the same results if the coords and current pixel values are displayed in a tooltip? I'm wondering if this is an issue with using both in a gui or perhaps the OS. I'm running 2k sp4.

Code:
; display current screen coords and pixel color in a tooltip

loop
{
Coordmode, Mouse, Screen
MouseGetPos, MouseX, MouseY
PixelGetColor, Color, %MouseX%, %MouseY%, RGB
tooltip, %Color% `nx%MouseX% y%MouseY%
sleep, 10
}

_________________
"Anything worth doing is worth doing slowly." - Mae West
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 4th, 2005, 8:22 am 
visual mousepos 0,0 | 1024,0 | 1024,768 | 0,768
tooltip mousepos 0,0 | 1023,0 | 1023,767 | 0,767

A_ScreenWidth = 1024
A_ScreenHeight = 768

W2k Sp4
AHK 1.0.26.0


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 4th, 2005, 8:29 am 
Offline

Joined: November 8th, 2004, 12:46 am
Posts: 1271
That makes sense as the values are displayed 0-799, 0-599 here, for what is 800x600. 0 is the first pixel. When I compiled the script I was using version 1.0.27.

_________________
"Anything worth doing is worth doing slowly." - Mae West
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 4th, 2005, 12:22 am 
Offline

Joined: November 8th, 2004, 12:46 am
Posts: 1271
[update]
Added color mode option - user can now choose between pasting color values as hexidecimal or decimal.

_________________
"Anything worth doing is worth doing slowly." - Mae West
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 4th, 2005, 1:33 am 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5346
Location: UK
Yeah, a definetly very useful script.
An addition I put for myself was a capture of a few more details in the 'Collect' routine:
Code:
    MouseGetPos, captX, captY, captWin, captControl
    captFullDetail = - Window: ID_%captWin%`n     > Control: %captControl%`n- Mouse: (x%captX%`, y%captY%)`n- Time (YYYYMMDDHH24MISS): %A_Now%`n`n
   FileAppend, Colour: %color%`n-------------------------`n%captFullDetail%, colors.txt


It'd be cool if the box bounced up or changed position if the cursor falls below the lower region of the screen (where it usually gets hidden):
e.g.
Code:
if (MouseY >= (A_ScreenHeight * 0.85))
   texty := MouseY - 20
else
   texty := MouseY + 20


Edit: Removed the "" in above code to make it work!

_________________
GitHubScriptsIronAHK Contact by email not private message.


Last edited by polyethene on April 5th, 2005, 12:00 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 21 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], lblb, RoAltmann and 8 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group