Sign in to follow this  
Followers 0
Fossil Rock

Zoom Zoom - Magnify utility w/ Zoom

16 posts in this topic

#1 ·  Posted (edited)

This isn't completed yet due to my lack of algorithm writing skillz and understanding of the DLLCall used in the magnification routine.

It only works for 1x, 3x & 9x (1, 2 & 3 respectively on the numpad).

Posted Image

; Example of zooming in on magnification area Orininal script @ http://www.autoitscript.com/forum/index.php?s=&showtopic=54080&view=findpost&p=409802

#include <A3LGDIPlus.au3>
#Include <Misc.au3>

Global Const $AC_SRC_ALPHA      = 1
Global Const $ULW_ALPHA         = 2
Global Const $c[9][2] = [[7,9],[0,0],[2,2],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]]; Correction bits for Magnification window placement
$ZoomFactor = 1

; Create GUI
$hwnd = GUICreate("Zoom Zoom", 320, 220, -1, -1, -1, $WS_EX_TOPMOST)
GUISetBkColor(0xFFFFFF)

GUISetState()

$MyhWnd = GUICreate("Zoom", 300, 200, 10, 10, BitOR($WS_CHILD, $WS_TABSTOP), -1, $hwnd)
GUISetBkColor(0xFFFFFF, $MyhWnd)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit

    EndSelect
_Zoom_Factor()
_Zoom($ZoomFactor)
WEnd

Func _Zoom_Factor(); Sets zoom factor ====== Only 1,3 & 9 work correctly ======
        Select
            Case _IsPressed("61")
                $ZoomFactor = 1
;           Case _IsPressed("62")
;               $ZoomFactor = 2
            Case _IsPressed("62");63
                $ZoomFactor = 3
;           Case _IsPressed("64")
;               $ZoomFactor = 4
;           Case _IsPressed("65")
;               $ZoomFactor = 5
;           Case _IsPressed("66")
;               $ZoomFactor = 6
;           Case _IsPressed("67")
;               $ZoomFactor = 7
;           Case _IsPressed("68")
;               $ZoomFactor = 8
            Case _IsPressed("63");69
                $ZoomFactor = 9
        EndSelect
EndFunc

Func _Zoom($zf); Modified from origial written by Larry, but he removed all his posts. Thanks anyway Larry.
    $pos = MouseGetPos()
    $a = $pos[0]
    $b = $pos[1]
    $MyHDC = DLLCall("user32.dll","int","GetDC","hwnd",$MyhWnd)
    If @error Then Return
        $DeskHDC = DLLCall("user32.dll","int","GetDC","hwnd",0)
        If Not @error Then
            $l = (($a - 140) + (140 * ($zf - 1)) / $zf) - $c[$zf-1][0]
            $t = (($b - 80) + (80 * ($zf - 1)) / $zf) - $c[$zf-1][1]
            DLLCall("gdi32.dll","int","StretchBlt","int",$MyHDC[0],"int", _
                    0,"int",0,"int",300 * $zf,"int",200 * $zf,"int",$DeskHDC[0],"int", _
                    $l,"int",$t,"int",300,"int",200,"long",$SRCCOPY)
        EndIf
        DLLCall("user32.dll","int","ReleaseDC","int",$DeskHDC[0],"hwnd",0)
    DLLCall("user32.dll","int","ReleaseDC","int",$MyHDC[0],"hwnd",$MyhWnd)
GUISetState()
Sleep(20)
EndFunc
Edited by Fossil Rock

Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

Share this post


Link to post
Share on other sites



SCRIPT_PATH(10,16) : WARNING: $ZoomFactor possibly not declared/created yet

$ZoomFactor = 1

~~~~~~~~~~~~~~~^

SCRIPT_PATH(12,69) : WARNING: $hwnd possibly not declared/created yet

$hwnd = GUICreate("Zoom Zoom", 320, 220, -1, -1, -1, $WS_EX_TOPMOST)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

SCRIPT_PATH(17,93) : WARNING: $MyhWnd possibly not declared/created yet

$MyhWnd = GUICreate("MagItZoom", 300, 200, 10, 10, BitOR($WS_CHILD, $WS_TABSTOP), -1, $hwnd)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

