Jump to content

Proof of Concept "SetWindowsHookEx"


Recommended Posts

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...