Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Zoomer magnifier


  • Please log in to reply
5 replies to this topic

Poll: Useful script? (4 member(s) have cast votes)

Useful script?

  1. Great! I'll use it all the time! (0 votes [0.00%])

    Percentage of vote: 0.00%

  2. Thanks, added to my collection. (3 votes [75.00%])

    Percentage of vote: 75.00%

  3. Cool but not for me. (1 votes [25.00%])

    Percentage of vote: 25.00%

Vote Guests cannot vote
Watcher
  • Members
  • 60 posts
  • Last active: Apr 06 2005 01:57 PM
  • Joined: 27 Dec 2004

;   Written by Watcher aka Bill DeVos with, as always, help

; from the forums at www.autohotkey.com.



;  This program was a small project to give me the ability

; to pick an individual pixel for another project.  Simply 

; put it gives you a zoomed view of the point that your

; cursor is on and the 24 pixles around it.  AHK is probably

; not the best program to do this with, the screen flashes a 

; bit but you can adjust the speed easily which helps.



; Oh, and Win-Q does the same as the Button and Win-W does the paste



Z_UpdateSpeed = 100 ; This is the default screen update speed

ZoomerOn =          ; This sets Zoomer to off,

                    ; it's started after the interface is created.





Gui, Add, Button, x6 y10 w80 h30 gButtonZoomer, Zoomer Off



Gui, Add, Progress, x4 y60 w30 h30 vPixel1, Pixel1

Gui, Add, Progress, x34 y60 w30 h30 vPixel2, Pixel2

Gui, Add, Progress, x64 y60 w30 h30 vPixel3, Pixel3

Gui, Add, Progress, x94 y60 w30 h30 vPixel4, Pixel4

Gui, Add, Progress, x124 y60 w30 h30 vPixel5, Pixel5



Gui, Add, Progress, x4 y90 w30 h30 vPixel6, Pixel6

Gui, Add, Progress, x34 y90 w30 h30 vPixel7, Pixel7

Gui, Add, Progress, x64 y90 w30 h30 vPixel8, Pixel8

Gui, Add, Progress, x94 y90 w30 h30 vPixel9, Pixel9

Gui, Add, Progress, x124 y90 w30 h30 vPixel10, Pixel10



Gui, Add, Progress, x4 y120 w30 h30 vPixel11, Pixel11

Gui, Add, Progress, x34 y120 w30 h30 vPixel12, Pixel12

Gui, Add, Progress, x64 y120 w30 h30 +Border vPixel13, Pixel13

GuiControl, Move, Pixel13, w31 h31 

Gui, Add, Progress, x94 y120 w30 h30 vPixel14, Pixel14

Gui, Add, Progress, x124 y120 w30 h30 vPixel15, Pixel15



Gui, Add, Progress, x4 y150 w30 h30 vPixel16, Pixel16

Gui, Add, Progress, x34 y150 w30 h30 vPixel17, Pixel17

Gui, Add, Progress, x64 y150 w30 h30 vPixel18, Pixel18

Gui, Add, Progress, x94 y150 w30 h30 vPixel19, Pixel19

Gui, Add, Progress, x124 y150 w30 h30 vPixel20, Pixel20



Gui, Add, Progress, x4 y180 w30 h30 vPixel21, Pixel21

Gui, Add, Progress, x34 y180 w30 h30 vPixel22, Pixel22

Gui, Add, Progress, x64 y180 w30 h30 vPixel23, Pixel23

Gui, Add, Progress, x94 y180 w30 h30 vPixel24, Pixel24

Gui, Add, Progress, x124 y180 w30 h30 vPixel25, Pixel25



Gui, Show, x70 y50 w158 h207, Zoomer

Gui, +AlwaysOnTop +ToolWindow



Gosub ButtonZoomer

Return



GuiEscape:

GuiClose:

ExitApp



#w::

if ZoomerOn     ; If Zoomer isn't On, don't set DoPaste flag.

  DoPaste = 1

return



#q::            ; Cheap trick to have hotkey toggle Zoomer on/off

ButtonZoomer:

{

  if ZoomerOn

  {

    ZoomerOn =

    SetTimer, Zoomer, off

    ControlSetText Zoomer, Zoomer On, Zoomer

    Gosub RemoveToolTip

  } 

  else

  {

    ZoomerOn = 1

    SetTimer, Zoomer,  %Z_UpdateSpeed%

    ControlSetText Zoomer, Zoomer Off, Zoomer

  }

  return

}



RemoveToolTip:

{

  SetTimer, RemoveToolTip, Off

  ToolTip

  return

}



Zoomer:

{

  RangeX = -2,-1,0,1,2

  RangeY = -2,-1,0,1,2

  MouseGetPos, X, Y

  PixelGetColor, PixelColor, X, Y, RGB

  ToolTip X %X% Y %Y% C %PixelColor%

  if DoPaste

  {

    DoPaste =

    Clipboard = %X% %Y% %PixelColor%

  }

  Loopcount = 0

  Loop Parse, RangeY, CSV

  {

    ParseY = %A_LoopField%

    Loop Parse, RangeX, CSV

    {

      Loopcount += 1

      ParseX = %A_LoopField%

      PixelGetColor, PixelColor, (X + ParseX), (Y + ParseY), RGB

      GuiControl +Background%PixelColor%, Pixel%Loopcount%

    }

  }



  Return

}

[/code]

BoBo
  • Guests
  • Last active:
  • Joined: --
Great stuff !
I've tested it.
Btw: Great stuff !!
Thx for sharing it :D

Little tweak. Use the Forums code option to label your code as code. :wink:

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
yeah this is nice!

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


tg3793
  • Members
  • 12 posts
  • Last active: Feb 03 2010 06:31 PM
  • Joined: 19 Jan 2010
