|
1-31-02
REALbasic Ghost Grab by
Erick Tejkowski
This week we'll take a break from the Merlin project and play with a newly released plugin.
Totte Alm has created a fun REALbasic plugin that permits you to send key down events to any
application. This is very useful for "faking" scripting of non-scriptable applications.
Preparation
Before you begin this project, you will need to download the T3 Key Plugin from Totte's site.
When you have the plugin, drop it in your REALbasic Plugins folder. Note that this week's
example only works on Mac OS X. When you're finished downloading and installing the plugin, launch REALbasic.
Build the Interface
The interface for this project is very simple. Drag a Timer control to Window1 and
set is Period to 1000 and Mode to 2. That's it! Simple, huh?
Add the Code
The code example this week is also very easy to complete. It is based heavily on the project that
accompanies the plugin, but simplifies matters a bit.
Double click Window1 to open its Code Editor and add the following code to its Open event:
LaunchGrab
whichcmd = 1
Next, open the Action event of the Timer control and enter this code:
dim n as integer
select case whichcmd
case 1
//press Cmd-Shift-Z
//to start timed screenshot
n = PostCommandKeyEvent(true)
n = PostShiftKeyEvent(true)
n = PostKeyEvent( "Z", &h06, true )
n = PostKeyEvent( "Z", &h06, false )
n = PostCommandKeyEvent(false)
n = PostShiftKeyEvent(false)
case 2
//press return to start the timer
n = PostKeyEvent( "", &h24, true )
case 3
//quit app
me.mode=0
quit
end select
//go to next step
whichcmd=whichcmd+1
Then, select the Edit-New Property menu and create a new property as follows:
whichcmd as Integer
The final step for coding this example is to launch the AppleScript Script Editor and create a script like this:
tell application "Finder"
tell application "Grab"
activate
end tell
end tell
Save the script as a "Compiled Script", and name it LaunchGrab. Drag this script into
your REALbasic application. You're ready to go! When you launch the application, it will in turn
launch the Grab application, press Cmd-Shift-Z, followed by a tap on the Return key. This
keyboard sequence causes the Timed Screenshot window to appear in Grab and start the process of
a timed screenshot. The great part about this, though, is that this is impossible with AppleScript alone.
It works as though you had typed the commands in by hand. The demo plugin stops working after a few minutes,
but this doesn't matter for our simple example. We will be finished using it in a matter of seconds.
And, if you're interested in more involved uses of the plugin, the price is very affordable.
As you can imagine, this plugin has many interesting possibilities. Not only is it good for "scripting"
previously unscriptable applications or features of applications, it has other uses. It wouldn't be terribly difficult, for example,
to force a browser to launch, open a URL, and automatically login. Or, maybe you just want to play a trick on a friend. This
plugin would help you out in such endeavors as well. In the future, we may use the plugin here at ResExcellence to
demonstrate how to do a particularly confusing action in REALbasic. That way you can download a simple application which will guide you through
the steps of a project. Fun stuff, indeed. Now, it's up to you to come up with an imaginative use for this powerful tool.
Conclusion
You can download this week's project and example application, in case you don't want to create the
project by hand. Have fun and see you next week when we'll wrap up our Merlin project.
1-29-02
REALbasic News
by
Erick Tejkowski
REALbasic 4.0.2fc1
REAL Software has announced the availability of REALbasic 4.0.2fc1. You can download it at one of the following locations:
Application Framework
Nick Hunt has posted a useful application framework in binhex format
and as a disk image.
Buggy
Paul Gaspar has posted a nifty tool for debugging.
If you need a simple but comfortable way to get debugging
messages out of the IDE or built applications before a crash happens
- just download this:
Buggy 1b1
- displays your messages in an external window
- writes them to a log file
- accepts string, integer, double, boolean messages
- very easy to use
- freeware
db Reports
Aaron Bratcher has announced db Reports.
db Reports is a cross-platform report writing application. With db Reports,
you can extract, format and print data from one of various data sources.
Depending on platform, data sources may include: 4D Server 6.7, FrontBase,
mySQL, ODBC, OpenBase, Oracle, postgreSQL, REALDatabase, Valentina (1.8.9r7)
Using the built-in assistant, or the easy-to-use drawing environment, a
report can be built quickly and easily. db Reports also supports data
grouping and fully recursive expressions. String, Math, and Logical
(including IF) expressions make db Reports a powerful tool for analyzing
data.
Download a free demo.
MDock
The dock-drawing plugin (MDock) of OSX Utils has been updated and should fix
all memory leaks--there was still a small one as of the last release. Other
plugins are unchanged.
Get it here.
|