; Добавил управление горячими клавишами
; Колёсико мыши - только регулировка увеличения
; Ctrl+Колёсико мыши - регулировка увеличения и размера лупы
; Shift+Колёсико мыши - только изменение размера лупы
; http://www.autoitscript.com/forum/index.php?showtopic=24154&view=findpost&p=168674
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
; Global Const $WM_MOUSEWHEEL = 0x020A
HotKeySet("{ESC}", "_Quit")
GUIRegisterMsg(0x020A , "WM_MOUSEWHEEL")
; установка параметров
Global $MagZoom = 4
Global $MagWidth = $MagZoom*10
Global $MagHeight =$MagZoom*10
Global $LastWidth = $MagWidth*$MagZoom
Global $LastHeight =$MagHeight*$MagZoom
Global $LastZoom, $Tr1=1
; $d = Int($MagWidth/2 + 5)
; Global $SRCCOPY = 0x00CC0020
Global $dll[3], $DeskHDC, $GUIHDC
$dll[1] = DllOpen ( "user32.dll")
$dll[2] = DllOpen ( "gdi32.dll")
Global $GUI = GUICreate ("Zoom x2 Au3", $MagWidth * $MagZoom, $MagHeight * $MagZoom, _
MouseGetPos (0), MouseGetPos (1), $WS_POPUP+$WS_BORDER, $WS_EX_TOPMOST)
GUISetState(@SW_SHOW)
Global $LastPos[2] = [0,0]
While 1
$MousePos = MouseGetPos() ; получаем координаты мыши
If $LastPos[0] <> $MousePos[0] Or $LastPos[1] <> $MousePos[1] Or $Tr1=1 Then ; если позиция мыши и зум изменилась, то выполняем перемещение
WinMove("Zoom x2 Au3", "", $MousePos[0] + $MagWidth/2 + 5, $MousePos[1], $MagWidth * $MagZoom, $MagHeight * $MagZoom)
$LastPos[0] = $MousePos[0] ; и темпируем координаты и зум
$LastPos[1] = $MousePos[1]
$LastZoom = $MagZoom
$Tr1=0
MAG()
EndIf
Sleep(10)
WEnd
Func MAG()
$DeskHDC = DLLCall("user32.dll","int","GetDC","hwnd",0)
$GUIHDC = DLLCall("user32.dll","int","GetDC","hwnd",$GUI)
If Not @error Then ; если без ошибок открыли DLL, то
DLLCall("gdi32.dll", "int", "StretchBlt", "int", $GUIHDC[0], "int", _
0, "int", 0, "int", $MagWidth * $MagZoom, "int", $MagHeight * $MagZoom, "int", $DeskHDC[0], "int", _
MouseGetPos (0) - $MagWidth/2, "int", MouseGetPos (1) - $MagHeight/2, "int", $MagWidth ,"int", $MagHeight, _
"long", $SRCCOPY)
DLLCall("user32.dll","int","ReleaseDC","int",$DeskHDC[0],"hwnd",0)
DLLCall("user32.dll","int","ReleaseDC","int",$GUIHDC[0],"hwnd",$GUI)
EndIf
; размер ящика выходного и координаты ящика сканирования
EndFunc
Func WM_MOUSEWHEEL($hWndGui, $MsgId, $wParam, $lParam)
If $MsgId = $WM_MOUSEWHEEL Then
$KeysHeld = BitAND($wParam, 0xFFFF) ; нажатый модификатор
$direction = BitShift($wParam, 16)
; $X = BitShift($lParam, 16) ; координаты мыши
; $Y = BitAND($lParam, 0xFFFF)
If $direction > 0 Then
$MagZoom += 1
Else
$MagZoom -= 1
EndIf
If $MagZoom < 2 Then $MagZoom = 2
Switch $KeysHeld
Case 0 ; ничего
$MagWidth = $LastWidth/$MagZoom
$MagHeight =$LastHeight/$MagZoom
Case 4 ; Shift
If $direction > 0 Then
$LastWidth = $MagWidth*$MagZoom
$LastHeight =$MagHeight*$MagZoom
$MagZoom -= 2
$MagWidth = $LastWidth/$MagZoom
$MagHeight =$LastHeight/$MagZoom
Else
$LastWidth = $MagWidth*$MagZoom
$LastHeight =$MagHeight*$MagZoom
$MagZoom += 2
$MagWidth = $LastWidth/$MagZoom
$MagHeight =$LastHeight/$MagZoom
EndIf
$MagZoom=$LastZoom
Case 8 ; Ctrl
$LastWidth = $MagWidth*$MagZoom
$LastHeight =$MagHeight*$MagZoom
EndSwitch
$Tr1=1
EndIf
EndFunc
Func _Quit()
DllClose ( $dll[1] )
DllClose ( $dll[2] )
Exit
EndFunc