name22

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

Nov 18th, 2012
173
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <WinAPI.au3>
  2.  
  3. ; Start this script first! It will automatically start the other script if it is within the same directory under the name 'Main.au3'.
  4. ; -Author: name22 (www.autoit.de)
  5.  
  6. Run(@AutoItExe & ' "' & @ScriptDir & '\Main.au3"')
  7.  
  8. Global Const $tagMSLLHOOKSTRUCT = "INT X; INT Y;DWORD mouseData;DWORD flags;DWORD time;ULONG_PTR dwExtraInfo", $WM_EVENT = _WinAPI_RegisterWindowMessage("AutoItEvent")
  9. Global $hWnd_Magnifier, $hMouseHook, $hMouseProc, $hSendAsyncProc, $pSendAsyncProc, $bEventReady = True
  10. Global $hDll_User32 = DllOpen("user32.dll")
  11.  
  12. Do
  13.     $hWnd_Magnifier = WinGetHandle("AutoItMagnifyingGUI")
  14. Until Not @error
  15.  
  16. $hMouseProc = DllCallbackRegister("_MouseProc", "INT", "INT;PTR;PTR")
  17. $hMouseHook = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($hMouseProc), _WinAPI_GetModuleHandle(0), 0)
  18. $hSendAsyncProc = DllCallbackRegister("_SendAsyncProc", "NONE", "HWND;UINT;ULONG_PTR;LRESULT")
  19. $pSendAsyncProc = DllCallbackGetPtr($hSendAsyncProc)
  20.  
  21. Sleep(10)
  22. DllCall($hDll_User32, "BOOL", "SendMessageCallback", "HWND", $hWnd_Magnifier, "UINT", $WM_EVENT, "WPARAM", _WinAPI_GetMousePosX(), "LPARAM", _WinAPI_GetMousePosY(), "PTR", $pSendAsyncProc, "ULONG_PTR", 0)
  23.  
  24. While Sleep(500)
  25.     If Not WinExists($hWnd_Magnifier) Then Exit
  26. WEnd
  27.  
  28. Func _MouseProc($nCode, $wParam, $lParam)
  29.     Local $aRet = DllCall($hDll_User32, "LRESULT", "CallNextHookEx", "HANDLE", $hMouseHook, "INT", $nCode, "WPARAM", $wParam, "LPARAM", $lParam)
  30.     If $nCode < 0 Then Return $aRet[0]
  31.     If BitAND($wParam, 0xFFFF) = 0x0200 And $bEventReady Then
  32.         Local $tMHook = DllStructCreate($tagMSLLHOOKSTRUCT, $lParam)
  33.         $bEventReady = False
  34.         DllCall($hDll_User32, "BOOL", "SendMessageCallback", "HWND", $hWnd_Magnifier, "UINT", $WM_EVENT, "WPARAM", DllStructGetData($tMHook, "X"), "LPARAM", DllStructGetData($tMHook, "Y"), "PTR", $pSendAsyncProc, "ULONG_PTR", 0)
  35.     EndIf
  36.     Return $aRet[0]
  37. EndFunc
  38.  
  39. Func _SendAsyncProc($hWnd, $iMsg, $dwData, $lResult)
  40.     $bEventReady = True
  41. EndFunc
  42.  
  43. Func _Shutdown()
  44.     _WinAPI_UnhookWindowsHookEx($hMouseHook)
  45.     DllCallbackFree($hMouseProc)
  46.     DllCallbackFree($hSendAsyncProc)
  47.     DllClose($hDll_User32)
  48. EndFunc
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×