Cursor Move

  • Thread starter Thread starter Guest
  • Start date Start date
Hi,

I dont think, there is any event to trap the "mousemove" within the
application, when you move mouse over the desktop (other than the app).
However, events like "SystemColors changed" can be trapped inside our
application when its changed OS level.

We can do other stuffs like monitering directories using "File Watchers"
which will raise event when something is changed in the directory of which
we are watching.

Sometimes, when there is a change in Env or registry values, HWND_BROADCAST
will raise an event inside our application. We can catch it and process.

The feature you are looking is really worth to have it, if microsoft exposes
it to developers. I believe they have this method for their applications,
like word or excel.

Shak.


Bill English said:
Is there an event for when the cursor moves? Not for a form, but for the whole screen?
don't get mad if I ask a stupid question. Thanks.
 
Another thought.

The closest thing which you can do imitating Microsoft spy++. Using
mousemove you can find the window, and get the class and handle for each
control of external application including desktop by this approach. If this
is ur goal, then simulate spy++.

Shak.



Bill English said:
Is there an event for when the cursor moves? Not for a form, but for the whole screen?
don't get mad if I ask a stupid question. Thanks.
 
AFAIK it can't be done without resorting to the Win32 API. The function you
would use is SetWindowsHookEx. Since you want the events for the whole
screen you're looking at a global hook. I believe for global hooks you'll
have to build it into a DLL, and I also believe you may have to do some
unmanaged coding. Note also that global hooks have a performance hit
associated with them.

What exactly are you trying to achieve? It could be that there's some
alternative based on your proposed usage.

Stu



Bill English said:
Is there an event for when the cursor moves? Not for a form, but for the whole screen?
don't get mad if I ask a stupid question. Thanks.
 
Bill English said:
What is the difference between managed and unmanaged code?

Managed code is what is produced when you code in C#, VB.NET, or Managed
C++. According to MS, the definition is:

"Code executed and managed by the Microsoft® .NET Framework, specifically by
the .NET Framework's common language runtime. Managed code must supply the
information necessary for the common language runtime to provide services
such as memory management, cross-language integration, code access security,
and automatic lifetime control of objects. All code based on Microsoft
Intermediate Language executes as managed code."

Unmanaged code is what is produced by 'standard' C++ or C etc:

"Code that is executed directly by the operating system, outside the
Microsoft .NET Framework's common language runtime. Unmanaged code must
provide its own memory management, type checking, and security support,
unlike managed code, which receives these services from the common language
runtime. Unmanaged code must be executed outside the .NET Framework."

So basically, if you want to install a global hook, you're almost certainly
going to have to write unmanaged code, probably in the form of a C or C++
DLL. You'll then have to write some code that can interface between that and
the rest of your application, which I'm assuming is in C#. That interface
layer will either be in Managed C++, or will be P/Invoke calls from C#.

Stu
 
Back
Top