LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 01-13-2010, 12:07 AM   #1
rajmohannambiar
LQ Newbie
 
Registered: Dec 2007
Posts: 6

Rep: Reputation: 0
Sending keystrokes from C program to certain running applications


My requirement is to save files before shutting the Linux machine down, unattended ie: when the user is not near the machine. This is done whenever the UPS battery is about to die, so that the files get saved. open-Office/text-editor applications that can be saved using keystrokes will have to be found from the running processes and keystrokes should be sent to them from a C program that was started in non-graphics stage. ie: from a C program that forks into memory as a daemon before xwindows part starts.

How to I send keystrokes to a running application? (like cotrol + F and then wait and then send next set of keystrokes till the file is saved
as a new file or as the same file itself), either from C program or a script?
 
Old 01-13-2010, 02:44 AM   #2
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Bookworm (Fluxbox WM)
Posts: 1,391
Blog Entries: 54

Rep: Reputation: 360Reputation: 360Reputation: 360Reputation: 360
The xdotools project might help you script this behaviour. In C you could make use of xlib calls such as XSendEvent.

The other possibility is of course to simply hibernate to disk...

Last edited by neonsignal; 01-13-2010 at 02:49 AM.
 
  


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
CPU running at 100% usage while no applications are running mike_morley Linux - Desktop 14 05-17-2007 09:39 PM
sending keystrokes pass Programming 4 08-19-2006 03:13 PM
Sending keystrokes to a gui lm317t Programming 3 10-11-2005 06:17 PM
Sending Keystrokes lm317t Linux - Software 0 10-10-2005 04:02 PM
Sending Keystrokes to a window seidren Programming 5 10-28-2003 06:24 AM

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

All times are GMT -5. The time now is 05:17 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