Created
April 1, 2010 14:58
-
-
Save soh335/351896 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use DateTime; | |
my $zone = DateTime::TimeZone->new(name => 'local'); | |
my $start = DateTime->new( | |
time_zone => $zone, | |
year => 2010, | |
month => 4, | |
day => 1, | |
hour => 18, | |
minute => 55, | |
second => 0, | |
); | |
my $end = DateTime->new( | |
time_zone => $zone, | |
year => 2010, | |
month => 4, | |
day => 1, | |
hour => 20, | |
minute => 0, | |
second => 0, | |
); | |
my $str; | |
while (<DATA>) { | |
chomp; | |
s/^\s+//; | |
$str .= sprintf ' -e "%s"', $_; | |
} | |
my $command = sprintf '/usr/bin/osascript %s', $str; | |
my $start_flag = 0; | |
while ( 1 ) { | |
my $d = DateTime->now(time_zone => $zone); | |
if ($start_flag == 0 && $d > $start) { | |
my $c = ' -e "startRecord()"'; | |
system $command . $c; | |
print "startRecord\n"; | |
$start_flag = 1; | |
} elsif ( $start_flag == 1 && $d > $end ) { | |
my $c = ' -e "stopRecord()"'; | |
system $command . $c; | |
print "stopRecord\n"; | |
$start_flag = 2; | |
} | |
sleep 1; | |
} | |
__DATA__ | |
on startRecord() | |
action(\"1\") | |
end startRecord | |
on stopRecord() | |
action(\"2\") | |
end stopRecord | |
on action(src) | |
tell application \"iShowU HD\" | |
activate | |
end tell | |
tell application \"System Events\" | |
if UI elements enabled then | |
key down command | |
keystroke src using {command down, shift down} | |
key up command | |
end if | |
end tell | |
end action |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment