Sign in to follow this  
Followers 0
spyrorocks

AutoMagnifier

8 posts in this topic




Nice job, but this has been done before.

; ------------------------------------------------------------------------------
;
; AutoIt Version:   3.1.1 Beta
; Author:           CodeMaster Rapture <Rapture2k4@Netscape.net>
; Language:         English
; Script Function:  A little application that magnifies a 20x20 area under the
;                   mouse. This is just an example of what CAN be done in Au3.
;
; ------------------------------------------------------------------------------

#include <GUIConstants.au3>

HotKeySet("{ESC}", "Quit")

;Magnifying a 20x20 area of the screen
Global $GUI_Pixel[400]
Global $GUI = GUICreate("Zoom x2 Au3",80,80,0,0,$WS_POPUP+$WS_BORDER,$WS_EX_TOPMOST)

$count = 0
;Let's create a bunch of labels and make them 4x4 pixels in size.
For $iterX = 0 To 79 Step 4
    For $iterY = 0 To 79 Step 4
        $GUI_Pixel[$count] = GUICtrlCreateLabel("",$iterX,$iterY,4,4)
        $count += 1
    Next
Next
GUISetState(@SW_SHOW)

Global $LastPos[2] = [0,0]

While 1
    $count = 0
    $MousePos = MouseGetPos()
    
;Got creative here, since we want to magnify a 20x20 area around the mouse,
;I just start with a negative number for each loop. It still counts 20x20, merely
;starts at a strange index. :)
    For $iterX = -10 To 9
        For $iterY = -10 To 9
            GUICtrlSetBkColor($GUI_Pixel[$count],PixelGetColor($MousePos[0]+$iterX,$MousePos[1]+$iterY))
            $count += 1;Loop thru our Pixel Array (20 * 20 == 400 elements)
        Next
    Next
    
;I placed this in to remove some choppiness. One less API call == good.
;This also allows for animation over an area of the screen.

;Sleeping 1-10 ms takes 70-60% (respectively) CPU usage on my machine
    Sleep(10)
WEnd

Func Quit()
    Exit
EndFunc

Nice job though.


[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

a bit easier way, code by larry although it isnt all autoit

Global $SRCCOPY = 0x00CC0020
Global $leave = 0

HotKeySet("{PAUSE}","leave")

SplashTextOn ( "AU3MAG", "" , 100 , 100 , 0, 0, 1 )
$MyhWnd = WinGetHandle("AU3MAG")

While Not $leave
  Sleep(25)
  MAG()
WEnd

Func MAG()
  $MyHDC = DLLCall("user32.dll","int","GetDC","hwnd",$MyhWnd)
  If @error Then Return
  $DeskHDC = DLLCall("user32.dll","int","GetDC","hwnd",0)
  If Not @error Then
     $xy = MouseGetPos()
     If Not @error Then
        $l = $xy[0]-10
        $t = $xy[1]-10
        DLLCall("gdi32.dll","int","StretchBlt","int",$MyHDC[0],"int",_
                    0,"int",0,"int",100,"int",100,"int",$DeskHDC[0],"int",_
                    $l,"int",$t,"int",20,"int",20,"long",$SRCCOPY)
     EndIf
     DLLCall("user32.dll","int","ReleaseDC","int",$DeskHDC[0],"hwnd",0)
  EndIf
  DLLCall("user32.dll","int","ReleaseDC","int",$MyHDC[0],"hwnd",$MyhWnd)
EndFunc

Func leave()
  $leave = 1
EndFunc
Edited by death pax

Share this post


Link to post
Share on other sites

Did you ever heard of a array?


-jaenster

Share this post


Link to post
Share on other sites

Did you ever heard of a array?

He does use arrays for some parts, but i agree that a few more could help :)

Share this post


Link to post
Share on other sites

What about:

; AutoMagnifier by spyrorocks
; edited by RazerM

#include <GUIConstants.au3>

$gui = GUICreate("AutoMagnifier", 192, 159, 193, 126)
Local $i = 0
Local $box[30]
For $y = 0 To 128 Step 32
    For $x = 0 To 160 Step 32
        $box[$i] =  GUICtrlCreateLabel($i, $x, $y, 32, 32)
        $i += 1
    Next
Next
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    setcolors()
WEnd


Func setcolors()
    $color = MouseGetPos()
    $x = $color[0]
    $y = $color[1]
    $ii = 2
    For $i = 2 To 14 Step 6
        GUICtrlSetBkColor($box[$i], PixelGetColor($x, $y - $ii))
        $ii -= 1
    Next
    
    $ii = 0
    $xMinus = 2
    Local $boxNums[10] = [0, 1, 6, 7, 12, 13, 18, 19, 24, 25]
    Local $yMinus[10] = [2, 2, 1, 1, 0, 0, -1, -1, -2, -2]
    For $i = 1 To 10
        GUICtrlSetBkColor($box[$boxNums[$i - 1]], PixelGetColor($x - $xMinus, $y - $yMinus[$i - 1]))
        $xMinus = 3 - $xMinus
    Next
    
    Local $boxNums[17] = [3, 4, 5, 9, 10, 11, 15, 16, 17, 21, 22, 23, 27, 28, 29, 26, 20]
    Local $xPlus[17] =  [1, 2, 3, 1, 2, 3, 1, 2, 3,  1,  2,  3,  1,  2,  3,  0,  0]
    Local $yMinus[17] = [2, 2, 2, 1, 1, 1, 0, 0, 0, -1, -1, -1, -2, -2, -2, -2, -1]
    For $i = 1 To 17
        GUICtrlSetBkColor($box[$boxNums[$i - 1]], PixelGetColor($x + $xPlus[$i - 1],$y - $yMinus[$i-1]))
    Next
EndFunc   ;==>setcolors

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'm quite good at shortening things with for..next loops. I just look for patterns and think of ways to loop them.


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

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