LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 06-27-2002, 10:42 PM   #1
purpleburple
Member
 
Registered: Jun 2002
Location: USA
Distribution: Slackware8.1
Posts: 332

Rep: Reputation: 30
Need a simple script that will take screenshots and ...


Hi. Is there a simple C program or bash script(not so sure that a script would work though) that I could write or anyone could show me that would take a snapshot of a certain window on the screen and then save it to a numbered file such as cap1.jpg cap2.jpg etc. and be able to map a key on the keyboard that would take the snapshot?

thanks
New to C and learning
 
Old 06-28-2002, 08:22 AM   #2
lackluster
Member
 
Registered: Apr 2002
Location: D.C - USA
Distribution: slackware-current
Posts: 488

Rep: Reputation: 30
there are a number of C headers & libs I've seen floating around that will simplify writing to jpg (or jpeg) format. As for the screenshots, uh......why dont you try to uh.....hmmm.......find the printscreen ascii's value; trigger the printscreen button; take from whereever the button puts the screen in memory and write it out to a file (ordered by # like you said)? I don't know if this is feasable, but if you look into it, I'm sure you'll find plenty of useless information that is actually quite intresting . I'd be suprised to find a script that wrote jpeg (or jpg) format (except Perl, that wouldn't suprise me).
 
Old 07-07-2002, 04:38 PM   #3
kervin
Member
 
Registered: Jan 2002
Location: Melbourne, FL.
Distribution: redhat
Posts: 168

Rep: Reputation: 30
use gimp. http://gimp.org/ Gimp comes with the screenshot plugin.

You can use scriptFU or PerlFU to extend it's functionality if needed beyond that.
 
Old 07-08-2002, 08:32 PM   #4
Crow
LQ Newbie
 
Registered: Jul 2002
Posts: 1

Rep: Reputation: 0
Lightbulb

Hey, just what I was working on (and needing amateur bash help on). On the command line you can do the following command to get a jpeg screenshot of the whole screen:

import -window root screenshot.jpeg

If you want a screenshot of just one window type:

import screenshot.jpeg

and you select the window with your mouse.

Here's a simple 2-line BASH shell script to do it:

#! /bin/sh
import screenshot.jpeg

Wow, what a guru I am, huh? That script puts out a jpeg in your current directory. You can change it a little to suit you such as replacing 'screenshot.jpeg' with /home/yourname/cap.jpeg and you get a jpeg in your home directory.

And now my question: Every time I run that script, it saves it as 'screenshot.jpeg', so if there is already one, it overwrites it. What can I add to name them in ascending order, like cap1.jpg cap2.jpg etc
 
Old 07-08-2002, 09:08 PM   #5
kervin
Member
 
Registered: Jan 2002
Location: Melbourne, FL.
Distribution: redhat
Posts: 168

Rep: Reputation: 30
I haven't tested this but something like that should work

#!/bin/sh
NAME=screenshot
COUNT=1
while [ -f "$NAME$COUNT.jpg" ]
do
COUNT=`expr $COUNT + 1`
done
import $NAME$COUNT.jpg

'man test' for how to use the '[' ']' operator and what the '-f' means. '-f' tests to see if the file by that name exists.

'expr' increments the COUNT variable.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Iptables (with masq) troubleshooting, very simple script attached script and logs. xinu Linux - Networking 13 11-01-2007 04:19 AM
New to C++ help with simple script Fredstar Programming 9 08-08-2005 11:09 AM
A Simple Script fiod Linux - General 3 09-20-2003 08:56 PM
Simple Script fiod Linux - General 2 09-08-2003 03:03 PM
Simple C Shell script is not so simple elconde Programming 2 09-16-2001 11:53 PM


All times are GMT -5. The time now is 10:14 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration