Skip to content

Instantly share code, notes, and snippets.

@hitode909
Created Aug 18, 2012
Embed
What would you like to do?
Perlで音楽
use strict;
use warnings;
use IO::Handle;
STDOUT->autoflush;
while(1) {
print "\a";
sleep 1;
}
use strict;
use warnings;
use Time::HiRes qw(usleep);
use IO::Handle;
STDOUT->autoflush;
while(1) {
print "\a";
usleep 250000;
}
use strict;
use warnings;
use Time::HiRes qw(usleep);
use IO::Handle;
sub setup_sound_effect {
my $script = <<APPLE_SCRIPT;
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.sound"
end tell
APPLE_SCRIPT
system "osascript", "-e", $script, "&";
}
sub set_sound_effect {
my ($i) = @_;
my $script = <<APPLE_SCRIPT;
tell application "System Events"
get properties
tell process "System Preferences"
set i to $i
click radio button 1 of tab group 1 of window 1
set selected of row i of table 1 of scroll area 1 of tab group 1 of window 1 to true
end tell
end tell
APPLE_SCRIPT
system "osascript", "-e", $script, "&";
}
STDOUT->autoflush;
setup_sound_effect();
my $sequence = [2..5];
my $i = 0;
while (++$i < 64) {
set_sound_effect($sequence->[$i % (scalar(@$sequence))]);
}
use strict;
use warnings;
use IO::Handle;
sub setup_sound_effect {
my $script = <<APPLE_SCRIPT;
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.sound"
end tell
APPLE_SCRIPT
system "osascript", "-e", $script, "&";
}
sub set_sound_effect {
my ($i) = @_;
my $script = <<APPLE_SCRIPT;
tell application "System Events"
get properties
tell process "System Preferences"
set i to $i
click radio button 1 of tab group 1 of window 1
set selected of row i of table 1 of scroll area 1 of tab group 1 of window 1 to true
end tell
end tell
APPLE_SCRIPT
system "osascript", "-e", $script, "&";
}
STDOUT->autoflush;
setup_sound_effect();
my $sequence = [2..5];
my $i = 0;
while (1) {
set_sound_effect(int(rand()*14));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment