Guest User

https://pastebin.com/3P0ZKj5G in English

a guest
Apr 7th, 2018
428
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 3.81 KB | None | 0 0
  1. #include <WinAPI.au3>
  2. #include <WindowsConstants.au3>
  3.  
  4. Global $hHook, $hStub_KeyProc, $iEditLog, $Gui
  5.  
  6. ; в AutoIt3 v3.3.6.1 and below these constants are not defined
  7. ; Global Const $WM_MBUTTONDBLCLK = 0x0209
  8. ; Global Const $WM_RBUTTONDBLCLK = 0x0206
  9. ; Global Const $WM_MOUSEHWHEEL = 0x020E ???
  10.  
  11. _Main()
  12.  
  13. Func _Main()
  14.     OnAutoItExitRegister("Cleanup")
  15.  
  16.     Local $hmod
  17.  
  18.     $hStub_KeyProc = DllCallbackRegister("_KeyProc", "long", "int;wparam;lparam")
  19.     $hmod = _WinAPI_GetModuleHandle(0)
  20.     $hHook = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($hStub_KeyProc), $hmod)
  21.  
  22.     ; Esc to close the script
  23.  
  24.     $Gui=GUICreate('An example of interception with a hook', 700, 260, -1 , -1, $WS_OVERLAPPEDWINDOW)
  25.     $iEdit = GUICtrlCreateEdit('', 5, 5, 290, 250)
  26.     $iEditLog = GUICtrlCreateEdit('', 300, 5, 390, 250)
  27.     GUISetState()
  28.  
  29.     Do
  30.     Until GUIGetMsg()=-3
  31. EndFunc
  32. ;===========================================================
  33. ; callback function
  34. ;===========================================================
  35. Func _KeyProc($nCode, $wParam, $lParam)
  36.     Local $tKEYHOOKS, $X, $Y, $tmp, $Delta
  37.     If $nCode < 0 Then Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam) ; переход к следующей цепочки хуков в очереди (не срабатывает)
  38.     $tKEYHOOKS = DllStructCreate($tagKBDLLHOOKSTRUCT, $lParam)
  39.     ; mouse coordinates X, Y
  40.     $X = DllStructGetData($tKEYHOOKS, "vkCode")
  41.     $Y = DllStructGetData($tKEYHOOKS, "scanCode")
  42.  
  43. Switch $wParam
  44.     Case $WM_MOUSEWHEEL ; if the mouse wheel is spinning
  45.         $Delta = BitShift(DllStructGetData($tKEYHOOKS, "flags"), 16) ; определяет вниз или вврх
  46.        
  47.         If $Delta > 0 Then
  48.             $tmp= 'the mouse wheel moved UP ^'
  49.         Else
  50.             $tmp= 'the mouse wheel shifted DOWN v'
  51.         EndIf
  52.         $tmp &= ' ('&$Delta&')'
  53.        
  54.     Case $WM_LBUTTONDOWN
  55.         $tmp= 'Left-down'
  56.        
  57.     Case $WM_LBUTTONUP
  58.         $tmp= 'Left-Up'
  59.        
  60.     Case $WM_MBUTTONDOWN
  61.         $tmp= 'Middle Button Down'
  62.        
  63.     Case $WM_MBUTTONUP
  64.         $tmp= 'Middle Button Up'
  65.        
  66.     Case $WM_RBUTTONDOWN
  67.         $tmp= 'Right Button Down'
  68.        
  69.     Case $WM_RBUTTONUP
  70.         $tmp= 'Right Button Up'
  71.        
  72.     Case $WM_XBUTTONDOWN
  73.         $tmp= 'X-Button Down'
  74.        
  75.     Case $WM_XBUTTONUP
  76.         $tmp= 'X-Button Up'
  77.        
  78. #cs
  79. ; this block does not work
  80.        
  81.     Case $WM_LBUTTONDBLCLK ; does not work
  82.         $tmp= 'Double click Left mouse button'
  83.        
  84.     Case $WM_MBUTTONDBLCLK ; does not work
  85.         $tmp= 'Double click with the middle mouse button'
  86.        
  87.     Case $WM_RBUTTONDBLCLK ; does not work
  88.         $tmp= 'Double-click Right mouse button'
  89.        
  90.     Case $WM_XBUTTONDBLCLK ; does not work
  91.         $tmp= 'Double-click with the x-mouse button'
  92.        
  93.     Case $WM_NCLBUTTONDBLCLK
  94.         $tmp= 'Double click Left on title'
  95.        
  96.     Case $WM_NCLBUTTONDOWN
  97.         $tmp= 'Left Down on title'
  98.        
  99.     Case $WM_NCLBUTTONUP
  100.         $tmp= 'Left Up on title'
  101.        
  102.     Case $WM_NCMBUTTONDBLCLK
  103.         $tmp= 'Double click Middle on title'
  104.        
  105.     Case $WM_NCMBUTTONDOWN
  106.         $tmp= 'Clicking Middle on the title'
  107.        
  108.     Case $WM_NCMBUTTONUP
  109.         $tmp= 'Middle Clickout on title'
  110.        
  111.     Case $WM_NCRBUTTONDBLCLK
  112.         $tmp= 'Double click Right on title'
  113.        
  114.     Case $WM_NCRBUTTONDOWN
  115.         $tmp= 'Clicking Right on the title'
  116.        
  117.     Case $WM_NCRBUTTONUP
  118.         $tmp= 'Right-click on title'
  119.        
  120.     Case $WM_NCMOUSEMOVE
  121.         $tmp= 'Moving the mouse in the NOT client area'
  122. #ce
  123.        
  124.     ; Case $WM_MOUSEMOVE ; too much log writes
  125.         ; $tmp= 'Moving the mouse in the client area'
  126.     Case Else
  127.         $tmp = ""
  128.         WinSetTitle($Gui, '', "X: "&$X&", Y: "&$Y)
  129.         Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam) ; transition to the next chain of hooks in the queue
  130. EndSwitch
  131. GUICtrlSetData($iEditLog, $tmp& @CRLF, 1)
  132.     ; Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam) ; transition to the next chain of hooks in the queue
  133. EndFunc
  134.  
  135. Func Cleanup()
  136.     _WinAPI_UnhookWindowsHookEx($hHook)
  137.     DllCallbackFree($hStub_KeyProc)
  138. EndFunc
Add Comment
Please, Sign In to add comment