SCRIPT_PATH(21,23) : WARNING: $msg possibly not declared/created yet

$msg = GUIGetMsg()

~~~~~~~~~~~~~~~~~~~~~~^

SCRIPT_PATH(55,25) : WARNING: $pos possibly not declared/created yet

$pos = MouseGetPos()

~~~~~~~~~~~~~~~~~~~~~~~~^

SCRIPT_PATH(56,17) : WARNING: $a possibly not declared/created yet

$a = $pos[0]

~~~~~~~~~~~~~~~~^

SCRIPT_PATH(57,17) : WARNING: $b possibly not declared/created yet

$b = $pos[1]

~~~~~~~~~~~~~~~~^

SCRIPT_PATH(58,64) : WARNING: $MyHDC possibly not declared/created yet

$MyHDC = DLLCall("user32.dll","int","GetDC","hwnd",$MyhWnd)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

SCRIPT_PATH(60,64) : WARNING: $DeskHDC possibly not declared/created yet

$DeskHDC = DLLCall("user32.dll","int","GetDC","hwnd",0)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

SCRIPT_PATH(62,71) : WARNING: $l possibly not declared/created yet

$l = (($a - 150) + (150 * ($zf - 1)) / $zf) - $c[$zf-1][0]

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

SCRIPT_PATH(63,71) : WARNING: $t possibly not declared/created yet

$t = (($b - 100) + (100 * ($zf - 1)) / $zf) - $c[$zf-1][1]

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

SCRIPT_PATH - 0 error(s), 11 warning(s)

->16:22:27 AU3Check ended.rc:1

>Running:(3.2.6.0):C:\Program Files\AutoIt3\autoit3.exe "SCRIPT_PATH"

SCRIPT_PATH (10) : ==> Variable used without being declared.:

$ZoomFactor = 1

^ ERROR

:)

Share this post


Link to post
Share on other sites

Check to see if you have all the includes.


Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

Share this post


Link to post
Share on other sites

This is very nice! Very fast as well :)


My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.

Share this post


Link to post
Share on other sites

Haha, awesome! I love the effect it has when you move your mouse over the zoom window :)

Share this post


Link to post
Share on other sites

Well, everything works great, except when I move my mouse quickly over explorer things, it blurs.


"Its not about the 30 inch 1080p display, or the SLI 8800 ultras, or the DDR3 memory. It's about when you turn on your PC, does it return the favor?"Math is like sex. Sure, it may give some practical results, but that is not why we do it

Share this post


Link to post
Share on other sites

ive tried a couple of these zoom scripts, and the image appears and follows the mouse but none of them zoom in.

im using the lastest builds, any idea what is wrong?

Share this post


Link to post
Share on other sites

@mattfaust

When the program starts, it is at 1x, press 2 or 3 to make it zoom.


My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.

Share this post


Link to post
Share on other sites

i have , nothing happens

Share this post


Link to post
Share on other sites

I'm curious, why by 3? Why not use a power of 2 like computers are based? 1, 2, 4, 8, etc.

Nice work though, it's fun to play with.

Share this post


Link to post
Share on other sites

I'm curious, why by 3? Why not use a power of 2 like computers are based? 1, 2, 4, 8, etc.

Nice work though, it's fun to play with.

Reread the original post.

Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

Share this post


Link to post
Share on other sites

If you don't have a numberpad then it won't work unless you change the _IsPressed

Share this post


Link to post
Share on other sites

This is very nice, no flashing lagging or skipping, very smooth and fast. Great Work.

Kurt


Awaiting Diablo III..

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

Nice.

Suggestion - I would use WinSetTrans on the GUI. This way magnifier would magnify what's "behind" the GUI (magnifying magnifier is only good for fun :)). And if you set it transparent enough, the user could see behind the GUI too, which is handy,as the GUI wouldn't get in the way. Also it would look better, especially if you add WS_EX_TOOLWINDOW style... But maybe that's just personal preference, and GUI window getting in the way wouldn't be that big of an issue if your display is larger than my 15'' ;)

Also on further inspection noticed that there's a memory leak - DC handles aren't being released, because the parameters for ReleaseDC call are mixed up (window handle should come first, then DC handle).

Edited by Siao

"be smart, drink your wine"

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0