Sign in to follow this  
Followers 0
4nt1h4cker

Proof of Concept "SetWindowsHookEx"

3 posts in this topic

I just tried to use SetWindowsHookEx in Autoit, first one good message i got i working so far. But i cant really handle the data.

$vCallBack = DllCallbackRegister ( "_hook", "int", "int;wparam;lparam;"); 

;~ ConsoleWrite ($vCallBack & @error)

$threadid = DllCall("kernel32.dll", "dword", "GetCurrentThreadId")
;~ ConsoleWrite ( "thread id: "& $threadid[0] & @CRLF)

$handle = DllCall ("user32.dll", "ptr", "SetWindowsHookEx", "int", 5, "ptr", DllCallbackGetPtr ($vCallBack), "int", 0, "dword", $threadid[0])


While 1
;~  Sleep ( 1 )
WEnd



func _hook ($nCode, $wParam, $lParam)
;~  ConsoleWrite ("here!")
;~  ConsoleWrite ($nCode & "|" & $wParam & "|" & $lParam & @CRLF )
    if $nCode < 0 Then
        DllCall ( "user32.dll", "int", "CallNextHookEx", "ptr", $handle[0], "int", $nCode, "wparam", $wParam, "lparam", $lParam)
        Return
    EndIf
    
    if $nCode == 3 Then
        ConsoleWrite ( "Window created: " & WinGetTitle ( $wParam ) & @CRLF )
    EndIf
    
    DllCall ( "user32.dll", "int", "CallNextHookEx", "ptr", $handle[0], "int", $nCode, "wparam", $wParam, "lparam", $lParam)
EndFunc

Share this post


Link to post
Share on other sites



SetWindowsHookEx is already implemented in the standard UDF library (_WinAPI_SetWindowHookEx()) with a working example. Play around with it :)


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

Oh cool! Thank you.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0