#!perl use strict; use Time::Local; use Warnings; use Win32; use Win32::OLE; my $start = shift || -1; # Use -1 for immediate start. my $playlist = shift; my $fadeup = 1; if ( not defined $playlist ) { if ( $start !~ m/^\s*-?\d+\s*$/ ) { $playlist = $start; $start = -1; $fadeup = 0; } else { $playlist = "Party Shuffle"; } } if ( $start != "-1" ) # Determine when to proceed, then wait until the +n. { my ( $sH, $sM ) = $start =~ m/^\s*(\d\d?)(\d\d)\s*$/; die "$0 '$start'\nTime should be in military time with no symbols, + e.g.:\n6:30 am = 630, 10:15 pm = 2215\n" unless defined( $sH ) and defined( $sM ); my $t = time(); my @p = localtime($t); # ($sec,$min,$hour,$mday,$mon,$year,$wday,$ +yday,$isdst) my ( $tM, $tH ) = ( $p[1], $p[2] ); my $s = 0; my $today = 0; if ( $sH < $tH || ( $sH == $tH && $sM <= $tM ) ) { my @sP = localtime($t + 86400); $s = timelocal( 0, $sM, $sH, $sP[3], $sP[4], $sP[5] ); } elsif ( $sH > $tH || ( $sH == $tH && $sM > $tM ) ) { $s = timelocal( 0, $sM, $sH, $p[3], $p[4], $p[5] ); $today = 1; } else { die "ASSERT( '$sH', '$tH' )" } print "Set for ", ( $today ? "today, " : "tomorrow, " ), scalar( l +ocaltime( $s ) ), "\n"; sleep( ( $s - $t ) - 59 ) if ( ( $s - $t ) > 59 ); print "Ready? One Minute to Go!\n"; sleep( 15 ) while time() < $s; } else { # no delay? then no fade either. $fadeup = 0; } print "Starting iTunes . . .\n"; my $G_iTA = new Win32::OLE("iTunes.Application"); $G_iTA->{ "BrowserWindow" }->{ "MiniPlayer" } = 1; $G_iTA->{ "SoundVolume" } = $fadeup ? 10 : 90; print "Playing...\n"; $G_iTA->{ "LibrarySource" }->{ "Playlists" }->ItemByName( $playlist )- +>PlayFirstTrack(); if ( $fadeup ) { print "Fading up...\n"; for my $v ( 11 .. 90 ) { sleep( 1 ); $G_iTA->{ "SoundVolume" } = $v; } print "Have a nice day!\n\n"; } else { print "iTunes load complete.\n\n"; }

In reply to Win32 iTunes Alarm Clock (Ole!) by Adam

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.