LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Using SCROT to capture portion of window (https://www.linuxquestions.org/questions/linux-software-2/using-scrot-to-capture-portion-of-window-784147/)

efittery 01-22-2010 11:29 PM

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

bigrigdriver 01-24-2010 08:16 AM

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.

efittery 01-26-2010 07:06 PM

I will try a different approach
 
Quote:

Originally Posted by bigrigdriver (Post 3838676)
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


All times are GMT -5. The time now is 01:00 PM.