LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-22-2010, 11:29 PM   #1
efittery
LQ Newbie
 
Registered: Jul 2008
Posts: 3

Rep: Reputation: 0
Angry Using SCROT to capture portion of window


Scrot supports capturing a portion of the screen by
allowing the user to use the -s option. I need to
use the command line.

So I installed xdotool to allow me from the command line
to move my mouse, click buttons, type text, select my
focus, etc...

I also built a bash script that uses scrot and xdotool
that allows me to select the window that has a firefox
web page displayed. Then I can position the mouse and
do a right button click to position to a data entry box
on the web page. Then I can use xdotool type "my text"
to input the text into the input box. All this works
very neatly.

My problem is the following:

The command "xdotool mousemove x y" does not move relative
to the top left hand corner of the focused window. The command
moves to the absolute x y screen location, not the relative window location.

This happens even though I use the command "xdotool windowfocus
windowid" or command "xdotool windowactivate windowid" to specify
which window I want to use (want in focus).

Does anybody know how to specify that the
"xdotool mousemove x y" is
to move relative to the upper left hand
corner of the currently
in focus window?

thanks

By the way, here is my bash script:

#!/bin/bash

# get window id
WIN_ID=`xdotool search --title MyWindow`

# activate window with title MyWindow
xdotool windowactivate $WIN_ID

# move to x, y location -- this is an absolute screen location move
xdotool mousemove $1 $2
# how does one do a relative location move based on focused window?

# do a left button click
xdotool click 1
sleep 0.01

# type out desired text in $3
xdotool type "$3" && xdotool key Return && sleep 0.2
sleep 0.01
 
Old 01-24-2010, 08:16 AM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
This is from xdtool documentation:
Quote:
SENDEVENT NOTES

If you are trying to send key input to a specific window, and it does not appear to be working, then it's likely your application is ignoring the events xdotool is generating. This is fairly common.

Sending keystrokes to a specific window uses a different API than simply typing to the active window. If you specify 'xdotool type --window 12345 hello' xdotool will generate key events and send them directly to window 12345. However, X11 servers will set a special flag on all events generated in this way (see XEvent.xany.send_event in X11's manual). Many programs observe this flag and reject these events.

Some programs can be configured to accept events even if they are generated by xdotool. Seek the documentation of your application for help.

Specific application notes (from the author's testing): * Firefox 3 seems to ignore all input when it does not have focus. * xterm can be configured while running with ctrl+leftclick, 'Allow SendEvents' * gnome-terminal appears to accept generated input by default.
 
Old 01-26-2010, 07:06 PM   #3
efittery
LQ Newbie
 
Registered: Jul 2008
Posts: 3

Original Poster
Rep: Reputation: 0
I will try a different approach

Quote:
Originally Posted by bigrigdriver View Post
This is from xdtool documentation:
Thanks.

I guess I will just spin my own by using imlib2 and not use a bash
wrapper to call SCROT and xdotool.

The results of a dedicated peice of code to capture a portion of the window in focus will certainly execute a lot faster than

Take care
 
  


Reply

Tags
bash, capture, screen



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
Capture a scrolling window? evilc77 Linux - General 2 05-04-2007 09:08 PM
Video capture from window on MDK10 Entropius Linux - Software 2 07-24-2004 05:33 PM
enlightenment and scrot jon1117 Linux - Software 0 07-12-2004 08:00 PM
How to install scrot? macleo Linux - Software 0 07-06-2004 10:51 PM
How to uncover the blocked portion of a window? gxie Linux - General 2 11-21-2003 10:50 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:40 PM.

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