AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Window Creation Hook

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
philou



Joined: 26 Jul 2006
Posts: 49
Location: Wuppertal

PostPosted: Wed Jan 23, 2008 12:17 pm    Post subject: Window Creation Hook Reply with quote

Hey Guys,
I need a way to catch the creation of an open/save dialog, without having to use a timer.
I tried to utilize portions of majkinetor's docking script, but this was merely some fooling around.
I also had a look at the wineventhook.dll, but not in-depth and I'd rather use an all-ahk method
It seems there's a fitting WinEvent:

Quote:
EVENT_OBJECT_CREATE
An object has been created. The system sends this event for the following user interface elements: caret, header control, list view control, tab control, toolbar control, tree view control, and window object. Server applications send this event for their accessible objects.

Servers must send this event for all of an object's child objects before sending the event for the parent object. Servers must ensure that all child objects are fully created and ready to accept IAccessible calls from clients when the parent object sends this event.

Because a parent object is created after its child objects, clients must make sure that an object's parent has been created before calling IAccessible::get_accParent, particularly if in-context hook functions are used.


WinEventProc returned an event (32768) on most occasions,
but I don't understand how to go on, or how to check which window sent the event, etc.
Any help?

Edit: Here's my attempt so far:
Code:
Dock_HostID := WinExist("ahk_class #32770")

Dock_hookProcAdr := RegisterCallback("Dock_HookProc")

Dock_hHook3 := API_SetWinEventHook(0x8000,0x8000,0,Dock_hookProcAdr,0,0,0)   ; EVENT_OBJECT_CREATE
If !Dock_hHook3
   API_UnhookWinEvent(Dock_hHook3)

; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   
API_SetWinEventHook(eventMin, eventMax, hmodWinEventProc, lpfnWinEventProc, idProcess, idThread, dwFlags) {
   DllCall("CoInitialize", "uint", 0)
   return DllCall("SetWinEventHook", "uint", eventMin, "uint", eventMax, "uint", hmodWinEventProc, "uint", lpfnWinEventProc, "uint", idProcess, "uint", idThread, "uint", dwFlags)
}

API_UnhookWinEvent( hWinEventHook ) {
   return DllCall("UnhookWinEvent", "uint", hWinEventHook)
}

; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Dock_HookProc(hWinEventHook, event, hwnd, idObject, idChild, dwEventThread, dwmsEventTime ) {
   global

   ToolTip, %event%
}


Last edited by philou on Wed Jan 23, 2008 4:58 pm; edited 1 time in total
Back to top
View user's profile Send private message
tonne



Joined: 06 Jun 2006
Posts: 1259
Location: Denmark

PostPosted: Wed Jan 23, 2008 12:42 pm    Post subject: Reply with quote

Maybe this link can help you http://www.autohotkey.com/forum/viewtopic.php?p=123323#123323
_________________
there's a dog barking close within the range of my ear
sounds like he wants to escape the chain
he would probably bite me to death if he could
but the chain lets me spit in his face

- Kashmir
Back to top
View user's profile Send private message
Guest






PostPosted: Wed Jan 23, 2008 3:12 pm    Post subject: Reply with quote

thank you for the link, unfortunately HSHELL_WINDOWCREATED is not sent on every window creation, it seems as if it only fires if the new window is owned by a new process, or something like that
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group