Source Code File 14-02_mspy
14-02_mspy.c
#include <ncurses.h> int main() { MEVENT mort; int ch; initscr(); noecho(); keypad(stdscr,TRUE); mousemask(ALL_MOUSE_EVENTS,NULL); while(1) { ch = getch(); if( ch == KEY_MOUSE ) { getmouse(&mort); move(0,0); clrtoeol(); printw("%d\t%d",mort.y,mort.x); refresh(); continue; } if( ch == '\n' ) break; } endwin(); return(0); }
Output Screenshot
Notes
* Variable mort
is short for Mortimer, which was Mickey Mouse's original first name.
* The noecho() function at Line 9 ensures that any text typed doesn't appear on the screen.
* The clrtoeol() function at Line 20 erases the previous coordinate pair. Otherwise the numbers can be misread.
* In the screenshot (above), you see the mouse pointer, which is shaped like an I-beam over my computer's terminal window. That's the approximate location clicked.
Copyright © 1997-2024 by QPBC.
All rights reserved