If you're an avid user of AOL Instant Messenger, you may often find yourself retyping some of the same messages and phrases daily. Poor typing skills don't improve the situation. What's an AIM geek to do?
This week we'll create a simple REALbasic application, named AIM Mate, that can help alleviate some of the more mundane typing tasks of working with Instant Messenger. Our AIM Mate project will display a list of commonly used phrases and sentences as well as a list of buddies. With the click of a button, you will be able to send any text to whomever you wish. You'll never have to type "LOL" or "BRB" again!
Build the Interface
Create a new REALbasic project and open Window1. Add two Listboxes and a PushButton to the window:
| Control | Name |
| Listbox | BuddyList |
| Listbox | QuickTextList |
| PushButton | SendButton |
You can arrange the interface however you wish, but to give you an idea of where we are going with this, here's a sample:
For the sake of convenience, it would also be good to change the Frame property of Window1 to Global Floating Window. This makes the window float above all other applications, giving you easy acces while using AIM.
Create Two Text Files
When AIM Mate starts up, we will load two text files into the interface:
Create these two text files (SimpleText works fine for this) and place them in the same folder as your REALbasic project. Make sure you name them exactly as shown above. If you decide to change the file names, you will also need to do so in the code that follows.
Add the Code
Ok, enough of the preparations, let's get to the code! First, add the following code to the Open event of Window1:
dim f as folderItemThis code loads the two text files you created earlier and places the contents of each in the correspdonding Listbox.
Next, place the following code in the Action event of SendButton:
if BuddyList.Listindex>=0 and QuickTextList.ListIndex>=0 thenThis code sends the currently selected text to the currently selected Buddy. But wait! What's that SendAIM command you see there? Easy, it's the name of an AppleScript that will take care of communicating with Instant Messenger for us.
Create the AppleScript
Launch Script Editor and create a new AppleScript:
on run {x, y}Save the script as a "Compiled Script" and give it the name: SendAIM. Finally, drag the new script into your REALbasic project.
Conclusion
That's it! Test the project and when you're happy with the results, build the final application. Of course, you can download the application and completed project instead. Until next week!