@spudw2k I want to listen to events of an external app. So in the meantime I found winapi's shellhookex(), with shellproc but I can't seem to trigger it when I create new windows after running the script.
#include <MsgBoxConstants.au3>
#include <StructureConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
Global $g_hHook
Example()
Func Example()
OnAutoItExitRegister("Cleanup")
$pcallback = DllCallbackGetPtr(DllCallbackRegister("MyCallback", "long", "int;wparam;lparam"));$WM_SHELL types
$g_hHook = _WinAPI_SetWindowsHookEx($WH_SHELL, $pcallback, _WinAPI_GetModuleHandle(0))
MsgBox($MB_SYSTEMMODAL, "", "Click OK, then in notepad type..." & _
@CRLF & @CRLF & "Jon" & @CRLF & "AutoIt" & @CRLF & @CRLF & "Press Esc to exit script")
Run("notepad.exe")
WinWait("[CLASS:Notepad]")
WinActivate("[CLASS:Notepad]")
While 1
Sleep(10)
WEnd
EndFunc ;==>Example
Func EvaluateKey()
EndFunc ;==>
; ===========================================================
; callback function
; ===========================================================
Func MyCallback($nCode, $wParam, $lParam) ; never called
msgbox(0,"Test","Test")
If $nCode < 0 Then
Return _WinAPI_CallNextHookEx($g_hHook, $nCode, $wParam, $lParam)
EndIf
If $nCode <> 1 Then
msgbox(0,"Test","Test")
EndIf
Return _WinAPI_CallNextHookEx($g_hHook, $nCode, $wParam, $lParam)
EndFunc ;==>_KeyProc
Func Cleanup()
_WinAPI_UnhookWindowsHookEx($g_hHook)
;DllCallbackFree($g_hStub_KeyProc)
EndFunc ;==>Cleanup