Those are added by Script Debugger, but I can set Script Debugger to remove all of them except the first, as you suggest. Probably won't have any effect on this issue...Ronald P. Regensburg wrote: ↑Mon Aug 30, 2021 7:10 pm In the info.plist file is a long list of privacy items.
...
I suppose only the first one is needed.
Copying pictures
Moderators: Cat_7, Ronald P. Regensburg, ClockWise
-
- Forum All-Star
- Posts: 1726
- Joined: Tue Oct 14, 2008 12:12 am
Re: Copying pictures
Re: Copying pictures
I see. Sorry for my wrong statement and thanks for correction.Ronald P. Regensburg wrote: ↑Mon Aug 30, 2021 7:01 pmAll apps in Full Disk Access also show up in Files and Folders, but many apps in Files and Folders, the ones that have access to specific folders and volumes, are not in Full Disk Access. I suppose they are added when the user allows access when asked while running the app.
Re: Copying pictures
Another thing:
The developer of Deark has added an option for us: "-opt pict:decodeqt".
See https://github.com/jsummers/deark/issue ... -908604441.
Changing the line
to
and the line
to
should make our script more efficient for PICT files with multiple containers.
The developer of Deark has added an option for us: "-opt pict:decodeqt".
See https://github.com/jsummers/deark/issue ... -908604441.
Changing the line
Code: Select all
set dearkResponse to paragraph -1 of (do shell script dearkPath & " -l -maxfiles 1 ~/Documents/clipboardConvFile." & sourceExtension)
Code: Select all
set dearkResponse to paragraph -1 of (do shell script dearkPath & " -l -maxfiles 1 -opt pict:decodeqt ~/Documents/clipboardConvFile." & sourceExtension)
and the line
Code: Select all
do shell script dearkPath & " ~/Documents/clipboardConvFile." & sourceExtension & " -t ~/Documents/clipboardConvFile." & destExtension
Code: Select all
do shell script dearkPath & " -opt pict:decodeqt ~/Documents/clipboardConvFile." & sourceExtension & " -t ~/Documents/clipboardConvFile." & destExtension
should make our script more efficient for PICT files with multiple containers.
-
- Forum All-Star
- Posts: 1726
- Joined: Tue Oct 14, 2008 12:12 am
Re: Copying pictures
I'm traveling this week and may not be able to work more on this for a few days, but I've done this:
I downloaded the latest deark code and built the executable; and I made the changes that mabam suggested for the code (for the dialog boxes, I simply told the application to "activate" before displaying the dialog; that seems to work in my other applications).
Unfortunately, when I run the code I get this error message:
I downloaded the latest deark code and built the executable; and I made the changes that mabam suggested for the code (for the dialog boxes, I simply told the application to "activate" before displaying the dialog; that seems to work in my other applications).
Unfortunately, when I run the code I get this error message:
I don't see how the extension "format" got in there so I don't know how to fix it. Mabam, am I doing something wrong (as is likely)? Here's my code:Deark error:
Error: Can't read /Users/edward/Documents/clipboardConvFile.format: No such file or directory
Code: Select all
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
use framework "Foundation" -- needed to check keyboard state
use framework "AppKit" -- needed to check keyboard state
-- to show image preview, either change next to true or
-- add "show" to the name of the app (as in "ConvertClipboardPICT Show")
property showImage : true
on run {}
set myName to name of me as string
if item 1 of item 1 of (clipboard info) as string is not "picture" then
activate
display dialog "No PICT data on the clipboard." buttons {"OK"} giving up after 5 with title myName
error number -128
end if
-- next two lines get permissions settled at the start
tell application "Finder" to count windows
tell application "System Events" to count windows
-- next try block gets the permissions dialog before anything else
try
do shell script "ls" & space & "~/Documents/clipboardConvFile.*"
end try
if myName contains "Show" then set showImage to true
if (myName contains "Key" or myName contains "Option") then
if (((current application's NSEvent's modifierFlags()) div 524288) mod 2) > 0 then -- 524288 = current application's NSAlternateKeyMask
set showImage to true
end if
end if
set myPath to POSIX path of (path to me)
set helpers to myPath & "Contents/Resources/Helpers/"
set dearkPath to quoted form of (helpers & "deark")
set impbcopyPath to quoted form of (helpers & "impbcopy")
set pictHeader to «data PICT0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000»
try
set clipFile to POSIX path of (path to documents folder as text) & "clipboardConvFile.pct"
set theOpenedFile to open for access clipFile with write permission
set eof of theOpenedFile to 0 -- Clear file content
write pictHeader to theOpenedFile starting at eof
write (the clipboard as picture) to theOpenedFile
close access theOpenedFile
on error err
try
close access theOpenedFile
end try
activate
display dialog err
error number -128
end try
try
set sourceExtension to "pct"
repeat
set dearkResponse to paragraph -1 of (do shell script dearkPath & " -l -maxfiles 1 -opt pict:decodeqt ~/Documents/clipboardConvFile." & sourceExtension)
if dearkResponse is "No files found to extract!" then
exit repeat
else
set destExtension to word -1 of dearkResponse
end if
do shell script dearkPath & " ~/Documents/clipboardConvFile." & sourceExtension & " -t ~/Documents/clipboardConvFile." & destExtension
set sourceExtension to destExtension
end repeat
on error err
if err contains "permission error" then
activate
display dialog "The converter program was unable to convert the image." buttons ("OK") giving up after 5 with title myName
try
do shell script "rm -f" & space & "~/Documents/clipboardConvFile.*"
end try
error number -128
else
activate
display dialog "Deark error:" & return & return & err
end if
end try
try
if destExtension is in {"png", "tif", "jpg", "gif", "bmp"} then
if destExtension is "png" then
set imgFormat to "PNGf"
else if destExtension is "tif" then
set imgFormat to "TIFF"
else if destExtension is "jpg" then
set imgFormat to "JPEG"
else if destExtension is "gif" then
set imgFormat to "GIFf"
else if destExtension is "bmp" then
set imgFormat to "BMPf"
end if
set the clipboard to {picture:(read (POSIX path of (path to documents folder as text) & "clipboardConvFile." & destExtension) as imgFormat)}
else
do shell script impbcopyPath & space & "~/Documents/clipboardConvFile." & destExtension -- Copies the image to the clipboard as TIFF.
set the clipboard to (the clipboard as «class PNGf») -- Copies a compressed PNG version of the image to the clipboard.
end if
on error err
set trashDialog to ""
try
set trashDialog to return & return & "Move the converted image file out of the trash if needed."
tell application "Finder" to move file ((path to home folder as text) & "clipboardConvFile." & destExtension) as text to trash
on error
set trashDialog to ""
end try
activate
display dialog "Could not copy the converted image to the clipboard." & trashDialog & return & return & err buttons {"OK"} giving up after 5 with title myName
try
do shell script "rm -f" & space & "~/Documents/clipboardConvFile.*"
end try
end try
if showImage is true then
set tempFile to "~/Documents/clipboardConvFile." & destExtension
do shell script "/usr/bin/qlmanage -p" & space & tempFile & space & "> /dev/null 2>&1 &"
set counter to 0
repeat until counter is 5
delay 0.25
set counter to counter + 0.25
tell application "System Events"
if (name of every process) does not contain "qlmanage" then
exit repeat
end if
end tell
end repeat
if counter is 5 then
tell application "qlmanage" to quit
end if
end if
try
do shell script "rm -f" & space & "~/Documents/clipboardConvFile.*"
end try
end run
Re: Copying pictures
I’m not in front of my computer right now so I haven’t tested, but you’re missing “-opt pict:decodeqt” in the second Deark line.
-
- Forum All-Star
- Posts: 1726
- Joined: Tue Oct 14, 2008 12:12 am
Re: Copying pictures
I don't know how I could have missed that, since I thought I had merely Selected All and copied and pasted, but of course you're right. It works perfectly now, I think, and I've notarized and uploaded read-only and editable versions. Same link:
http://www.columbia.edu/~em36/ConvertClipboardPICT.zip
EDIT: The zip that I uploaded a few minutes showed the wrong title in dialog boxes; now fixed.
http://www.columbia.edu/~em36/ConvertClipboardPICT.zip
EDIT: The zip that I uploaded a few minutes showed the wrong title in dialog boxes; now fixed.
Re: Copying pictures
Thanks for uploading the new version. Conversion runs fine here. The option key or changing the app’s name still doesn’t do anything for me, though.
With the new Deark option it would be better to remove the repeat loop. I realised that the way it is now was a quick “fix” by me. It works but doesn’t really make sense logically.
I’ll be gone for a few days now but should be able to have a look into it somewhere next week.
With the new Deark option it would be better to remove the repeat loop. I realised that the way it is now was a quick “fix” by me. It works but doesn’t really make sense logically.
I’ll be gone for a few days now but should be able to have a look into it somewhere next week.
-
- Forum All-Star
- Posts: 1726
- Joined: Tue Oct 14, 2008 12:12 am
Re: Copying pictures
Again, thank you. I won't try to sort out the problems with the name of the app until you look at the code again.
Re: Copying pictures
mabam wrote: ↑Thu Sep 02, 2021 10:50 pm With the new Deark option it would be better to remove the repeat loop. I realised that the way it is now was a quick “fix” by me. It works but doesn’t really make sense logically.
I’ll be gone for a few days now but should be able to have a look into it somewhere next week.
Here we go. Substitute
Code: Select all
set sourceExtension to "pct"
repeat
set dearkResponse to paragraph -1 of (do shell script dearkPath & " -l -maxfiles 1 -opt pict:decodeqt ~/Documents/clipboardConvFile." & sourceExtension)
if dearkResponse is "No files found to extract!" then
exit repeat
else
set destExtension to word -1 of dearkResponse
end if
do shell script dearkPath & " ~/Documents/clipboardConvFile." & sourceExtension & " -t ~/Documents/clipboardConvFile." & destExtension
set sourceExtension to destExtension
end repeat
Code: Select all
set destExtension to word -1 of (do shell script dearkPath & " -l -maxfiles 1 -opt pict:decodeqt ~/Documents/clipboardConvFile.pct")
do shell script dearkPath & " ~/Documents/clipboardConvFile.pct -t ~/Documents/clipboardConvFile." & destExtension
-
- Forum All-Star
- Posts: 1726
- Joined: Tue Oct 14, 2008 12:12 am
Re: Copying pictures
Hello again!
Unfortunately, the new code produces an unreadable JPEG file when run with the ExamplePicture.pct that you provided. Am I doing something wrong?
Also, I figured out why changing the name of the app to add "Show" didn't work. The first line of the on run block should read:
And because it's likely that I'm making some foolish error in working with your code, here's the code I've got that seems to work correctly - using your earlier repeat block, not the new code in your recent message:
Unfortunately, the new code produces an unreadable JPEG file when run with the ExamplePicture.pct that you provided. Am I doing something wrong?
Also, I figured out why changing the name of the app to add "Show" didn't work. The first line of the on run block should read:
Code: Select all
tell application "System Events" to set myName to get name of (path to me)
Code: Select all
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
use framework "Foundation" -- needed for option-key test
use framework "AppKit" -- needed for option-key test
-- based entirely on code and solutions by mabam
-- https://www.emaculation.com/forum/viewtopic.php?f=20&t=11314
-- to show image preview, either change next to true or
-- add "show" to the name of the app (as in "ConvertClipboardPICT Show")
property showImage : false
on run {}
tell application "System Events" to set myName to get name of (path to me)
if item 1 of item 1 of (clipboard info) as string is not "picture" then
activate
display dialog "No PICT data on the clipboard." buttons {"OK"} giving up after 5 with title myName
error number -128
end if
-- next two lines get permissions settled at the start
tell application "Finder" to count windows
tell application "System Events" to count windows
-- next try block gets the permissions dialog before anything else
try
do shell script "ls" & space & "~/Documents/clipboardConvFile.*"
end try
if myName contains "Show" then set showImage to true
if (myName contains "Key" or myName contains "Option") then
if (((current application's NSEvent's modifierFlags()) div 524288) mod 2) > 0 then -- 524288 = current application's NSAlternateKeyMask
set showImage to true
end if
end if
set myPath to POSIX path of (path to me)
set helpers to myPath & "Contents/Resources/Helpers/"
set dearkPath to quoted form of (helpers & "deark")
set impbcopyPath to quoted form of (helpers & "impbcopy")
set pictHeader to «data PICT0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000»
try
set clipFile to POSIX path of (path to documents folder as text) & "clipboardConvFile.pct"
set theOpenedFile to open for access clipFile with write permission
set eof of theOpenedFile to 0 -- Clear file content
write pictHeader to theOpenedFile starting at eof
write (the clipboard as picture) to theOpenedFile
close access theOpenedFile
on error err
try
close access theOpenedFile
end try
activate
display dialog err
error number -128
end try
try
set sourceExtension to "pct"
repeat
set dearkResponse to paragraph -1 of (do shell script dearkPath & " -l -maxfiles 1 -opt pict:decodeqt ~/Documents/clipboardConvFile." & sourceExtension)
if dearkResponse is "No files found to extract!" then
exit repeat
else
set destExtension to word -1 of dearkResponse
end if
do shell script dearkPath & " -opt pict:decodeqt ~/Documents/clipboardConvFile." & sourceExtension & " -t ~/Documents/clipboardConvFile." & destExtension
set sourceExtension to destExtension
end repeat
on error err
if err contains "permission error" then
activate
display dialog "The converter program was unable to convert the image." buttons ("OK") giving up after 5 with title myName
try
do shell script "rm -f" & space & "~/Documents/clipboardConvFile.*"
end try
error number -128
else
activate
display dialog "Deark error:" & return & return & err
end if
end try
try
if destExtension is in {"png", "tif", "jpg", "gif", "bmp"} then
if destExtension is "png" then
set imgFormat to "PNGf"
else if destExtension is "tif" then
set imgFormat to "TIFF"
else if destExtension is "jpg" then
set imgFormat to "JPEG"
else if destExtension is "gif" then
set imgFormat to "GIFf"
else if destExtension is "bmp" then
set imgFormat to "BMPf"
end if
set the clipboard to {picture:(read (POSIX path of (path to documents folder as text) & "clipboardConvFile." & destExtension) as imgFormat)}
else
do shell script impbcopyPath & space & "~/Documents/clipboardConvFile." & destExtension -- Copies the image to the clipboard as TIFF.
set the clipboard to (the clipboard as «class PNGf») -- Copies a compressed PNG version of the image to the clipboard.
end if
on error err
set trashDialog to ""
try
set trashDialog to return & return & "Move the converted image file out of the trash if needed."
tell application "Finder" to move file ((path to home folder as text) & "clipboardConvFile." & destExtension) as text to trash
on error
set trashDialog to ""
end try
activate
display dialog "Could not copy the converted image to the clipboard." & trashDialog & return & return & err buttons {"OK"} giving up after 5 with title myName
try
do shell script "rm -f" & space & "~/Documents/clipboardConvFile.*"
end try
end try
if showImage is true then
set tempFile to "~/Documents/clipboardConvFile." & destExtension
activate
do shell script "/usr/bin/qlmanage -p" & space & tempFile & space & "> /dev/null 2>&1 &"
set counter to 0
repeat until counter is 5
delay 0.25
set counter to counter + 0.25
tell application "System Events"
if (name of every process) does not contain "qlmanage" then
exit repeat
end if
end tell
end repeat
if counter is 5 then
tell application "qlmanage" to quit
end if
end if
try
do shell script "rm -f" & space & "~/Documents/clipboardConvFile.*"
end try
end run
-
- Forum All-Star
- Posts: 1726
- Joined: Tue Oct 14, 2008 12:12 am
Re: Copying pictures
Now that we have a registration code for GIFConverter (see the MiniVMac forum), it's possible to write a script that runs in SheepShaver and saves the image in the clipboard to a PNG file on the SheepShaver desktop. Here's one that seems to work. I can't figure out the GIFConverter scripting routine that would let me save the file directly to the Unix folder without an obscure prompt, so saving the SheepShaver desktop seemed most reliable. It should be easy to extend the script to move the PNG file to the Unix folder if anyone wants to do that.
Code: Select all
on run {}
set clipInfo to (clipboard info) as string
if clipInfo contains "picture" then
my convertFile()
else
display dialog "No image in clipboard." buttons {"OK"} giving up after 2
end if
error number -128
end run
on convertFile()
set deskDir to path to desktop folder as string
set saveImage to "FromClipboard.png"
set saveFile to deskDir & saveImage
tell application "Finder"
if exists file saveFile then
activate
display dialog saveImage & " already exists on the desktop." & return & return & "Delete and replace?" buttons {"Yes", "No"} default button 2
if button returned of result is "Yes" then
delete file saveFile
else
error number -128
end if
end if
end tell
set appRunning to false
if (list processes) contains "GIFConverter" then
set appRunning to true
end if
tell application "GIFConverter"
activate
make at beginning new graphic document
tell image 1 of graphic document 1
paste
end tell
try
close palette 1
end try
save graphic document 1 in file saveFile as PNG
try
close graphic document 1 saving no
end try
if appRunning is false then
try
quit application "GIFConverter"
end try
end if
end tell
end convertFile
Re: Copying pictures
emendelson wrote: ↑Sun Sep 12, 2021 12:11 am Unfortunately, the new code produces an unreadable JPEG file when run with the ExamplePicture.pct that you provided. Am I doing something wrong?
My bad. This time I missed the “-opt pict:decodeqt” part. Please try
Code: Select all
set destExtension to word -1 of (do shell script dearkPath & " -l -maxfiles 1 -opt pict:decodeqt ~/Documents/clipboardConvFile.pct")
do shell script dearkPath & " -maxfiles 1 -opt pict:decodeqt ~/Documents/clipboardConvFile.pct -t ~/Documents/clipboardConvFile." & destExtension
-
- Forum All-Star
- Posts: 1726
- Joined: Tue Oct 14, 2008 12:12 am
Re: Copying pictures
That fixed it, thank you!
I've uploaded corrected editable and run-only versions to:
http://www.columbia.edu/~em36/ConvertClipboardPICT.zip
Well done, and thank you for sorting this all out!
I've also put together an AppleScript that runs in SheepShaver and uses the old GIFConverter utility to convert the PICT in the clipboard to a PNG file on either the SheepShaver desktop or the Unix folder. We now have a registration code for GIFConverter (the author has not been heard from since 2011, so I hope this is OK) and that makes the script possible. Will post the script after some cleanup.
I've uploaded corrected editable and run-only versions to:
http://www.columbia.edu/~em36/ConvertClipboardPICT.zip
Well done, and thank you for sorting this all out!
I've also put together an AppleScript that runs in SheepShaver and uses the old GIFConverter utility to convert the PICT in the clipboard to a PNG file on either the SheepShaver desktop or the Unix folder. We now have a registration code for GIFConverter (the author has not been heard from since 2011, so I hope this is OK) and that makes the script possible. Will post the script after some cleanup.
Re: Copying pictures
Just tested it and it all works as advertised now.emendelson wrote: ↑Mon Sep 13, 2021 2:30 am I've uploaded corrected editable and run-only versions to:
http://www.columbia.edu/~em36/ConvertClipboardPICT.zip
Well done, and thank you for sorting this all out!
I’ve sorted this out partly, the other part was all your effort. So the credit is to you as well!
I won’t test this as I’m not using your app. But it sounds like a nice little enhancement.I've also put together an AppleScript that runs in SheepShaver and uses the old GIFConverter utility to convert the PICT in the clipboard to a PNG file on either the SheepShaver desktop or the Unix folder. We now have a registration code for GIFConverter (the author has not been heard from since 2011, so I hope this is OK) and that makes the script possible. Will post the script after some cleanup.
- Ronald P. Regensburg
- Expert User
- Posts: 7835
- Joined: Thu Feb 09, 2006 10:24 pm
- Location: Amsterdam, Netherlands
Re: Copying pictures
I would like to post your run-only version together with a readme in the BasiliskII and SheepShaver for macOS downloads topics here. Is that OK with you?
-
- Forum All-Star
- Posts: 1726
- Joined: Tue Oct 14, 2008 12:12 am
Re: Copying pictures
Of course yes!