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 

Zoomer magnifier

 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  

Useful script?
Great! I'll use it all the time!
0%
 0%  [ 0 ]
Thanks, added to my collection.
75%
 75%  [ 3 ]
Cool but not for me.
25%
 25%  [ 1 ]
Total Votes : 4

Author Message
Watcher



Joined: 27 Dec 2004
Posts: 60

PostPosted: Mon Feb 14, 2005 5:48 am    Post subject: Zoomer magnifier Reply with quote

Code:

;   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]

Last edited by Watcher on Mon Feb 14, 2005 9:37 am; edited 1 time in total
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
BoBo
Guest





PostPosted: Mon Feb 14, 2005 9:19 am    Post subject: Reply with quote

Great stuff !
I've tested it.
Btw: Great stuff !!
Thx for sharing it Very Happy

Little tweak. Use the Forums code option to label your code as code. Wink
Back to top
Rajat



Joined: 28 Mar 2004
Posts: 1687

PostPosted: Mon Feb 14, 2005 9:30 am    Post subject: Reply with quote

yeah this is nice!
_________________
Back to top
View user's profile Send private message
tg3793



Joined: 19 Jan 2010
Posts: 12
Location: Philippines

PostPosted: Tue Jan 19, 2010 2:09 pm    Post subject: Reply with quote

Sorry didn't work for me. Running Window XP Home SP3
Back to top
View user's profile Send private message
sinkfaze



Joined: 18 Mar 2008
Posts: 5043
Location: the tunnel(?=light)

PostPosted: Tue Jan 19, 2010 4:01 pm    Post subject: Reply with quote

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.
_________________
Try Quick Search for Autohotkey or see the tutorial for newbies.
Back to top
View user's profile Send private message Send e-mail
tidbit



Joined: 09 Mar 2008
Posts: 1807
Location: Minnesota, USA

PostPosted: Tue Jan 19, 2010 4:26 pm    Post subject: Reply with quote

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

Code:
; 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*
Note: My name is all lowercase for a reason.
Even monkeys fall from trees. - Japanese proverb
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
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