Sorry didn't work for me. Running Window XP Home SP3

sinkfaze
  • Moderators
  • 6367 posts
  • Last active: Nov 30 2018 08:50 PM
  • Joined: 18 Mar 2008
The script works fine for me on XP Pro SP3 but keep in mind this script is very outdated. This technique has been improved upon, for example, in toralf's AHK Window Info script.

Make sure that you're using the latest version of AHK.

tidbit
  • Administrators
  • 2709 posts
  • Hates playing Janitor
  • Last active: Jan 15 2016 11:37 PM
  • Joined: 09 Mar 2008
My edited version of "color zoomer". A plugin for my personal 'Mango' script.
- no color selector
- zoom out with -
- zoom in with =
- escape with Esc
- re-positions so it doesn't go off-screen

; Mango: Magnifier
; Creator: Sean (Color Zoomer)
; Modified: tidbit
; Version: 1.10

CoordMode, ToolTip, Screen
ToolTip, 
(
- --- Zoom out
= --- Zoom in
Esc --- Exit
)
, 0, 0

#NoEnv
#SingleInstance, Force

SetWinDelay, 10
CoordMode, Mouse
DetectHiddenWindows, On
SetTimer, RemovetoolTip, 8000 ; very bottom of script
Zoomer()

Return
-::Return
=::Return
~Esc::ExitApp

Zoomer()
{
   nZ := 3                    ; Zoom Factor
   nR := 256//2//nZ*nZ - 1      ; Rectangle of the Zoomer

   VarSetCapacity(nColor,63)
   nColor := A_Space
   VarSetCapacity(ti, 40, 0)
   ti := Chr(40)
   DllCall("ntdll\RtlFillMemoryUlong", "Uint", &ti + 4, "Uint", 4, "Uint", 0x20)
   DllCall("ntdll\RtlFillMemoryUlong", "Uint", &ti +36, "Uint", 4, "Uint", &nColor)

   hWnd := DllCall("CreateWindowEx", "Uint", 0x08000008, "str", "tooltips_class32", "str", "", "Uint", 0x3, "int", 0, "int", 0, "int", 0, "int", 0, "Uint", 0, "Uint", 0, "Uint", 0, "Uint", 0)

   DllCall("SetClassLong", "Uint", hWnd, "int", -12, "int", DllCall("LoadCursor", "Uint", 0, "Uint", 32515))

   SendMessage, 1028, 0, &ti,, ahk_id %hWnd%
   SendMessage, 1041, 1, &ti,, ahk_id %hWnd%
   SendMessage, 1036, 0, &ti,, ahk_id %hWnd%

   hDC_SC := DllCall("GetDC", "Uint",    0)
   hDC_TT := DllCall("GetDC", "Uint", hWnd)

   Loop
   {
      MouseGetPos, xCursor, yCursor
      DllCall("StretchBlt", "Uint", hDC_TT, "int", 0, "int", 0, "int", 2*nR, "int", 2*nR, "Uint", hDC_SC, "int", xCursor-nR//nZ, "int", yCursor-nR//nZ, "int", 2*nR//nZ, "int", 2*nR//nZ, "Uint", 0x00CC0020)
    
	if (xCursor>=A_ScreenWidth//2)
		xcurpos:=xCursor-(nR+1)-(nR+5)
	 Else
		xcurpos:=xCursor-(nR+1)+(nR+5)
		
	if (yCursor>=A_ScreenHeight//2)
		ycurpos:=yCursor-(nR+1)-(nR+5)
	 Else
		ycurpos:=yCursor-(nR+1)+(nR+5)
		

	 
	 WinMove, ahk_id %hWnd%,, xcurpos, ycurpos, 2*(nR+1), 2*(nR+1)   ; 1-pixel border
	 WinSet, AlwaysOnTop, On, ahk_id %hWnd% 
	 ; WinMove, ahk_id %hWnd%,, xCursor-(nR+1)+(nR+5), yCursor-(nR+1)-(nR+5), 2*(nR+1), 2*(nR+1)   ; 1-pixel border
	 
		If GetKeyState("=")
		{
			nZ+=1
			sleep, 200
		}
		If GetKeyState("-")
		{
			nZ-=1
			sleep, 200
		}

	   }
   }

Cursor(hDC, xCenter, yCenter)
{
   VarSetCapacity(mi, 20, 0)
   mi := Chr(20)
   DllCall("GetCursorInfo", "Uint", &mi)

   ptr := &mi + 4
   bShow   := *ptr++ | *ptr++ << 8 | *ptr++ << 16 | *ptr++ << 24
   hCursor := *ptr++ | *ptr++ << 8 | *ptr++ << 16 | *ptr++ << 24

   DllCall("GetIconInfo", "Uint", hCursor, "Uint", &mi)

   ptr := &mi + 4
   xHotspot := *ptr++ | *ptr++ << 8 | *ptr++ << 16 | *ptr++ << 24
   yHotspot := *ptr++ | *ptr++ << 8 | *ptr++ << 16 | *ptr++ << 24
   hBMMask  := *ptr++ | *ptr++ << 8 | *ptr++ << 16 | *ptr++ << 24
   hBMColor := *ptr++ | *ptr++ << 8 | *ptr++ << 16 | *ptr++ << 24

   DllCall("DeleteObject", "Uint", hBMMask)
   DllCall("DeleteObject", "Uint", hBMColor)

   If bShow
   DllCall("DrawIcon", "Uint", hDC, "int", xCenter - xHotspot, "int", yCenter - yHotspot, "Uint", hCursor)
}


RemovetoolTip:
SetTimer, RemovetoolTip, Off
Tooltip
return

rawr. be very afraid
*poke*
. Populate the AutoHotkey city. Pointless but somewhat fun. .