Jump to content

Recommended Posts

Posted

Hey there,

i hope me asking alot of questions doesn't annoy anyone... :whistle:

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 accordingly

am currently reseaching on event handling stuff, but if anyone

already knows how to do this or where i can read about it i would be greatful

thanks :D


Posted (edited)

It looks like you should learn another language :lol:

You are trying to create a "system-wide event hook".

Read there : http://www.vbaccelerator.com/codelib/hook/vbalhook.htm

Hook Scope: System Wide or Local Thread Hooks

One 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 :no:

Edited by Delprat
Posted (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 buggy

i 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 ( :no: ) to put a record in a database that it had an error...so trying to do a system hook would be better

anyways am still reading and checking examples to get to the bottom of this

Edited by saprouzy

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
  • Recently Browsing   0 members

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