Jump to content

Monitor Zoom


Recommended Posts

Hey guys,

i have written a 2x zoom tool for my 37" LCD-TV, maybe anyone of you could use it, too :D

#include <GDIplus.au3>
#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
$FW = DllCall("user32.dll", "int", "GetSystemMetrics", "int", 78)
$FH = DllCall("user32.dll", "int", "GetSystemMetrics", "int", 79)
$XA = @DesktopWidth
$YA = @DesktopHeight
$WA = $FW[0]
$HA = $FH[0]

$hGUI = GUICreate("MonView", 200, 200, -1, -1, BitOR($WS_POPUP, $WS_BORDER, $WS_DISABLED), BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

Dim $fR = 1, $yS, $xS, $wPosX, $wPosY, $mXo, $mYo, $fTs = 0
_GDIPlus_Startup()
$timer = TimerInit()
While 1
;~  Get CursorPos
    $mX = MouseGetPos(0)
    $mY = MouseGetPos(1)
;~  X-Koordinate
    Switch $mX
        Case 0 To 252
            $x = $mX + 51
            $xS = True
        Case 253 To $WA - 254
            If $xS Then
                $x = $mX + 51
            Else
                $x = $mX - 252
            EndIf
        Case $WA - 253 To $WA
            $x = $mX - 252
            $xS = False
    EndSwitch
;~  Y-Koordinate
    Switch $mY
        Case 0 To 252
            $y = $mY + 51
            $yS = True
        Case 253 To $HA - 254
            If $yS Then
                $y = $mY + 51
            Else
                $y = $mY - 252
            EndIf
        Case $HA - 253 To @DesktopHeight
            $y = $mY - 252
            $yS = False
        Case @DesktopHeight + 1 To $HA
            $y = $mY - 308
            $yS = False
    EndSwitch
;~  Move Window
    If $mX = $mXo And $mX = $mXo Then
        If $fTs = 0 Then
            $fT = TimerInit()
            $fTs = 1
        EndIf
        If TimerDiff ($fT) > 5000 And $fTs = 1 Then
            Exit
        EndIf
    Else
        $fTs = 0
    EndIf
    If $x <> $wPosX Or $y <> $wPosY And $fR = 0 Then
        WinMove($hGUI, "", $x, $y)
    EndIf
    If $fR = 0 Then
        _Shot($mX, $mY)
    EndIf
    If $fR = 1 Then
        WinMove($hGUI, "", $x, $y)
        GUISetState()
        _Shot($mX, $mY)
        $fR = 0
    EndIf
    $wPos = WinGetPos($hGUI)
    $wPosX = $wPos[0]
    $wPosY = $wPos[1]
    $mXo = $mX
    $mYo = $mY
    If TimerDiff($timer) > 1000 Then
        $timer = TimerInit()
        WinSetOnTop ($hGui, "",1)
    EndIf
    Sleep(50)
WEnd

Func _Exit()
    _GDIPlus_Shutdown()
    GUIDelete()
    Exit
EndFunc   ;==>_Exit

Func _Shot($mX, $mY)
    $sCap = _ScreenCapture_Capture("", $mX - 50, $mY - 50, $mX + 50, $mY + 50, False)
    $sCapBM = _GDIPlus_BitmapCreateFromHBITMAP($sCap)
    $sCapX = _GDIPlus_ImageGetWidth($sCapBM)
    $sCapY = _GDIPlus_ImageGetHeight($sCapBM)
    $sGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsDrawImageRectRect($sGraphic, $sCapBM, 0, 0, $sCapX, $sCapY, 0, 0, 200, 200)
    _GDIPlus_GraphicsDispose($sGraphic)
    _GDIPlus_ImageDispose($sCapBM)
    _WinAPI_DeleteObject($sCap)
EndFunc   ;==>_Shot

have fun, yetrael

Edited by yetrael
Link to comment
Share on other sites

Nice but these includes are missing:

#include <GDIplus.au3>

#include <GUIConstantsEx.au3>

#include <ScreenCapture.au3>

#include <WindowsConstants.au3>

Further, why is the mouse in the middle of the zoom screen permanently?

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Thanks, happy to hear this :D

The only "problem" i have so far, is the different vertical resolution of my PC-Monitor and my LCD... PC runs with 1024px, lcd with 1080px. When i move the coursor from lcd to pc monitor it appears a little bit under or out of the screen... Hope u understand my english :D

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...