Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #54179

Re: Monitor key presses in Python?

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'offline': 0.03; 'win32': 0.03; 'subject:Python': 0.06; 'purpose.': 0.07; 'see:': 0.07; 'function,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'separately': 0.09; 'url:activepython': 0.09; 'url:activestate': 0.09; 'windows,': 0.09; 'yeah,': 0.09; "wouldn't": 0.14; '"system': 0.16; 'focus,': 0.16; 'portable,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'stuff.': 0.16; 'subject:key': 0.16; 'threw': 0.16; 'url:pywin32': 0.16; 'url:timgolden': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'module': 0.19; 'first.': 0.19; 'fit': 0.20; 'help.': 0.21; 'separate': 0.22; 'header:User-Agent:1': 0.23; 'dll': 0.24; 'module,': 0.24; 'package.': 0.24; 'possibly': 0.26; 'least': 0.26; 'header:X-Complaints-To:1': 0.27; 'function': 0.29; 'tim': 0.29; "i'm": 0.30; 'url:mailman': 0.30; 'code': 0.31; 'ctypes': 0.31; 'didnt': 0.31; 'linux.': 0.31; 'probably': 0.32; 'run': 0.32; 'url:python': 0.33; "can't": 0.35; 'test': 0.35; 'but': 0.35; 'there': 0.35; 'url:listinfo': 0.36; 'charset:us-ascii': 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'process,': 0.38; 'window': 0.38; 'to:addr:python-list': 0.38; 'that,': 0.38; 'does': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'mailing': 0.39; 'received:org': 0.40; 'url:mail': 0.40; 'how': 0.40; 'even': 0.60; 'most': 0.60; 'monitoring': 0.61; 'url:5': 0.61; "you'll": 0.62; 'email addr:gmail.com': 0.63; 'kind': 0.63; 'within': 0.65; 'here': 0.66; 'between': 0.67; 'url:me': 0.69; 'keystrokes': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Dave Angel <davea@davea.name>
Subject Re: Monitor key presses in Python?
Date Sat, 14 Sep 2013 22:03:56 +0000 (UTC)
References <57051d11-abd9-4621-9618-1574cd37545c@googlegroups.com> <l0n9n1$kpu$1@reader1.panix.com> <5c59400c-45ca-40f0-846c-05bef3eb0233@googlegroups.com> <roy-B7F251.14034214092013@news.panix.com> <bf7b8085-4994-4006-ad66-3ee4d291114e@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=US-ASCII
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host 174.32.174.29
User-Agent XPN/1.2.6 (Street Spirit ; Linux)
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.381.1379196255.5461.python-list@python.org> (permalink)
Lines 41
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1379196255 news.xs4all.nl 15925 [2001:888:2000:d::a6]:34479
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:54179

Show key headers only | View raw


On 14/9/2013 14:10, eamonnrea@gmail.com wrote:

> I didnt wanna say that, in case people threw a fit and stuff.
>
> So yeah, how would I monitor the key presses?

There's a huge difference between monitoring key presses within your own
process, and intercepting them system-wide.  if you need to see
keystrokes even when your window does not have the focus, then you need
to call some system DLL function, (some kind of "system hook", which
you can probably do using the platform module, or the ctypes module, or
some module that I wouldn't have on Linux.  This type of code is not the
least bit portable, which just means I can't test things here to try to
help.

Note also that if you get one of the ActivePython implementations from
ActiveState, you'll get PyWin32, which may well have a function just for
the purpose.  See:

http://docs.activestate.com/activepython/2.5/pywin32/PyWin32.HTML

I'm sure it can be separately downloaded, but when I used to run
Windows, I just got the whole package.  The ActivePython also had the
best offline documentation I was able to find at the time.

See also Tim Golden's win32 web page:

http://timgolden.me.uk/python/win32_how_do_i.html

There is a separate win32 mailing list;  see:

https://mail.python.org/mailman/listinfo/python-win32

Possibly the most frequent poster there is Tim Golden, so search his
site first.


-- 
DaveA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Monitor key presses in Python? eamonnrea@gmail.com - 2013-09-09 10:39 -0700
  Re: Monitor key presses in Python? Dave Angel <davea@davea.name> - 2013-09-09 18:19 +0000
  Re: Monitor key presses in Python? John Gordon <gordon@panix.com> - 2013-09-09 18:40 +0000
  Re: Monitor key presses in Python? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-09-09 23:37 +0000
  Re: Monitor key presses in Python? Nobody <nobody@nowhere.com> - 2013-09-10 02:33 +0100
  Re: Monitor key presses in Python? Michael Torrie <torriem@gmail.com> - 2013-09-09 20:43 -0600
  Re: Monitor key presses in Python? Grant Edwards <invalid@invalid.invalid> - 2013-09-10 14:18 +0000
    Re: Monitor key presses in Python? eamonnrea@gmail.com - 2013-09-14 10:44 -0700
      Re: Monitor key presses in Python? Roy Smith <roy@panix.com> - 2013-09-14 14:03 -0400
        Re: Monitor key presses in Python? eamonnrea@gmail.com - 2013-09-14 11:10 -0700
          Re: Monitor key presses in Python? Dave Angel <davea@davea.name> - 2013-09-14 22:03 +0000
      Re: Monitor key presses in Python? Paul Rubin <no.email@nospam.invalid> - 2013-09-14 11:42 -0700

csiph-web