LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 09-16-2008, 08:04 PM   #1
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
How to set the focus to the window my bash program is running in?


Sorry, I was not able to summarize my question in a better way the title.

The question is this. I have written a bash script. The script calls in a loop Imagemagick's display and displays the contents of a graphical file (jpg). I run KDE.

The script then asks me whether or not I should perform an operation on the file displayed. If I answer affirmative, the operation is performed and the next image is shown, if I respond negative, the next image is shown.

The problem is that whenever the image is shown, the ImageMagick window gets the focus. I have to use the mouse or a key combination to set the focus back to the Konsole window my script is running in.

What I actually want is that immediately after the Imagemagick window is shown, my Konsole window get the focus back you that I can press just one key, instead of using both mouse and keyboard.

It is no problem that the Imagemgick window gets partially obscured by the console, but it would be nice if I could force the Imagemagick window to -say- the rightmost side of the screen.

Any ideas how to manipulate KDE Windows from within a bash script? I googled for 'windows' but the result was predictable.

jlinkels
 
Old 09-18-2008, 05:26 AM   #2
234107
LQ Newbie
 
Registered: Sep 2008
Posts: 8

Rep: Reputation: 0
One fast solution is to use xautomation tools - http://hoopajoo.net/projects/xautomation.html and then use it in your script like this:

Code:
$xte "key F2"
xte is one of the tools you can find inside. Dont forget ofc to bind key combination to focus.

The other solution is to write ur own code using XTest... and get rid of this bash script.

You can use the same way if thats more comfortable for you, to move your mouse at certain coordinates and perform mouse click like this:


Code:
$xte 'mousemove X Y'
$xte 'mousedown 1'
Maybe there are other easier solutions... :\
 
  


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
Question about running a program from terminal window ganoo Linux - Newbie 7 11-01-2010 12:44 PM
Fluxbox : set focus on opened window mat087 Linux - Newbie 2 09-12-2006 07:14 PM
Running program in GUI opens term window zer0hmz Linux - Newbie 2 08-05-2006 02:36 AM
Bash: set Konsole window title to current command bforbes Programming 5 04-19-2006 11:44 AM
bash script - open new window running a command zippity Linux - Newbie 1 07-13-2004 11:16 AM

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

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