![]() 3D 3D Photo Gallery (Part 1) 3D Photo Gallery (Part 2) Audio Poor Man's MIDI Make A Metronome iPod Tricks (Part 1) iPod Tricks (Part 2) iPod Tricks (Part 3) Laugh Track Machine Audio Player with Reverb Shepard Melody RB Phone Home Build a Drum Machine Custom Controls and Windows Double Click Listbox Draggable Metal Window Double Click Canvas Custom Buttons Custom Buttons Part II iTunes-style Listboxes Custom Controls General RB Scrolling Windows Using Mesage Dialogs Case-Sensitive Word Finder Introduction to Stacks Wiggle Window JPEG in PDF Listbox Checkboxes Background Applications Listbox Auto-Find Virtual Volumes Time Tracker Software Distribution (Part 1) Software Distribution (Part 2) Software Distribution (Part 3) Software Distribution (Part 4) Exceptions Tips and Tricks Text Clippings Made Easy Graphics Drawing a Simple Gradient The SpriteSurface: Space Game Image Spinner Cropping Graphics (Part 1) Cropping Graphics (Part 2) Cropping Graphics (Part 3) Cropping Graphics (Part 4) Shimmer Graphics Lissajous Figures Simple Screen Capture Vector Graphics Kaleidoscope Images Stegonography Spirals! Image Table RB Magnifying Lens Screen Capture Color Picker Tutorial Hacks Ghost Grab Speedy Mouse Extension iTunes Plugins iTunes Skinner Mac OS X Global Hot Key Event (Carbon Events) Login Welcomer (Carbon Events) Add/Remove Buttons Resizable Sheets Mac OS X Preferences Window Using Sheets in REALbasic Build a Bundle (Part 1) Build a Bundle (Part 2) Dock Your Passwords Mac OS X Debugging REALbasic Mac OS X Icon Tutorial Animate Your Dock RB and the Command Line Menus Window Menu Templates Menu Listbox Menu Novelty Guessing Game Calendar Trivia Tile Mixer Zip Code Finder Happy Valentine's Day Merlin Simulator (Part 1) Merlin Simulator (Part 2) Merlin Simulator (Part 3) Buzzword Machine AppleSoft BASIC Printing Print to PDF Registration Registration Code Validation Network Registration Codes Resources Picture Extractor (Part 1) Picture Extractor (Part 2) Serial Caller ID (Part 1) Caller ID (Part 2) Caller ID (Part 3) Speech Speech Recognition Socket Communication Easy Peer-to-Peer File Sharing MacPAD Version Checking Display Web Image In Canvas HTML IMG Tags Version Tracking Even Smarter Instant Messaging Web Tiler JavaScript and REALbasic Stock Ticker (Part I) Stock Ticker (Part 2) AIM Mate XML Manipulation Simple XML Introduction Video Big Brother Video Capture Note: All articles without a byline were written by Erick Tejkowski. When cleaning the site I removed them because the code differed from page to page, and I have yet to put them back in.
Tell us about a bad link. |
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: LaunchGrabwhichcmd = 1 Next, open the Action event of the Timer control and enter this code: dim n as integerselect 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. |
|||||
|
Please support ResExcellence by Visiting our Sponsors. One click makes a difference. |
||||||
|
|