Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to control ...... 1

Status
Not open for further replies.

dishan

Programmer
May 19, 2003
1
0
0
LK
How to control mouse in c
 
You can't. The mouse is an input device only. There is no way to output data to a mouse.

-pete
 
You can control the mouse pointer, which is what I assume the poster means. However, C does not specify anything about controlling the mouse, so you'll need to resort to operating-system/compiler specific facilities to do so.

Since you don't mention the platform you want your code to work on...
 
Code:
// poltergeist.cpp
// Simple object manipulation program

#include <telepathy.h>
#include &quot;detection.h&quot;  // user-defined function detect_mouse

int main()
{
    PHYSICAL_OBJECT mouse = detect_mouse();

    apply_telepathic_force( mouse, 20, TP_WEST );
    apply_telepathic_force( mouse, 20, TP_NORTH );

    return 0;
}

(Error detection omitted for simplicity).
 
More seriously, it depends on your system. We're in C here so I'll assume you might be interested in a 16-bit DOS environment on a PC (big assumption) in which case interrupt 033h does the job. You can move the mouse pointer about, find out what the user is doing with the mouse, and everything. It's very easy.
Just do a web search for that, and you'll find it. But beware of computers with windows operating systems installed by an Oik who thought dos didn't matter and didn't bother installing the dos mouse driver (there are not many around nowadays, but a couple of years ago this was very common).

If in windows, someone else can answer, I am not an expert.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top