Bill Janssen wrote:
We discussed this a bit last year, but with no resolution that I
remember. I've got a situation where a Python program is preventing
logout/shutdown. It's a script that just runs in an endless loop
watching what app I'm working with; when it sees one it knows
(Preview,
MS Word, Safari, etc.) it uses appscript to ask the app what document
I'm looking at. It then squirrels that document away in a journal so
that I've got a record of what I've been working with.
The basic control loop is something like this:
while True:
... see what's running, and possibly what document ...
time.sleep(1.0)
See:
http://mail.python.org/pipermail/pythonmac-sig/2008-December/020792.html
Two options described there: replace your 'while True' loop with a
Carbon/Cocoa event loop, allowing a GUI-based process to handle
incoming events, or prevent the OS from automatically upgrading your
python process to a GUI process (which it only does if it knows the
executable is located in an application bundle, e.g. Python.app/
Contents/MacOS/python).
Regards,
has
--
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.net
_______________________________________________
Pythonmac-SIG maillist - Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig