Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Need help with looping over subroutine and compiling 48x48 icon and 16x16 tray perltray pdk

by diamondsandperls (Beadle)
on Jul 04, 2012 at 03:30 UTC ( [id://979811]=perlquestion: print w/replies, xml ) Need Help??

diamondsandperls has asked for the wisdom of the Perl Monks concerning the following question:

With my current code below I am attempting to do the following.
I am stuck and really needing the code to loop back over subroutine ip

1. Get compiled perltray icon code to compile to loop every 30 minutes
2. have 48x48 desktop icon and same 16x16 systray icon compiled once I get the loop working
3. have log file append new entries to the top shifting older entries to the bottom of log file

Thanks to all who reply

#!perl use strict; use warnings; use LWP::UserAgent; use Time::Piece; use Win32; use PerlTray; &ip; sub ip { my $t = localtime; my $username = Win32::LoginName; my $output_file = "C:/Users/$username/Dropbox/My_IP.txt"; my $ua = new LWP::UserAgent; $ua->agent('Mozilla/5.0'); my $response = $ua->get("http://automation.whatismyip.com/n09230945.as +p"); my $content = $response->content; open(my $output_fh, '>>', $output_file) or die "You may not have dropbox installed failed to open - $outpu +t_file $!"; print {$output_fh} "Your IP address is $content at $t\n"; close $output_fh; } sub Timer { sleep 10; \&ip } sub PopupMenu { return [ ['Refresh', \&ip], ['Exit', 'exit'] ]; } sub ToolTip {"MyIP_2_Dropbox"}
  • Comment on Need help with looping over subroutine and compiling 48x48 icon and 16x16 tray perltray pdk
  • Download Code

Replies are listed 'Best First'.
Re: Need help with looping over subroutine and compiling 48x48 icon and 16x16 tray perltray pdk
by zentara (Archbishop) on Jul 04, 2012 at 11:17 UTC
    to loop every 30 minutes

    Well I can't run your code because I'm on Linux, but looking at the PerlTray online docs, it says

    SetTimer(ELAPSE, CALLBACK) The SetTimer() function starts an asynchronous timer, which invokes th +e CALLBACK every time ELAPSE milliseconds have expired. Calling SetTi +mer() with ELAPSE set to 0 stops the timer for this specific CALLBACK +. If CALLBACK is omitted, it will default to Timer(). The ELAPSE parameter can also be specified in "hh:mm:ss.xxxx" format. +Examples are: :15 => 15 seconds 1:30 => 1 hour, 30 minutes 4:30:15 => 4 hours, 30 minutes, 15 seconds 2.500 => 2 seconds, 500 milliseconds
    So you need a line of code something like:
    SetTimer ( 1800000, \&ip ) # 1800 seconds x 1000 for millisecs #or possibly SetTimer ( 0:30, \&ip);

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
Re: Need help with looping over subroutine and compiling 48x48 icon and 16x16 tray perltray pdk
by Anonymous Monk on Jul 04, 2012 at 06:22 UTC

    I am stuck and really needing the code to loop back over subroutine ip

    What does that mean?

Re: Need help with looping over subroutine and compiling 48x48 icon and 16x16 tray perltray pdk
by cavac (Parson) on Jul 04, 2012 at 15:00 UTC

    have 48x48 desktop icon and same 16x16 systray icon compiled once I get the loop working

    Do you mean something like PerlTray->Files->Add Icon Source (or similar, curently surfing on Linux)?

    Sorry for any bad spelling, broken formatting and missing code examples. During a slight disagreement with my bicycle (which i lost), i broke my left forearm near the elbow. I'm doing the best i can here...
      On the icon I was having trouble display a full desktop and perltray all you have to do with perltray is compile with a 48x48 or 32x32 icon with a 16x16 and the icon will display fine on desktop and systray i just used a matching icon for both which makes the most sense. Thanks for the SetTimer recommendation this got me over that hurdle this project is done now on to the next one.

      happy coding!!

      :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://979811]
Approved by Eliya
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (12)
As of 2024-04-23 14:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found