I have written an appleScript under OS X 10.2.6 which open the app GraphicConverter an within the GraphicConverter a browser window which shows the contents a special folder. This special folder is the folder where the picture are loaded into from my digital camera. The downloading is done with the OS X app “Digitale Kamera” (I don’t know how it is called in english, perhaps “Digital camera” or whatever)(.
This script works fine if invoked from the FInder or from GraphicConverters script menu. But it does not work if invoked from “Digiitale Kamera”. I invoking there with these menu on the right side which is called “Actions to do after downloading” or similar.
Does anybody know what the problem is and could please give me a hint?
The script itself looks like this (no error handling up to now and not very flexible…)
set KameraFolder to “” as string
tell app GrahicConverter
activate
browser with KameraFolder
end tell
I don’t know the related app, but maybe the “Actions to do after downloading” menu can’t run compiled scripts…
You could install Apple’s Script Menu, which is system-wide and you can choose its items from any application.
Go to /Applications/AppleScript
Drag & Drop the “Script Menu.menu” to your menu bar, next to the clock.
Now, you will see there any script found into your “/Library/Scripts” folder or “~/Library/Scripts”. If you place your script in any of these locations, you will see it in the script menu.
To remove it from the system-menu-bar, command-drag it out of the bar.
If the menu “Actions to do after downloading” runs automatically the items placed within, “after downloading”, maybe you can save your script as application, instead as compiled script, so it is launched and run properly…
I have forgotten to mention that it is an application. This AppleScript Application is executed (i see it starting in the dock) but nothing happens.
Do I need something like and ‘on run…end run’ handler or whatever?
Nope… All scripts have a run handler, even if you don’t define it, and it is executed when the app is launched…
Maybe you can create some test code, to see what’s going on. Eg:
display dialog "I'm launched OK!"
--> do whatever: set KameraFolder...
display dialog "KameraFolder OK!"
--> do whatever more
display dialog "whatever more OK!"
I added ‘Display dialog’ statements just like you mentioned. The point is, that my script goes through these additional statement for debbugging.
It’s now interesting to see, that the app I made from it executes correctly if invoked from the Finder, from the GraphicConverter, and from the scripts menu - but not from Image Capture. I see it starting in the dock and immediately it stops.
For information, here the complete script but now with commented out ‘Display dialog’ statements:
--display dialog "Skript erfolgreich gestartet."
set KameraOrdner to "Cocoa:Users:Shared:Bilder:PowerShot A70" as string
--display dialog "Pfad zum Bilderordner gesetzt."
tell application "GraphicConverter"
with timeout of (5 * 60) seconds
activate
end timeout
--display dialog "Anwendung GraphicConverter gestartet."
open KameraOrdner
--display dialog "Browserfenster geöffnet."
end tell
Curious…
I’d rewrite this code as follows, but I’m not sure that this is related to the launch-and-quit behaviour you get when launching the script from the capture app…
tell app "GraphicConverter" to open alias "Cocoa:Users:Shared:Bilder:PowerShot A70"
Since the script-app is launched (you see its icon bouncing in the Dock), I don’t know why it doesn’t executes properly… Have you tried keeping the script-app, eg, in the desktop, then placing an alias in the related menu into the capture app?
What is the regular use of that menu? What happens if you place an alias to GraphicConverter into such menu and you choose it?
Maybe the capture app passes an apple-event “open” to the script, instead of “run”/“activate”, or anything… :?:
Oh, yeah! I see… We are talking about “Image Capture”, the folk located within all our “Applications” folder (called in my system “Captura de Imagen”)…
Effectivelly, I’ve been testing it with my fuji a-303, and it invokes the “open” handler of the script, not the “run” (implicit) handler (that is “any code located outside of a handler”, in your sample, all the code)… So, when invoked from such menu, you can use this:
on open listOfAliasImages
tell app "GraphicConverter" to open alias "Cocoa:Users:Shared:Bilder:PowerShot A70"
end open
The variable-parameter listOfAliasImages is, as you see, a list of alias, typically images if you use the menu, and it is very useful if you wish processing the images individually. Eg:
on open listOfAliasImages --> eg, {alias "path:to:image.jpg", alias "path:to:image2.jpg}
repeat with i in listOfAliasImages
jpgToTiff(i)
end repeat
end open
to jpgToTiff(i)
set new_tiff to (i as string) & ".tiff"
--> create new file with extension tiff
set fRref to (open for access file new_tiff without write permission)
close access fRref
set new_tiff to new_tiff as alias
--> open jpg and save into the new tiff file
tell application "GraphicConverter"
open i without messages
save window 1 in new_tiff as TIFF
close window 1 saving no
end tell
end jpgToTiff