LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-30-2009, 11:06 PM   #1
ganyks
LQ Newbie
 
Registered: Nov 2009
Posts: 2

Rep: Reputation: 0
C: programming macro recorder and pixel reader


I am currently writing a game-playing ai program that needs to access the mouse, keyboard, and screen while running in the background. I've searched extensively so far with no results on how to write this. It needs to work on Ubuntu Linux.
 
Old 12-01-2009, 02:47 AM   #2
echo36
LQ Newbie
 
Registered: Nov 2009
Posts: 6

Rep: Reputation: 1
What do you mean by access? Does it need to know when the mouse is moved, keys are pressed, etc? Or does it need to generate mouse clicks and key presses?

Normally I would assume the former, but because of what you're doing, I needed clarification.
 
Old 12-01-2009, 06:11 PM   #3
ganyks
LQ Newbie
 
Registered: Nov 2009
Posts: 2

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by echo36 View Post
What do you mean by access? Does it need to know when the mouse is moved, keys are pressed, etc? Or does it need to generate mouse clicks and key presses?

Normally I would assume the former, but because of what you're doing, I needed clarification.
Generate mouse clicks and key presses.
 
Old 12-02-2009, 12:43 AM   #4
echo36
LQ Newbie
 
Registered: Nov 2009
Posts: 6

Rep: Reputation: 1
If you want to generate mouse and keyboard events from a program in the background, you can use the uinput virtual device driver. First make sure that the driver is loaded by checking to see if the /dev/input/uinput file exists. If it doesn't, load the module with

Code:
sudo modprode uinput
You can generate input events by writing to this file. A good reference for this can by found in the wminput project that allows the wiimote to be used as an input device in linux. Here is a link to the most relevant file in that project:

http://abstrakraft.org/cwiid/browser...input/uinput.c


As for reading the screen, the X windows system provides functionality to obtain a dump of any of the windows under its control, including the root window. Look at the documentation of the XGetImage() function in Xlib.
 
Old 12-02-2009, 08:04 AM   #5
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,784

Rep: Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083
What about XSendEvent()?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
VOX Recorder and Audio Timer Recorder? devmoc Linux - Software 6 10-23-2009 11:55 PM
Linux Mouse Recorder Macro Program floorit Linux - Software 2 06-14-2008 06:57 PM
I can't configure my cd-dvd recorder as a recorder!!! slamd64 Lier Linux - Software 4 10-26-2006 11:40 PM
#defining a macro inside a macro? saravkrish Programming 1 05-24-2005 09:48 PM
Is there a good macro recorder in linux? Bad_Bob Linux - Software 6 06-22-2004 08:04 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:33 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration