name22

Desktop Magnifying Glass v2.0 (Script 1/2 - Main)

Nov 18th, 2012
117
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <WinAPI.au3>
  2. #include <Constants.au3>
  3. #include <GUIConstants.au3>
  4. #include <WindowsConstants.au3>
  5.  
  6. ; -Author: name22 (www.autoit.de)
  7.  
  8. Opt("GUIOnEventMode")
  9.  
  10. Global Const $iFlag = BitOR($SWP_NOSIZE, $SWP_NOZORDER), $tagMSLLHOOKSTRUCT = "INT X; INT Y;DWORD mouseData;DWORD flags;DWORD time;ULONG_PTR dwExtraInfo"
  11. Global $hWnd_Magnifier, $hWnd_Desktop, $hDC_Window, $hDC_Desktop, $iDesktopWidth, $iDesktopHeight
  12. Global $hDll_GDI32 = DllOpen("gdi32.dll"), $hDll_User32 = DllOpen("user32.dll")
  13. Global $WM_EVENT = _WinAPI_RegisterWindowMessage("AutoItEvent")
  14.  
  15. Global $iGUIWidth = 100
  16. Global $iGUIHeight = 100
  17. Global $iCaptureWidth = 50
  18. Global $iCaptureHeight = 50
  19.  
  20. $hWnd_Magnifier = GUICreate("AutoItMagnifyingGUI", $iGUIWidth, $iGUIHeight, -1, -1, $WS_POPUP, $WS_EX_TOPMOST)
  21. GUISetState()
  22.  
  23. $hWnd_Desktop = _WinAPI_GetDesktopWindow()
  24. $hDC_Window = _WinAPI_GetDC($hWnd_Magnifier)
  25. $hDC_Desktop = _WinAPI_GetDC($hWnd_Desktop)
  26. ;~ DllCall($hDll_GDI32, "INT", "SetStretchBltMode", "HANDLE", $hDC_Window, "INT", 3)
  27.  
  28. $iDesktopWidth = _WinAPI_GetWindowWidth($hWnd_Desktop)
  29. $iDesktopHeight = _WinAPI_GetWindowHeight($hWnd_Desktop)
  30.  
  31. GUIRegisterMsg($WM_EVENT, "_ReDraw")
  32. OnAutoItExitRegister("_Shutdown")
  33. GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
  34. HotKeySet("{ESC}", "_Exit")
  35.  
  36. While Sleep(1000)
  37. WEnd
  38.  
  39. Func _ReDraw($hWnd, $iMsg, $wParam, $lParam)
  40.     Local Static $iX_Max = $iDesktopWidth - $iGUIWidth - $iCaptureWidth / 2, $iY_Max = $iDesktopHeight - $iGUIHeight - $iCaptureHeight / 2
  41.     Local $iX_Mouse = $wParam
  42.     Local $iY_Mouse = $lParam
  43.     Local $iX_MouseTmp = $iX_Mouse
  44.     Local $iY_MouseTmp = $iY_Mouse
  45.  
  46.     If $iX_MouseTmp < 0 Then $iX_MouseTmp = 0
  47.     If $iX_MouseTmp > $iX_Max Then $iX_MouseTmp = $iX_Max
  48.     If $iY_MouseTmp < 0 Then $iY_MouseTmp = 0
  49.     If $iY_MouseTmp > $iY_Max Then $iY_MouseTmp = $iY_Max
  50.     DllCall($hDll_User32, "BOOL", "SetWindowPos", "HWND", $hWnd_Magnifier, "HWND", 0, "INT", $iX_MouseTmp + $iCaptureWidth / 2 , "INT", $iY_MouseTmp + $iCaptureHeight / 2 , "INT", 0, "INT", 0, "UINT", $iFlag)
  51.     DllCall($hDll_GDI32, "INT", "StretchBlt", "HWND", $hDC_Window, "INT", 0, "INT", 0, "INT", $iGUIWidth, "INT", $iGUIHeight, "HWND", $hDC_Desktop, "INT", $iX_Mouse - $iCaptureWidth / 2, "INT", $iY_Mouse - $iCaptureHeight / 2, "INT", $iCaptureWidth, "INT", $iCaptureHeight, "DWORD", $SRCCOPY)
  52. EndFunc   ;==>_ReDraw
  53.  
  54. Func _Exit()
  55.     Exit
  56. EndFunc   ;==>_Exit
  57.  
  58. Func _Shutdown()
  59.     _WinAPI_ReleaseDC($hWnd_Magnifier, $hDC_Window)
  60.     _WinAPI_ReleaseDC($hWnd_Desktop, $hDC_Desktop)
  61.     DllClose($hDll_GDI32)
  62.     DllClose($hDll_User32)
  63. EndFunc
  64.  
  65.  
  66. ; #FUNCTION# ====================================================================================================================
  67. ; Name...........: _WinAPI_StretchBlt
  68. ; Description....: Copies a bitmap from a source rectangle into a destination rectangle, stretching or compressing the bitmap
  69. ;                  to fit the dimensions of the destination rectangle, if necessary.
  70. ; Syntax.........: _WinAPI_StretchBlt ( $hDestDC, $iXDest, $iYDest, $iWidthDest, $iHeightDest, $hSrcDC, $iXSrc, $iYSrc, $iWidthSrc, $iHeightSrc, $iRop )
  71. ; Parameters.....: $hDestDC     - Handle to the destination device context.
  72. ;                  $iXDest      - The x-coordinate, in logical units, of the upper-left corner of the destination rectangle.
  73. ;                  $iYDest      - The y-coordinate, in logical units, of the upper-left corner of the destination rectangle.
  74. ;                  $iWidthDest  - The width, in logical units, of the destination rectangle.
  75. ;                  $iHeightDest - The height, in logical units, of the destination rectangle.
  76. ;                  $hSrcDC      - Handle to the source device context.
  77. ;                  $iXSrc       - The x-coordinate, in logical units, of the upper-left corner of the source rectangle.
  78. ;                  $iYSrc       - The y-coordinate, in logical units, of the upper-left corner of the source rectangle.
  79. ;                  $iWidthSrc   - The width, in logical units, of the source rectangle.
  80. ;                  $iHeightSrc  - The height, in logical units, of the source rectangle.
  81. ;                  $iRop        - The raster-operation code. These codes define how the color data for the source rectangle is
  82. ;                                 to be combined with the color data for the destination rectangle to achieve the final color.
  83. ;                                 This parameter must be 0 or one of the following values.
  84. ;
  85. ;                                 $BLACKNESS
  86. ;                                 $CAPTUREBLT
  87. ;                                 $DSTINVERT
  88. ;                                 $MERGECOPY
  89. ;                                 $MERGEPAINT
  90. ;                                 $NOMIRRORBITMAP
  91. ;                                 $NOTSRCCOPY
  92. ;                                 $NOTSRCERASE
  93. ;                                 $PATCOPY
  94. ;                                 $PATINVERT
  95. ;                                 $PATPAINT
  96. ;                                 $SRCAND
  97. ;                                 $SRCCOPY
  98. ;                                 $SRCERASE
  99. ;                                 $SRCINVERT
  100. ;                                 $SRCPAINT
  101. ;                                 $WHITENESS
  102. ;
  103. ; Return values..: Success      - 1.
  104. ;                  Failure      - 0 and sets the @error flag to non-zero.
  105. ; Author.........: Yashied
  106. ; Modified.......:
  107. ; Remarks........: The system stretches or compresses the bitmap according to the stretching mode currently set in the
  108. ;                  destination device context.
  109. ; Related........:
  110. ; Link...........: @@MsdnLink@@ StretchBlt
  111. ; Example........: Yes
  112. ; ===============================================================================================================================
  113.  
  114. Func _WinAPI_StretchBlt($hDestDC, $iXDest, $iYDest, $iWidthDest, $iHeightDest, $hSrcDC, $iXSrc, $iYSrc, $iWidthSrc, $iHeightSrc, $iRop)
  115.  
  116.     Local $Ret  = DllCall('gdi32.dll', 'int', 'StretchBlt', 'hwnd', $hDestDC, 'int', $iXDest, 'int', $iYDest, 'int', $iWidthDest, 'int', $iHeightDest, 'hwnd', $hSrcDC, 'int', $iXSrc, 'int', $iYSrc, 'int', $iWidthSrc, 'int', $iHeightSrc, 'dword', $iRop)
  117.  
  118.     If (@error) Or (Not $Ret[0]) Then
  119.         Return SetError(1, 0, 0)
  120.     EndIf
  121.     Return 1
  122. EndFunc   ;==>_WinAPI_StretchBlt
RAW Paste Data