Sign in to follow this  
Followers 0
ARozanski

Magnifying Tool

5 posts in this topic

Hi. I have built a program that does all sorts of random things...but one thing i would like it to do is take a certain area around the mouse pointer and either project it elsewhere on the screen magnified but unmagnified would be ok too. Just like the magnifying tool windows has. Is this possible??

I know how to get every pixel around the mouse and save it in an array. But how would i project it elsewhere on the screen

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

short example:

(press alt + q )

#include <ScreenCapture.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>

HotKeySet('!q', 'Magnify')
Global $GUI = GUICreate('Magnify', 400, 400, 100, 100, $WS_POPUPWINDOW)

While 1
    Sleep(10)
WEnd

Func Magnify()
    GUISetState(@SW_HIDE)
    $Pos = MouseGetPos()
    $HBITMAP = _ScreenCapture_Capture('', $Pos[0] - 100, $Pos[1] - 100, $Pos[0] + 100, $Pos[1] + 100, False)
    
    _GDIPlus_Startup()
    
    $oBITMAP = _GDIPlus_BitmapCreateFromHBITMAP($HBITMAP)
    $oGRAPHIC = _GDIPlus_GraphicsCreateFromHWND($GUI)
    GUISetState()
    _GDIPlus_GraphicsDrawImageRectRect($oGRAPHIC, $oBITMAP, 0, 0, 200, 200, 0, 0, 400, 400); Draw 2x zoomed image

    _WinAPI_DeleteObject($HBITMAP)
    _GDIPlus_GraphicsDispose($oGRAPHIC)
    _WinAPI_DeleteObject($oBITMAP)
    _GDIPlus_Shutdown()


    
EndFunc;==>Magnify
Edited by oMBra

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Man - that is just amazing! Thank you very much - i am seriously impressed!...but unfortunately if i try to make it a constant thing by taking out the function part and just leaving while 1...everything goes haywire :-/ ...

thanks anyways

Edited by ARozanski

Share this post


Link to post
Share on other sites

Man - that is just amazing! Thank you very much - i am seriously impressed!...but unfortunately if i try to make it a constant thing by taking out the function part and just leaving while 1...everything goes haywire :-/ ...

thanks anyways

Siao did an excellent magnifier in example scripts, and I think Nahuel diod one too.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

how about my prog iposted.

include<WindowsConstants.au3>
;zoomit


Opt("GUIOnEventMode", 1)

$x_s = 0
$ry = 0
$rowx = 200
Dim $row_x[$rowx + 1]


$Zi = GUICreate("Zoom", 400, 250, 320, 300, -1, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST))
$lbl = GUICtrlCreateLabel("", 250, 5, 75, 25)
$clr1 = GUICtrlCreateLabel("", 5, 125, 100, 50)
$got_clr=GUICtrlCreateLabel("",150,150,50,50)
GUICtrlSetBkColor(-1,0x000000)
$jmp_x = 0
$jmp_y = 0
For $x = 1 To $rowx
    $row_x[$x] = GUICtrlCreateLabel("", 2 + $x_s + $jmp_x, 2 + $ry + $jmp_y, 10, 10)
    GUICtrlSetBkColor($row_x[$x], 0xff0000)

    

    If IsInt($x / 20) Then
        $ry += 10
        $x_s = -10
    EndIf
    $x_s += 10
    
    If $x_s=100 Then
        $jmp_x = 1
    Else
        $jmp_x = 0
    EndIf

    If $ry=50 Then
        $jmp_y = 1
    Else
        $jmp_y = 0
    EndIf
Next

GUISetState(@SW_SHOW)

While 1
    $ms = MouseGetPos()
    GUICtrlSetData($lbl, "X " & $ms[0] & "  Y " & $ms[1])
    $py = 0
    $px = 0
    For $ms_x = 1 To $rowx

        GUICtrlSetBkColor($row_x[$ms_x], PixelGetColor($ms[0] + $px - 10, $ms[1] + $py - 5))
        If $px = 10 And $py = 4 Then 
        $pgc=PixelGetColor($ms[0] + $px - 10, $ms[1] + $py - 5)
        $hex=hex($pgc)
        $stlf=StringTrimLeft($hex,2)
        GUICtrlSetData($clr1, $pgc&"   0x"&$stlf)
        GUICtrlSetBkColor($got_clr,$pgc)
        EndIf
        
        If IsInt($ms_x / 20) Then
            $py += 1
            $px = -1
        EndIf

        $px += 1
    Next
    Sleep(25)
WEnd

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