10-27-2006, 08:16 PM
This is an alternative "created window" trigger that can be used in exe. You need to edit something.
Macro
Function WE_CreatedWindowInstall
Function WE_CreatedWindowProc
Macro
;This is an example.
mac "WE_CreatedWindowInstall" ;;launch "created window" triggers in new thread
;do other things ...
Function WE_CreatedWindowInstall
function [off]
;Installs/uninstalls hooks that will call WE_CreatedWindowProc whenever an object is created.
;This function does not need to be modified.
int-- hook
if(off) if(hook) UnhookWinEvent(hook); hook=0
else
,if(getopt(nthreads)>1) mes "Already running. If in QM, use Threads dialog to end thread. If in exe, thread will end automatically." "" "i"; ret
,hook=SetWinEventHook(EVENT_OBJECT_CREATE EVENT_OBJECT_CREATE 0 &WE_CreatedWindowProc 0 0 WINEVENT_OUTOFCONTEXT)
,atend WE_CreatedWindowInstall 1
,opt waitmsg 1
,wait -1Function WE_CreatedWindowProc
;/WE_Main
function hhook event hwnd idObject idChild dwEventThread dwmsEventTime
if(!hwnd or idObject or idChild or GetWindowLong(hwnd GWL_STYLE)&WS_CHILD) ret
;This function is called whenever a window (hwnd) is created. Edit it.
;Must return as soon as possible. Must not execute any code that would
;interact with applications (instead use mac to start other macros).
;This code only shows what window is created
str sc.getwinclass(hwnd) st.getwintext(hwnd)
out "class=%s, text=%s" sc st
;;To filter windows and launch macros, here you can use code like this
;if(wintest(hwnd "window text" "window class" ...))
,;mac "some macro"
;else if(wintest(hwnd "window text" "window class" ...))
,;mac "another macro"
;...
