@Nine as an idea
putting an additional parameter in WinMagnifier.au3 in the function
Func _MagnifierGUICreate($nWidth, $nHeight, $iX1, $iY1, $bInvertColors = False, $bShowCursor = False, $hParent = 0 )
and filling in the following
$hMagnifyGUI = GUICreate("", $nWidth, $nHeight, $iX1, $iY1, 0x80000000, BitOR(0x08000000, 0x080000, 0x80, 0x20), $hParent)
that simplifies things ?
#include <WindowsConstants.au3>
#include "WinMagnifier.au3"
_MagnifierInit()
Run("Notepad")
Sleep(100)
Local $hWnd = WinGetHandle("[CLASS:Notepad]"), $aPos[4], $aPosTmp[4]
Local $hDesktop = WinGetHandle("[CLASS:Progman]")
WinGetPosEx($hDesktop, $aPos)
Local $aHndl = _MagnifierGUICreate($aPos[2], $aPos[3], $aPos[0], $aPos[1], True, False, $hWnd)
Local $hMagnifyGUI = $aHndl[0], $hMagnifyCtrl = $aHndl[1]
_MagnifierSetSource($hMagnifyCtrl, $aPos[0], $aPos[1], $aPos[2], $aPos[3])
GUISetState(@SW_SHOWNOACTIVATE, $hMagnifyGUI)
While WinExists($hWnd)
If WinActive($hWnd) Then
WinGetPosEx($hWnd, $aPosTmp)
If $aPos[0] <> $aPosTmp[0] Or $aPos[1] <> $aPosTmp[1] Or $aPos[2] <> $aPosTmp[2] Or $aPos[3] <> $aPosTmp[3] Then
$aPos = $aPosTmp
WinMove($hMagnifyGUI, "", $aPos[0], $aPos[1], $aPos[2], $aPos[3])
_MagnifierSetSource($hMagnifyCtrl, $aPos[0], $aPos[1], $aPos[2], $aPos[3])
EndIf
_WinAPI_RedrawWindow($hMagnifyCtrl)
Sleep(10)
Else
Sleep(300)
EndIf
WEnd
_WinAPI_DestroyWindow($hMagnifyCtrl)
GUIDelete($hMagnifyGUI)
Func WinGetPosEx($hWnd, ByRef $aPos)
Local $aTmp = WinGetPos($hWnd)
If @error Then Return
$aPos = $aTmp
; adjust magnifier to the edge of the window
$aPos[0] += 8
$aPos[1] += 1
$aPos[2] -= 16
$aPos[3] -= 9
EndFunc ;==>WinGetPosEx
Edit:
after the observation made below by the @Nine
Maximize does not produce proper result, same goes with resizing larger than initial display.
I added the initialization in start
Local $hDesktop = WinGetHandle("[CLASS:Progman]")
WinGetPosEx($hDesktop, $aPos)
as a temporary solution