I m creating an app! in which if the user moves the cursor the message should be displayed! But I m using setcursorpos() in my form to set cursor position which display the message! I dont want message to be displayed when mouse is moved through function, I want message to be displayed when user moves the mouse through hardware only (i.e moving mouse with hand)

I want message to be displayed when user moves the mouse through hardware only (i.e moving mouse with hand)

What would that suppose to mean? You mean moving cursor with keyboard (directional keys)?

No.

Msg should appear when I move mouse and not if there is change in coordinates in setcursorpos().

So u want to show msg when your mouse moves over ur form? and wanna hide it after some time when mouse dnt move? or u mant to hide it if mouse coordinates change? n where is ur mouse going to move? On any control or on form?
I know there are many questions :D
But u will have to explain the whole idea.

I think what he's trying to accomplish is:
He has a function foo() that does two things when the cursor is moved: displays a MessageBox, and calls setcurspos() to move the cursor on top of the MessageBox.
However, because he's calling setcurspos() in foo(), foo() gets called again because the cursor position changed (due to his method call in foo()).
So his end goal is to still call setcurspos() in foo(), but not have it recursively called due to the change of the cursor's position through the function, but solely have foo() called in response to actual user input. Hope that's cleared up the situation.

Cursor positioned changed? call foo()
foo() calls setcurspos(), changes cursor position, calls foo()
^-----------------------------------------------------------------------------|
repeats.

I have my form running I just want to know how to check if my mouse is moved or not? not only on form but anywhere on desktop!As We have our computer hooked up with mouse, which we use to control cursor. So, if I move that mouse! my form will recognize that mouse has been moved and will call intended function!

I m making automatic cursor movement recording program. (check this video http://www.youtube.com/watch?v=YYJ_xNITxLA)

So when the cursor is moving automatically (i.e through setCursorPos()), and if the user moves his mouse(input device) cursor automatic movement should pause/halt.

What I m not getting is How to access mouse movements made by mouse(hardware).?

I followed that tutorial and modified the code, didnt achieve exactly what u wanted but this may help u at some level(code in VB.NET)

What it does is if u drag ur mouse on form within 100ms then PLay stops.

Please someone give me alternative solution.

How to check if cursor is moved manually and not by any function such as SetCursorPos()?

I don't think it's easily done (I bet there's some sort of Win32 function for it, but good luck finding it).

What I would do is wherever SetCursorPos() is being called, set a flag just before it (something like ProgramMovedMouse=true). Then in the Mouse_Move event check this flag before showing the messagebox. If it is set, then don't show the box and clear the flag. Otherwise show the messagebox as usual.

Hi skatamatic,
I helped him with setting flags but what he wants is he want detect mouse movement not just when mouse over form but all the time on whole screen. I tried searching but didnt find any solution.
Is there any way to do this? Means detecting mouse movement directly.

Hi skatamatic,
I helped him with setting flags but what he wants is he want detect mouse movement not just when mouse over form but all the time on whole screen. I tried searching but didnt find any solution.
Is there any way to do this? Means detecting mouse movement directly.

Yes, you can using the win32 api. But some software might consider this activity malicious, so be careful.
This guy seems to have done all the hard work for you, just reference his dll and follow the documentation.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.