saprouzy Posted June 29, 2005 Posted June 29, 2005 Hey there,i hope me asking alot of questions doesn't annoy anyone... is there a way to catch events that happen in another applications,for example, if app1 poped up a msgbox, i want app_catcher to notice this event and act accordinglyam currently reseaching on event handling stuff, but if anyonealready knows how to do this or where i can read about it i would be greatfulthanks
Delprat Posted June 29, 2005 Posted June 29, 2005 (edited) It looks like you should learn another language You are trying to create a "system-wide event hook".Read there : http://www.vbaccelerator.com/codelib/hook/vbalhook.htmHook Scope: System Wide or Local Thread HooksOne of the features of the Win32 Hook library is that it allows you to specify whether the scope of your hook is local to the current thread or whether it applies to all windows in the entire system. System Wide hooks are always a topic of interest because they let you modify windows in other applications; for example the stupidly-named Window Blinds application uses this method to apply a skin when drawing all windows on your system (well, it tries to, anyway!)Before you get excited, though, VB on its own cannot be used to create a system-wide hook. This is because the hook procedure must reside within a Windows DLL, and VB cannot create these beasts (because you cannot specify to export the HookProc function). Also I should point out that system-wide hooks aren't much fun to write: you can't debug them, and if anything goes wrong it takes your whole system down! If you have some C knowledge, however, you can steal code either from the Spy utility provided with the NT Resource Kit or there is a most interesting sample at CodeGuru.com which adds a Pin button to the caption of all windows on the system.good luck !EDIT: maybe you will work around this issue with a timer and "EnumWindow" API (testing indefinitely if the right caption appear in a window) ; but it will be ugly and buggy Edited June 29, 2005 by Delprat
saprouzy Posted June 30, 2005 Author Posted June 30, 2005 (edited) maybe you will work around this issue with a timer and "EnumWindow" API (testing indefinitely if the right caption appear in a window) ; but it will be ugly and buggyi think this could work, since it's not necessary to catch the msgbox instantly, i can do a check every 10 minutes what am trying to do, is to check whether an application among the ones running generated an error msgbox, if so, kill it's process and run it again...can the enumwindow get the name of the application that caused a msgbox to appear?i know i can do this in another way but then it would need modification to all the apps ( ) to put a record in a database that it had an error...so trying to do a system hook would be betteranyways am still reading and checking examples to get to the bottom of this Edited June 30, 2005 by saprouzy
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now