AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

pixelget2 - mouse follow version
Goto page 1, 2  Next
 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Serenity



Joined: 07 Nov 2004
Posts: 1271

PostPosted: Wed Feb 23, 2005 8:32 pm    Post subject: pixelget2 - mouse follow version Reply with quote



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

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


Last edited by Serenity on Thu Apr 14, 2005 6:30 pm; edited 17 times in total
Back to top
View user's profile Send private message Visit poster's website
polyethene



Joined: 11 Aug 2004
Posts: 5248
Location: UK

PostPosted: Wed Feb 23, 2005 8:47 pm    Post subject: Reply with quote

Cool, very handy.
What would be even more useful, some sorta hotkey to save the colours to colours.txt Very Happy
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Serenity



Joined: 07 Nov 2004
Posts: 1271

PostPosted: Wed Feb 23, 2005 8:57 pm    Post subject: Reply with quote

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. Smile
_________________
"Anything worth doing is worth doing slowly." - Mae West
Back to top
View user's profile Send private message Visit poster's website
procyon



Joined: 10 Feb 2005
Posts: 14
Location: Tallinn, Estonia

PostPosted: Wed Feb 23, 2005 9:02 pm    Post subject: Reply with quote

Code:
Gui, Show, NoActivate w70 h25 x%textx% y%texty%, pixelget2

needs screen coordinates Exclamation
Whenever a non maximized window is active, tooltip will jump to wrong coordinates with current code
Add:
Code:
CoordMode, Mouse, Screen
CoordMode, Pixel, Screen
Back to top
View user's profile Send private message
Serenity



Joined: 07 Nov 2004
Posts: 1271

PostPosted: Wed Feb 23, 2005 9:06 pm    Post subject: Reply with quote

procyon, thanks! I'll update the executable now. I was wondering why it was moving around when other windows were open. Confused
_________________
"Anything worth doing is worth doing slowly." - Mae West
Back to top
View user's profile Send private message Visit poster's website
Larry



Joined: 03 Mar 2005
Posts: 61

PostPosted: Thu Mar 03, 2005 4:53 am    Post subject: Get Different Results on Different Computers with this Utili Reply with quote

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.
Back to top
View user's profile Send private message
BoBo
Guest





PostPosted: Thu Mar 03, 2005 7:30 am    Post subject: Reply with quote

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 Shocked

Question
Back to top
Serenity



Joined: 07 Nov 2004
Posts: 1271

PostPosted: Thu Mar 03, 2005 8:12 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
Larry



Joined: 03 Mar 2005
Posts: 61

PostPosted: Thu Mar 03, 2005 8:39 am    Post subject: Reply with quote

Yes, I'm refering to the titlebar version and I'm using it on computers running Windows XP Pro.
Back to top
View user's profile Send private message
BoBo
Guest





PostPosted: Thu Mar 03, 2005 8:40 am    Post subject: Reply with quote

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. Shocked
Back to top
Serenity



Joined: 07 Nov 2004
Posts: 1271

PostPosted: Fri Mar 04, 2005 7:02 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
BoBo
Guest





PostPosted: Fri Mar 04, 2005 7:22 am    Post subject: Reply with quote

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
Back to top
Serenity



Joined: 07 Nov 2004
Posts: 1271

PostPosted: Fri Mar 04, 2005 7:29 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
Serenity



Joined: 07 Nov 2004
Posts: 1271

PostPosted: Sun Apr 03, 2005 11:22 pm    Post subject: Reply with quote

[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
Back to top
View user's profile Send private message Visit poster's website
polyethene



Joined: 11 Aug 2004
Posts: 5248
Location: UK

PostPosted: Mon Apr 04, 2005 12:33 am    Post subject: Reply with quote

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 Mon Apr 04, 2005 11:00 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group