Modify ↓
Opened 14 years ago
Closed 14 years ago
#1979 closed Bug (No Bug)
_WinAPI_SetWindowsHookEx() Don`t work with all idHook
| Reported by: | monoscout999 | Owned by: | Gary |
|---|---|---|---|
| Milestone: | Component: | Standard UDFs | |
| Version: | 3.3.6.1 | Severity: | None |
| Keywords: | Hooks, Hook | Cc: |
Description
_WinAPI_SetWindowsHookEx() only works when the idHook parameter is $WH_KEYBOARD_LL or $WH_MOUSE_LL and not when the idHook parameter is another as $WH_CALLWNDPROCRET for example.
#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <StructureConstants.au3>
Opt('MustDeclareVars', 1)
Global $hHook, $hStub_CallWndRetProc, $buffer = ""
_Main()
Func _Main()
OnAutoItExitRegister("Cleanup")
Local $hmod
$hStub_CallWndRetProc = DllCallbackRegister("_CallWndRetProc", "long", "int;wparam;lparam")
$hmod = _WinAPI_GetModuleHandle(0)
$hHook = _WinAPI_SetWindowsHookEx($WH_CALLWNDPROCRET, DllCallbackGetPtr($hStub_CallWndRetProc), $hmod)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $hHook = ' & $hHook & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
While 1
Sleep(10)
WEnd
EndFunc ;==>_Main
;===========================================================
; callback function
;===========================================================
Func _CallWndRetProc($nCode, $wParam, $lParam)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $nCode = ' & $nCode & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
local $tagCWPRETSTRUCT = "LRESULT lResult;LPARAM lParam;WPARAM wParam;UINT message;HWND hwnd;"
Local $tCWPRETSTRUCT = DllStructCreate($tagCWPRETSTRUCT, $lParam)
If $nCode < 0 Then
Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam)
EndIf
If DllStructGetData($tCWPRETSTRUCT, "message") = $WM_MOUSEMOVE Then
ConsoleWrite("Mouse Move Message Recived by - " & DllStructGetData($tCWPRETSTRUCT, "hwnd") & @CRLF)
EndIf
Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam)
EndFunc ;==>_KeyProc
Func Cleanup()
_WinAPI_UnhookWindowsHookEx($hHook)
DllCallbackFree($hStub_CallWndRetProc)
EndFunc ;==>Cleanup
Attachments (0)
Change History (1)
comment:1 Changed 14 years ago by Valik
- Resolution set to No Bug
- Status changed from new to closed
Guidelines for posting comments:
- You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
- In-depth discussions should take place on the forum.
For more information see the full version of the ticket guidelines here.
Note: See
TracTickets for help on using
tickets.

You do not know how to use the function, no more, no less.