This page is a wiki. Please login or create an account to begin editing.


14 posts / 0 new
Last post
galgot's picture
Offline
Joined: 2014 May 7
Screenshots with applescript ?

Hi,
Does someone know a way to make a screenshot with an applescript in Syst 7.5.3 ?
I found it's possible in OS X of course , with "System Events" calling a keystroke or an osascript calling "Screencapture". But there is no "System Events" that I know of in 7.5.3 Smile

Comments

SystemSix's picture
Offline
Joined: 2019 Apr 17

I used KeyQuencer to do System Events type stuff back in the day. I don't see a copy of it here on the garden, but it is out there on the web.

galgot's picture
Offline
Joined: 2014 May 7

Thank you ! Found it. Will try that .

nil0bject's picture
Offline
Joined: 2012 Nov 14

Is a System Event the same as an Apple Event?

BryMD's picture
Offline
Joined: 2018 Jul 2

Hi nilObject! Awesome job on ResEditX, by the way Smile

System Events is a separate scriptable layer of the Mac OS X Finder. It duplicates the scriptability of the Classic Mac OS Finder, and expands it ENORMOUSLY (including, but not limited to, GUI scripting). Apple hit the ball out of the park with Mac OS X scriptability without really getting the attention this truly would have deserved...

nil0bject's picture
Offline
Joined: 2012 Nov 14

Hey BryMD.
Cheers, I hope you've found some use for ResEditX. I recently updated it to export 'snd ' resources to system 7 sound files(.sfil). These can be opened in programs like Audacity.

I love AppleScript, too. I wish it was more universal.
System Events sound very similar to Apple Events, but simpler.
http://mirror.informatimago.com/next/developer.apple.com/documentation/m...
https://staticky.com/dl/ftp.apple.com/developer/Technical_Documentation/...

BryMD's picture
Offline
Joined: 2018 Jul 2

Have used some time to read up on Apple Events through the links you provided, and it does indeed sound EXTREMELY similar to System Events. Wouldn't say System Events is simpler than Apple Events, though. If anything, System Events seems to be quite a lot more powerful. Quite striking similarities though!

The book seems to be written in 1996, coinciding with OS 7.5. Do you know if Apple Events was ever updated for OS 9? Furthermore, do you know if it is installed with a standard system install? And if not, do you know where it could be downloaded?

Getting System Events-like control of OS 9 would be freakin' EPIC!

PS: My bad on being a 'know-it-all' in my the previous post. It won't happen again... I hope Tongue

galgot's picture
Offline
Joined: 2014 May 7

I don’t know enough to tell , sorry :/
anyway,
Found KeyQuencer 2.5 lite:
https://web.archive.org/web/19990421045431/http://www.binarysoft.com/kqm...
and the install include a "KeyQuencer Links" file that goes into the Scripting Additions folder. It adds KeyQuencer command to AppleScript.
Could then make an script that mimic Cmd-Shift-3 to make a screenshot, then move it to a certain folder.
Now to add the current date to the "Picture xx" file name with Applescript is another matter …

nil0bject's picture
Offline
Joined: 2012 Nov 14

That's good to know. Could you create or update the page for keyquencer about this and add the archive?

galgot's picture
Offline
Joined: 2014 May 7

Can't see a page for keyQuencer here . But will do one with what i've found.

Edit: done

galgot's picture
Offline
Joined: 2014 May 7

Learning Applescript on Syst 7 Smile
One thing that bothers me in Mac OS 7-9 is that screenshots are saved in root of the HD and named sequentially "Picture 1" , 2, 3… ect.
If I tidy up all my screenshots and put it in say an "Images" folder, then the next screenshot I do will again start at "Picture 1", and moving it to the "Image" folder will conflict with the previous one I've made...

I also have an MinivMac VM running a gopher server, and serving an "image" folder. I wanted to be able to make a screenshot of it via ToolDaemon, then have it automatically moved to that served "Images" folder, available thru the gopher server. But same problem here, "picture x" will conflict with "Picture x"…

So came keyQuencer (Thanks again SystemSix) to the rescue for making screenshots with an Applescript, that then rename the screenshot an put it in the "Images" folder.
It renames the file to "Screen-" followed by the hour of the day. I tried having it renamed with the all date and hour, but couldn't have the months working, got a "can't set the month as string" error or something… But still having each images with different names works for me, has I would seldom do a screenshot at the exact time of the day each days.

Was fun exercise, I'm a complete nub in Applescript. A problem is that its hard to find help online for older Mac OS 7-9 Applescript versions.

Anyway, here is the script if this can be of some interest.
Would be happy to know if any refinements can be done.
tested on a Syst 7.6.1 and 7.5.3 , KeyQuencer 255 lite installed:

http://galgot.free.fr/transit/ScreenShotScript.sit.hqx

BryMD's picture
Offline
Joined: 2018 Jul 2

Hi Galgot! Great progress on your screenshot script Smile

Here's a simply brilliant introduction to AppleScript on Classic Mac OS:

https://web.archive.org/web/20170322000233/https://whitefiles.org/b1_s/1...

It is not all exhaustive, but it will give you a rundown on all the basics. Without this guide there wouldn't be any Exposé-functions in Functional Keys Wink

galgot's picture
Offline
Joined: 2014 May 7

Thanks ! This is great resource.
Have to found now how to save the screenshot in a more easily "readable" format than .pict for OS X Wink

galgot's picture
Offline
Joined: 2014 May 7

Hi,
So this is a follow up of my Screenshot script. Finally managed to make it do all what I wanted.
that is : make a screenshot (sic), rename it to a unique name, save it as Jpeg, and move it to a folder I want.
I would love anyone to test it , and know if there is any possible improvements.

