Code : Tout sélectionner
; http://www.autoitscript.com/forum/topic/150136-window-zoom-out-tool/#entry1071721
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPIGdi.au3>
#include <Misc.au3>
Opt("GUICloseOnESC", 0)
HotKeySet("{ESC}", "On_Exit")
Global $hMag_GUI, $hMagDC, $hDeskDC, $hPen, $oObj, $aMouse_Pos[2], $iLast_Mouse_X = 0, $iLast_Mouse_Y = 0, $zoom = 3
$hMag_Win = GUICreate("MAG", 100, 100, 0, 0, $WS_POPUP+$WS_BORDER, $WS_EX_TOPMOST)
GUISetState(@SW_SHOW, $hMag_Win)
$hMag_GUI = WinGetHandle("MAG")
$hMagDC = _WinAPI_GetDC($hMag_GUI)
$hDeskDC = _WinAPI_GetDC(0)
$hPen = _WinAPI_CreatePen($PS_SOLID, 1, 0x000000)
$oObj = _WinAPI_SelectObject($hMagDC, $hPen)
While 1
$aMouse_Pos = MouseGetPos()
If $aMouse_Pos[0] <> $iLast_Mouse_X Or $aMouse_Pos[1] <> $iLast_Mouse_Y Then
Loupe($aMouse_Pos)
$iLast_Mouse_X = $aMouse_Pos[0]
$iLast_Mouse_Y = $aMouse_Pos[1]
EndIf
If _IsPressed("11") Then
For $i = 31 to 39
If _IsPressed($i) Then $zoom = $i-30
Next
For $i = 61 to 69
If _IsPressed($i) Then $zoom = $i-60
Next
Loupe($aMouse_Pos)
EndIf
WEnd
Func On_Exit()
_WinAPI_SelectObject($hMagDC, $oObj)
_WinAPI_DeleteObject($hPen)
_WinAPI_ReleaseDC(0, $hDeskDC)
_WinAPI_ReleaseDC($hMag_GUI, $hMagDC)
GUIDelete($hMag_GUI)
Exit
EndFunc ;==>On_Exit
Func Loupe($aMouse_Pos)
Local $iX, $iY
_WinAPI_StretchBlt($hMagDC, 0, 0, 100, 100, $hDeskDC, $aMouse_Pos[0] - 50/$zoom +1, $aMouse_Pos[1] - 50/$zoom +1, 100/$zoom, 100/$zoom, $SRCCOPY)
; crosshair ========
_WinAPI_MoveTo ($hMagDC, 0, 50)
_WinAPI_LineTo ($hMagDC, 46, 50)
_WinAPI_MoveTo ($hMagDC, 54, 50)
_WinAPI_LineTo ($hMagDC, 100, 50)
_WinAPI_MoveTo ($hMagDC, 50, 0)
_WinAPI_LineTo ($hMagDC, 50, 46)
_WinAPI_MoveTo ($hMagDC, 50, 54)
_WinAPI_LineTo ($hMagDC, 50, 100)
DllCall("gdi32.dll","int","Arc", "hwnd", $hMagDC, "int", 46, "int", 46, "int", 55, "int", 55, "int", 0, "int", 50, "int", 0, "int", 50)
;================
If $aMouse_Pos[0] < (@DesktopWidth - 100 -100/$zoom) Then
$iX = $aMouse_Pos[0] + 100/$zoom
Else
$iX = $aMouse_Pos[0] - 100 -100/$zoom
EndIf
If $aMouse_Pos[1] < (@DesktopHeight - 120 -100/$zoom) Then
$iY = $aMouse_Pos[1] + 100/$zoom
Else
$iY = $aMouse_Pos[1] - 100 -100/$zoom
EndIf
WinMove($hMag_GUI, "", $iX, $iY, 100, 100)
EndFunc ;==>Loupe