AutoHotkey Community

It is currently May 25th, 2012, 5:55 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 

Useful script?
Poll ended at February 24th, 2005, 6:48 am
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
 Post subject: Zoomer magnifier
PostPosted: February 14th, 2005, 6:48 am 
Offline

Joined: December 28th, 2004, 12:33 am
Posts: 60
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 February 14th, 2005, 10:37 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 14th, 2005, 10:19 am 
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:


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 14th, 2005, 10:30 am 
Offline

Joined: March 28th, 2004, 3:53 pm
Posts: 1870
yeah this is nice!

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 19th, 2010, 3:09 pm 
Offline

Joined: January 19th, 2010, 11:39 am
Posts: 12
Location: Philippines
Sorry didn't work for me. Running Window XP Home SP3


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 19th, 2010, 5:01 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5470
Location: the tunnel(?=light)
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.

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 19th, 2010, 5:26 pm 
Offline

Joined: March 10th, 2008, 12:55 am
Posts: 1907
Location: Minnesota, USA
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.
"I think Bigfoot is blurry, that's the problem. It's not the photographer's fault, Bigfoot is blurry. So there's a large, out-of-focus monster roaming the countryside."


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: nothing and 20 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