|
9-12-02
Simple Screen Capture for Jaguar by
Erick Tejkowsi
Mac OS X 10.2 added a new command line tool called screencapture. This handy command lets you take
screenshots in all sorts of ways. The problem? There are so many options that it begins to become difficult to
remember what everything does. REALbasic comes to the rescue! Today we'll build a simple 5-minute project that
lets you add an interface to this powerful new command line tool.
Build the Interface
The interface this week is really simple to create: one PushButton and two RadioButtons. When you add them to a window,
leave their default names as is. (i.e. PushButton1, RadioButton1, and RadioButton2).
- PushButton1 - Caption = "Capture"
- RadioButton1 - Caption = "Clipboard"
- RadioButton2 - Caption = "File on Desktop"
Arrange the interface any way you want.
Mine looks like this:
Source Code
Like the interface, the code this week is also simple. Double-click PushButton1 and add the following code to its Action event:
Dim s As Shell
dim d as date
dim f as string
//NOTE: Mac OS X 10.2 or higher required
s=New Shell
If TargetCarbon then
if radioButton1.value then
//capture to the clipboard
s.execute "screencapture -c"
else
//capture to a file
d=new date
f = str(d.totalSeconds)+".pdf"
s.execute "screencapture ~/Desktop/" + f
end if
If s.errorCode<>0 then
MsgBox "Error Code: "+Str(s.errorCode)
end if
end if
Keep in mind that this project only covers a few options available to you with the new screencapture command.
To learn about the other features, use the man command:
man screencapture
With just a little effort, it wouldn't be too tough to add the rest of the options.
Conclusion
That's it for this week. Select Debug->Run to test your work. As usual, you can download
the finished project. See you next week!
9-10-02
REALbasic News
by Erick Tejkowsi
Game Creation - MWRB
SilverNetworks has released a
bug fix release for their free game creation program, SilverCreator,
version 1.0.1.
You can download SilverCreator v1.0.1
now for OS 7.5.5 - 9.2.2 and Mac
OS X. All of the runtime
packages are included for easy compiling.And, of course, SilverNetworks is Maade with REALbasic.
I Declare!
Kevin Ballard has updated the popular Carbon Declare Library.
It includes a few new functions and some bug fixes. Check it out!
Apple GUI Guide
Apple has posted an informative piece for "switchers" (read: ex-Windows geeks)
about the Mac OS interface.
Despite being intended for the "switching" crowd, it serves as a nice introduction to some important GUI features of Mac OS X, which
you can put to use in your everyday REALbasic activities.
Marc Zeedar Tutorial and Review
Marc Zeedar begins his coverage of the latest REALbasic release by looking at the
many subtle improvements in REALbasic 4.5. While we're on the topic of Marc, you can also find a handy tutorial by him called
SimplePaint
easyPalette
fracturedSoftware has announced the release of easyPalette
preview1.
easyPalette makes it fast and easy to add cross platform, customisable
tearoff palettes to your REALbasic project ( win32 palettes will be
available in the next release ).
PrintWindow
For those who would like to print things under RB (e.g. text, styled
text or graphics) on Windows and Mac, Tony Barry has made available an RB project
called PrintWindow.
What does it do?
- It provides a styled editField which you can type into, and print from.
- It gets around the current dysfunctional StyledTextPrinter on Windows,
which does not print styles at present.
- It also provides a Print Preview window, to save paper and show what
the printer will actually print.
- No plugins are used in the project.
It is being released as donationware, and the source code is ... well,
all there.
|