Make sure that 'Allow service to interact with desktop' is checked. Otherwise the service can't 'see' the desktop to get the handle.
<sig> Anthony George <[EMAIL PROTECTED]> Systems Engineer. Do your technical services need medical attention? We can help. EMSTS, LLC. 800-304-8269 231-720-1600 http://www.emsts.com 2516 Glade Muskegon,MI 49444</sig> -----Original Message----- From: Lee Hosty <[EMAIL PROTECTED]> To: perl-win32-gui-users@lists.sourceforge.net Date: Mon, 16 Dec 2002 14:22:13 +0000 Subject: [perl-win32-gui-users] calling Win32:GUI inside a service > > Hi, > > I hope this isn't seen as Off Topic, but I'm working on a pet project > at > the moment, whose basic task is to populate my windows signature file > with > the currently playing song from winamp. I do this already with random > quotes, which runs as a windows service (using Win32::Daemon) and > writes to > the text file that is my signature file. > > I have a working script to return the current song from winamp: > > sub GetCurrentSong { > my $winampHandle = Win32::GUI::FindWindow("Winamp v1.x", ""); > my $ret = ""; > > if ($winampHandle) { > > > print "$winampHandle"; > ## GRAB WINDOW TEXT ## > my $windowtext = Win32::GUI::Text( $winampHandle ); > # trim "number. " from beginning > $windowtext =~ s/^\d+\. //i; > # trim " [paused] from end > $windowtext =~ s/ \[paused\]$//i; > # trim " [stopped] from end > $windowtext =~ s/ \[stopped\]$//i; > # trim " - winamp" from end > $windowtext =~ s/ - winamp$//i; > $ret = "$windowtext\n"; > } > return $ret; > } > > This runs fine on the command line, but not when I run it as part of a > service through Win32::Daemon. It fails to find a handle for winamp, > even > though winamp is running. Is there something I'm not seeing that would > prevent a script running in the background as a service from finding a > current window handle in the foreground? > > Thanks In Advance > > > Lee Hosty -x- MP3: Otep - Possesion (Demo) > > > > > ------------------------------------------------------- > This sf.net email is sponsored by: > With Great Power, Comes Great Responsibility > Learn to use your power at OSDN's High Performance Computing Channel > http://hpc.devchannel.org/ > _______________________________________________ > Perl-Win32-GUI-Users mailing list > Perl-Win32-GUI-Users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users