I did two versions , one working on Mac OS 8.6 and above, and one working on System 7.5.3 68k.
This because some commands changed in between, and also because I've tested the System 7.5.3 version on a relatively slow setup, and had to set delays in the commands.

For these to work, you need, all available here on this very site :
- KeyQuencer 2.55 Lite
- QuickTime 6.0.3 , For Mac OS 8.6 versions , any that works on it and above.
- QuickTime 4.0.3 , For System 7.5.3 68k (say BasiliskII), but could be a highr version if you're on a PPC.
QuickTime is needed because the script uses PictureViewer application to export the screenshot as Jpeg.

Please note: before you use the script, you must open an image (any) with PictureViewer and export it as Jpeg.
This is to set PictureViewer to export as Jpeg by default, otherwise you get BMP file.
Also note these scripts are set to save the screenshots in an "Images" folder on your startup disk.

Here the compiled Mac OS 8.6 version of the script :
ScreenShotScript4-86.hqx

here how look the Mac OS 8.6 version with comments:

-- Set KeyQuencer to trigger screenshot action
KeyQuencer Do Macro "Key cmd shift \"3\""

-- Prepare screenshot renaming
set Pictime to time string of (current date)
set Ho to characters 1 thru 2 of Pictime
set Mi to characters 4 thru 5 of Pictime
set Se to characters 7 thru 8 of Pictime

set {year:y, month:m, day:d} to (current date)

-- Set renaming to "Screen-DayMonthYearHourMinutesSeconds"
set Pic to "Screen-"
set theName to (Pic & d & m & y & Ho & Mi & Se) as string

-- Rename screenshot (Picture-x) to "Screen-DayMonthYearHourMinutesSeconds"
tell application "Finder"
activate
set the name of every file of startup disk whose name contains "Picture" to theName
set Document1 to every file of startup disk whose name contains "Screen"
end tell

-- Tell PictureViewer to open screenshot.
tell application "PictureViewer"
activate
open {Document1 as alias}
end tell

-- Set KeyQuencer to triger PictureViewer actions to image display full size, export to JPEG, and save.
KeyQuencer Do Macro "Key cmd \"1\""
KeyQuencer Do Macro "Key cmd \"e\""
KeyQuencer Do Macro "Key return"

-- Set a delay of 3 seconds, then tell PictureViewer to quit
delay 3
tell application "PictureViewer"
quit
end tell

-- Move JPEGed screenshot to "Images" folder, wait 3 seconds, then move remaining PICT screenshot to trash. Empty trash is optional.
tell application "Finder"
move (get every file of startup disk whose name contains "jpg") to folder "Images" of startup disk
delay 3
move (get every file of startup disk whose name contains "Screen-") to trash
--empty trash
end tell

Here the compiled System 7.5.3 version of the script :
ScreenShotScript4-753.hqx

And here how System 7.5.3 script version looks:

-- Set KeyQuencer to trigger screenshot action
KeyQuencer Do Macro "Key cmd shift \"3\""

-- Prepare Screenshot renaming
set Pictime to time string of (current date)
set Ho to characters 1 thru 2 of Pictime
set Mi to characters 4 thru 5 of Pictime
set Se to characters 7 thru 8 of Pictime

--set {year:y, month:m, day:d} to (current date) <--Can't get the month as string on Syst 7.5.3 !!

-- Set renaming to "Screen-HourMinutesSeconds"
set Pic to "Screen-"
set theName to (Pic & Ho & Mi & Se) as string

-- Set renaming to "Screen-HourMinutesSeconds"
tell application "Finder"
activate
set the name of every file of startup disk whose name contains "Picture" to theName
set Document1 to every file of startup disk whose name contains "Screen"
end tell

-- Tell PictureViewer to open screenshot.
tell application "PictureViewer"
activate
open {Document1 as alias}
end tell

-- "Delay" command doesn't seems to work in System 7.5.3
-- so use "timeout" for delay of 20 seconds (!) ,
-- Set KeyQuencer to trigger PictureViewer actions to image display full size, export to JPEG, and save.
-- Note : PictureViewer V.4 of QuickTime v.4.0.3 as the stubborn tendency
-- to save the screenshot in his own "QuickTime™ Folder" folder (which I place
-- in folder "Applications" of root disk). This is noted for moving the file later.
with timeout of 20 seconds
KeyQuencer Do Macro "Key cmd \"1\""
KeyQuencer Do Macro "Key cmd \"e\""
KeyQuencer Do Macro "Key return"
end timeout

-- With timeout of ? (tried different delay numbers, finally found this one on a tuto,
-- was the only one that worked for me. But I don't know what the exact length actually is ! ,
-- Set KeyQuencer to make PictureViewer quit. The simple "Quit" applescript command wouldn't accept
-- delays (timeout), so used KeyQuencer here again.
with timeout of 60 * minutes seconds
tell application "PictureViewer"
KeyQuencer Do Macro "Key cmd \"q\""
end tell
end timeout

-- Wait 10 seconds, Move JPEGed screenshot from the "QuickTime™ Folder" folder to "Images" folder,
-- wait 10 seconds, then move remaining PICT screenshot to trash. Empty trash is optional.
-- Note, while testing , these 10 delays don't acually last 10 seconds, it goes faster,
-- but if I set delays to smaller numbers, the script doesn't work, do an action before another
-- it should have done before that, and end in mess.
tell application "Finder"
with timeout of 10 seconds
move (get every file of folder "QuickTime™ Folder" of folder "Applications" of startup disk whose name contains "jpg") to folder "Images" of startup disk
end timeout
with timeout of 10 seconds
move (get every file of startup disk whose name contains "Screen-") to trash
end timeout
--empty trash
end tell

Sorry for this looooong post Tongue