Jump to content

Magnify two areas simultaneously


Recommended Posts

I would do something like this with SDL.  I'm sure that there are equal or better ways.

To do it with SDL, first download the SDL UDF from >LINK.

Figure out the basic code to start and utilize a SDL project with AutoIt.

Once you have a AutoIt SDL window you can do something like a AutoIt _ScreenCapture_Capture() to get the target source areas.

Then zoomSurface() to a AutoIt SDL window.

I'm not 100% sure that this is the best way to go.

I am interested to see what challenges I would have.

I am happy to help you with any of the steps and go into more detail if you would like to take the SDL path.

Edited by Xandy
Link to comment
Share on other sites

Thank you for reply,

in last post i'm (and Melba) using dll call.

I read about GDI vs DllCall to accomplish these task to optimize mem usage and do'nt charge PC too much.

Re-post here code to show 2 areas alternatively:

(PAUSE switch between panels)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

Opt("GUICloseOnESC", 0)

HotKeySet("{ESC}", "On_Exit")
HotKeySet("{PAUSE}", "On_Switch") ; to switch areas to be magnified

; Set coordinates for areas to magnify
Global $aCoords_1[2] = [750, 500], $aCoords_2[2] = [1000, 500]
; Set size of magnifier GUI
Global $iWidth = 500, $iHeight = 500
Global $hMag_Win, $hMagDC, $hDeskDC, $hPen, $oObj, $iShow = 1

; Create mouse GUI
$hMouse_GUI = GUICreate("Mouse", 5, 5, 0, 0, $WS_POPUP, $WS_EX_TOPMOST)
GUISetBkColor(0, $hMouse_GUI)
GUISetState(@SW_SHOW)

; Create Magnifier GUI
$hMag_GUI = GUICreate("Test", $iWidth, $iHeight, 0, 0, $WS_POPUP)
GUISetState(@SW_SHOW)

; Get device context for Mag GUI
$hMagDC = _WinAPI_GetDC($hMag_GUI)
If @error Then Exit
; Get device context for desktop
$hDeskDC = _WinAPI_GetDC(0)
If @error Then
    _WinAPI_ReleaseDC($hMag_GUI, $hMagDC)
    Exit
EndIf

While 1
    Sleep(10)

    ; Show the correct area
    Switch $iShow
        Case 1
            Magnify($aCoords_1)
            MouseCheck($aCoords_1)
        Case 2
            Magnify($aCoords_2)
            MouseCheck($aCoords_2)
    EndSwitch

WEnd

; Move the mouse GUI to follow the real mouse
Func MouseCheck($aCoords)

    Local $aMousePos = MouseGetPos()
    If  $aMousePos[0] > $aCoords[0] And $aMousePos[0] < $aCoords[0] + 250 And _
        $aMousePos[1] > $aCoords[1] And $aMousePos[1] < $aCoords[1] + 250 Then

        Local $iX = ($aMousePos[0] - $aCoords[0]) * 2
        Local $iY = ($aMousePos[1] - $aCoords[1]) * 2
        WinMove($hMouse_GUI, "", $iX, $iY)

    Else
        ; Hide mouse GUI if not required
        WinMove($hMouse_GUI, "", -20, -20)
    EndIf

EndFunc

Func On_Exit()

    ; Clear up
    _WinAPI_ReleaseDC(0, $hDeskDC)
    _WinAPI_ReleaseDC($hMag_GUI, $hMagDC)
    Exit

EndFunc   ;==>On_Exit

Func On_Switch()

    Switch $iShow
        Case 1
            $iShow = 2
        Case 2
            $iShow = 1
    EndSwitch

EndFunc

Func Magnify($aCoords)

    ; Fill Mag GUI with 2x expanded contents of desktop area as set in $aCoords
    DllCall("gdi32.dll", "int", "StretchBlt", _
        "int", $hMagDC,  "int", 0,                   "int", 0,   "int", $iWidth,     "int", $iHeight, _
        "int", $hDeskDC, "int", $aCoords[0], "int", $aCoords[1], "int", $iWidth / 2, "int", $iWidth / 2, _
        "long", $SRCCOPY)

EndFunc   ;==>Magnify

But can't understand where modify to show two panels simultaneously and in landscape...

Anyone can help with gdi32.dll call ?

thank you,

m

Edited by myspacee
Link to comment
Share on other sites

I developed this with SDL.

The code is simple but I'd really like to clean it up better.

http://www.youtube.com/watch?v=K0SHgKZRiQQ&feature=youtu.be

I looked over your code, it's not something I know about.

May I clean this up for you, tomorrow night?

Link to comment
Share on other sites

Try this:
 

#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <GUIConstantsEx.au3>
Global $iW = 100, $iH = 100
Global $fZoom = 4
Global $hGUI_Zoom = GUICreate("Zoom", 2 * $iW * $fZoom, $iH * $fZoom, -1, -1, Default, $WS_EX_TOPMOST)
GUISetState()
Global $hDC_Zoom = _WinAPI_GetDC(0)
Global $hGUI_ZoomDC = _WinAPI_GetDC($hGUI_Zoom)
Global $hDLL_gdi32 = DllOpen("gdi32.dll")

Do
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            _WinAPI_ReleaseDC($hGUI_Zoom, $hGUI_ZoomDC)
            _WinAPI_ReleaseDC(0, $hDC_Zoom)
            _WinAPI_DeleteDC($hGUI_ZoomDC)
            _WinAPI_DeleteDC($hDC_Zoom)
            GUIDelete()
            DllClose($hDLL_gdi32)
            Exit
    EndSwitch
    _WinAPI_StretchBlt($hGUI_ZoomDC, 0, 0, $iW * $fZoom, $iH * $fZoom, $hDC_Zoom, 0, 0, $iW, $iH, $SRCCOPY)
    _WinAPI_StretchBlt($hGUI_ZoomDC, $iW * $fZoom, 0, $iW * $fZoom, $iH * $fZoom, $hDC_Zoom, 0, 100, $iW, $iH, $SRCCOPY)
Until False

Func _WinAPI_StretchBlt($hDestDC, $iXDest, $iYDest, $iWidthDest, $iHeightDest, $hSrcDC, $iXSrc, $iYSrc, $iWidthSrc, $iHeightSrc, $iRop)
    Local $Ret  = DllCall($hDLL_gdi32, "int", "StretchBlt", "hwnd", $hDestDC, "int", $iXDest, "int", $iYDest, "int", $iWidthDest, "int", $iHeightDest, "hwnd", $hSrcDC, "int", $iXSrc, "int", $iYSrc, "int", $iWidthSrc, "int", $iHeightSrc, "dword", $iRop)
    If (@error) Or (Not $Ret[0]) Then
        Return SetError(1, 0, 0)
    EndIf
    Return 1
EndFunc   ;==>_WinAPI_StretchBlt

Br,

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

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...