1

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'
  • Could we see the exact ssh and osascript command as you enter it into the command line. – Tony Williams Feb 5 '14 at 2:13
  • I have just added it in my question – qbait Feb 5 '14 at 2:27
1

I solved my problem, global variable was reset, now I store variable in file, here is the code:

set thePath to (get path to scripts folder from user domain as text) & “myTempFile.scpt"

script theData
    property IsPaused : missing value
end script

try
    set theData to load script file thePath
on error
    set IsPaused of theData to false
end try

tell application "iPhoto"
    if slideshow running then
        if isPaused of theData then
            resume slideshow
        set isPaused of theData to false
        else
            pause slideshow
            set isPaused of theData to true
        end if
    else
        start slideshow
    set isPaused of theData to false
    end if
end tell

store script theData in file thePath replacing yes
return IsPaused of theData

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .