Tim, sorry, I missed this post before. I don't read the list too often (through an RSS reader, and I've been neglecting most of what's in there lately!).
Here's some code that will do what your AppleScript does: #!/usr/bin/perl use warnings; use strict; use Mac::Glue ':all'; my $sysevt = new Mac::Glue 'System Events'; my $app_name = $sysevt->prop( name => item => 1, application_process => whose(frontmost => equals => 1) )->get; my $app_glue = new Mac::Glue $app_name; my $window_name = $app_glue->prop(name => window => 1)->get; As you can tell, that's basically what you were already doing. There's actually a script I wrote called "happening" that was covered a bit in an O'Reilly Mac OS X Hacks book. Unfortunately, the Mac::Glue version will only work for getting the frontmost window for applications where you've already created a glue for it (with `gluemac` on the command line). The script runs in the background and sets my iChat status to my app and its frontmost window, if I want it to. Does lots of other similar things too, like looking at what I am listening to or watching. http://dev.macperl.org/files/scripts/happening Cheers, --Chris In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Tim Bunce) wrote: > On Thu, Nov 16, 2006 at 10:32:25PM +0000, Tim Bunce wrote: > > Hello. > > > > I'm hoping someone can point me in the right direction to get me started... > > > > I want to write a perl script that can gather the following simple info: > > > > Has the screen blanker blanked the screen? > > What's the front-most application? > > What's its window title? > > > > I've been using a mac for a couple of years now but never needed to do > > any mac-specific development. Mac-Glue and Mac-Carbon distributions > > look wonderful (thanks Chris!) but somewhat daunting to the OSX novice. > > > > I'm sure it's trivial. Hopefully someone can show me just how trivial ;-) > > > > Tim. > > > > p.s. I'm planning to implement a little script that'll log the info at > > regular intervals and, from time to time, dump it into a SQLite db. > > Another script will extract and summarize the info - including > > determining what 'project' was being worked on - and report summary info > > aggregated in various ways. > > FYI here's what I've put together so far from fragments of info gathered > from AppleScript docs and web: > > set win_name to "" > tell application "System Events" > set app_name to name of the first process whose frontmost is true > -- is "ScreenSaverEngine" if screen saver is running > -- is "SecurityAgent" if prompting for a password to unlock > end tell > > try > tell application app_name > set win_count to count of windows > if (win_count is greater than 0) then > set win_name to name of window 1 > end if > end tell > end try > > Tim. -- Chris Nandor [EMAIL PROTECTED] http://pudge.net/ Open Source Technology Group [EMAIL PROTECTED] http://ostg.com/