About Timed Screenshot 1.1 Source

Class App
Inherits Application
// Properties
Dim c As clock
Dim foldername As string
Dim quality As integer

// Event implementations
Sub Open()
dim t as TextInputStream
dim f as FolderItem
dim s as String
dim seconds as Integer
dim o as TextOutputStream

RegisterPlugins

quality=75

f=GetFolderItem("Timed Screenshot Config")
if f<>Nil then
t=f.OpenAsTextFile

if t<>nil then
while not t.eof
s=t.ReadLine
if s<>"" and left(s,1)<>"#" then
if left(s,9)="interval=" then
seconds=val(mid(s,10))
elseif left(s,12)="destination=" then
foldername=(mid(s,13))
elseif left(s,8)="quality=" then
quality=val(mid(s,9))
end if
end if
wend

t.Close
end if
end if

if seconds>0 then
c=new clock
c.Period=seconds*1000
c.Mode=2


else
if f<>nil then
o=f.CreateTextFile
if o<>nil then
o.WriteLine "#"
o.WriteLine "# Interval in seconds:"
o.WriteLine "interval=60"
o.WriteLine "#"
o.WriteLine "# Name of destination folder:"
o.WriteLine "# Can be the name of an alias"
o.WriteLine "destination=Screenshots"
o.WriteLine "#"
o.WriteLine "# Quality in %"
o.WriteLine "quality=75"
o.WriteLine "#"

o.Close

end if
end if
quit
end if

Exception
quit
End Sub

// Methods
Sub notify(s as string)
#if DebugBuild

MsgBox s

#else
dim n as NotificationMBS

n=new NotificationMBS
n.Message=s
n.FlashIcon=true

n.Show
#endif

Exception

End Sub
End Class

Class Clock
Inherits Timer
// Event implementations
Sub Action()
dim f as FolderItem
dim g as FolderItem
dim d as date
dim p as Picture
dim s as String
dim i,c as integer
dim e as JPEGExporterMBS

c=ScreenCount
for i=0 to c
p=ScreenshotDisplayMBS(i)
p=p.BitmapMBS
d=new date

s=Format(d.Year,"0000")+"-"
s=s+Format(d.Month,"00")+"-"
s=s+Format(d.day,"00")+"-"
s=s+Format(d.Hour,"00")+"-"
s=s+Format(d.Minute,"00")+"-"
s=s+Format(d.Second,"00")+"-"+str(i)+".jpg"

f=GetFolderItem(app.foldername)
if f<>Nil then
f.CreateAsFolder
g=f.Child(s)

e=new JPEGExporterMBS
e.Progressive=true
e.Quality=app.quality
e.Picture=p
e.File=g
e.Export
end if

Next

Exception

End Sub
End Class





Links
MBS Realbasic tutorial videos