Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Tue 02 Sep 2014, 12:41
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
control hotkeys in gtk from a bash script?
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [8 Posts]  
Author Message
zigbert


Joined: 29 Mar 2006
Posts: 5701
Location: Valåmoen, Norway

PostPosted: Sat 01 Jan 2011, 15:14    Post subject:  control hotkeys in gtk from a bash script?  

I found this script that return keystroke value. It works great when running it in a terminal..... But......

Is it possible to start it from gtkdialog code in a way that the keystrokes responds from an active gui window? When I try, the key-script gets its own pid, and it seems to me that my keystrokes is out of reach of gtkdialog.


Thanks
Sigmund

Code:
#!/bin/bash

while IFS='^B' read -sn1 a; do # ^B is Control B
   k=`perl -e "printf('%d',ord('$a'));"`
   if (( k == 27 )) ; then
      while IFS='' read -sn1 -t1 c; do
         l=`perl -e "printf('%d',ord('$c'));"`
         k="$k $l"
         grep "^$k 0 " $0 > /dev/null
         if (( $? == 0 )) ; then
            break
         fi
      done
   fi
#   echo $k
   gxmessage $k
   grep "^$k 0 " $0
done
# never gets here
exit

27 79 70 0 end
27 79 72 0 home
27 79 81 0 f2
27 79 82 0 f3
27 79 83 0 f4
27 91 49 53 126 0 f5
27 91 49 55 126 0 f6
27 91 49 56 126 0 f7
27 91 49 57 126 0 f8
27 91 50 48 126 0 f9
27 91 50 49 126 0 f10
27 91 50 52 126 0 f12
27 91 50 126 0 insert
27 91 51 126 0 delete
27 91 49 126 0 home
27 91 52 126 0 end
27 91 53 126 0 pageUp
27 91 54 126 0 pageDown
27 91 65 0 up
27 91 66 0 down
27 91 67 0 right
27 91 68 0 left
27 91 49 59 53 67 0 ctl-right
27 91 49 59 53 68 0 ctl-left
27 91 49 59 53 65 0 ctl-up
27 91 49 59 53 66 0 ctl-down
27 91 69 0 keypad-five
9 0 tab
33 0 bang
35 0 pound
36 0 dollarSign
37 0 percent
38 0 ampersand
40 0 openParen

_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
Karl Godt


Joined: 20 Jun 2010
Posts: 3964
Location: Kiel,Germany

PostPosted: Thu 13 Jan 2011, 13:58    Post subject:  

I could think of somethink like

<entry>
<variable>Entry</variable>
<input>cat /tmp/TEMPFILE</input>
</entry>
<action>
./FILE</action>
--------------------------------------
FILE
#!/bin/bash

CODE to get KEY

echo $k > /tmp/TEMPFILE
--------------------------------------
<action>cat /tmp/TEMPFILE</action>
<action>refresh:Entry</action>


I started to dislike the rubbering of the parent window and added
a " & "
<action>./FILE &</action>
and a
<hbox>
<button><input file stock=\"gtk-refresh\"></input><label>REFRESH
Files</label>
<action type=\"clear\">Entry</action>
<action>Refresh:Entry</action>
<action type=\"clear\">Entry3</action>
<action>Refresh:Entry3</action>
</button>

so the user must hit it to show the changed entry ....
Back to top
View user's profile Send private message Visit poster's website 
technosaurus


Joined: 18 May 2008
Posts: 4348

PostPosted: Sat 15 Jan 2011, 00:34    Post subject:  

there are a lot of keyloggers (most lighter than perl) ... then you could clear the log file and use tail -n [# of bytes]
but some languages have different number of bytes and the Esc key and others are doubles

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
zigbert


Joined: 29 Mar 2006
Posts: 5701
Location: Valåmoen, Norway

PostPosted: Sun 16 Jan 2011, 03:36    Post subject:  

technosaurus wrote:
then you could clear the log file and use tail -n [# of bytes]
Great answer, it could work. Do you know where to find a keylogger without perl that won't add new dependencies to Puppy. At least not something big.


Thank you
Sigmund

_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
seaside

Joined: 11 Apr 2007
Posts: 886

PostPosted: Sun 16 Jan 2011, 12:27    Post subject:  

zigbert wrote:
technosaurus wrote:
then you could clear the log file and use tail -n [# of bytes]
Great answer, it could work. Do you know where to find a keylogger without perl that won't add new dependencies to Puppy. At least not something big.


Thank you
Sigmund


zigbert,

I'm not sure about dependencies, but Logkeys apparently runs on Ubuntu Lucid and the latest can be found here-
http://code.google.com/p/logkeys/

It requires compiling and I've never tried it, but it seems better than some of the other keyloggers.

Regards,
s
Back to top
View user's profile Send private message 
jpeps

Joined: 31 May 2008
Posts: 3220

PostPosted: Sun 16 Jan 2011, 14:01    Post subject:  

Why is using Perl an issue? It's already in base:


Code:

#!/usr/bin/perl
$key="@ARGV";
print ord($key);
Back to top
View user's profile Send private message 
seaside

Joined: 11 Apr 2007
Posts: 886

PostPosted: Tue 18 Jan 2011, 17:58    Post subject:  

jpeps wrote:
Why is using Perl an issue? It's already in base:


Code:

#!/usr/bin/perl
$key="@ARGV";
print ord($key);


jpeps,

I agree and I've just posted a 300k keylogger (logkeys-0.1.0.pet) here-
http://murga-linux.com/puppy/viewtopic.php?p=487764#487764
which would be a bit of overkill.....

Regards,
s
(Logkeys does work rather well, however...)
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4348

PostPosted: Tue 18 Jan 2011, 21:33    Post subject:  

I sometimes forget that perl in base is slightly stripped while the rest of the modules are in the devx ... I nearly always have the devx merged with my main sfs & it made for a confounding bug hunt in a script
_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [8 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0696s ][ Queries: 12 (0.0095s) ][ GZIP on ]