I need toggle playPause for iPhoto, so I wrote this script
global isPaused
try
get isPaused
on error
set isPaused to false
end try
tell application "iPhoto"
if slideshow running then
if isPaused then
resume slideshow
else
pause slideshow
set isPaused to true
end if
else
start slideshow
end if
end tell
I sent this command via ssh (with osascript -e '%s') and resume feature doesn't work (start and pause work correctly).
so I wrote helper script
try
get toggle
on error
set toggle to false
end try
tell application "iPhoto"
if toggle then
start slideshow
else
set toggle to true
end if
end tell
it works correctly when I run it via AppleScript editor, but not if I run this code via ssh.
[edited]
I run scripts exactly this way:
osascript -e 'try
get toggle
on error
set toggle to false
end try
tell application "iPhoto"
if toggle then
start slideshow
else
set toggle to true
end if
end tell'
Best Answer
I solved my problem, global variable was reset, now I store variable in file, here is the code: