Hack58.Car-Enable Clunky Applications


Hack 58. Car-Enable Clunky Applications

You can use a scripting program to provide single-press access to application features that normally require complex menu navigation.

Many programs are difficult to use without a mouse and keyboard. For instance, most of the navigation packages for Windows are almost impossible to control without stopping the car and clicking on tiny buttons for a while. These applications are actually designed for use by a passenger with a laptop, not the driver.

A few summers ago I went on a month-long, cross-country trip with my wife and daughter ("to find America," as my friend put it). During the trip, we stopped from time to time and uploaded maps of our route so our relatives could keep track of us. We also took pictures of our daughter in front of all the "Welcome to [state]" signs we passed along the way.

Our "itinerary" was no more specific than dots on a poster-sized map of the U.S., and a printout of the addresses of our friends and family. As we had no portable Internet solution worked out for that trip except for any WiFi connection we might stumble upon, we relied on our GPS unit, our prototype CarBot, and the DeLorme Street Atlas USA program.

The DeLorme program has a sort of clunky, Visual-Basic-buttony feel, but it was pretty fast on my 600-MHz fanless VIA EPIA motherboard. I was fortunate to have a copilot who could work the clunky NAV application on that trip, though, as we quickly learned that the program is essentially unusable by the driver. Few programs are written to be used exclusively with a mouse; fewer still are designed to be used by someone with only one free hand who can't look at the screen except for fractions of a second.

Being used to MapQuest, we liked the DeLorme feature of being able to put in any two addresses and calculate the route between them, and the fact that we could switch between having the map track with the GPS unit (i.e., where we actually were) and then doing some MapQuest-like "reconnaissance" to find out where we were going.

I liked the DeLorme program, and it had all the maps and features I needed. Thus, when I later went to find the ideal NAV application for my in-car computer, I was frustrated that I couldn't just use the cheap (less than $100) app that I had already bought.

5.5.1. Scripting a Solution

On the MP3Car.com forums (http://www.mp3car.com), there is constant talk about controlling, launching, and grabbing the Windows handles of other non-car applications to make them work with car PC software. While this is a great solution for a coder (which I am, but that's not the point), I wanted to see what I could do with application scripting alone.

After a few searches, I found a freeware Windows scripting solution that, after a steep two-hour learning curve, solved my problem within a few minutes. Called PowerPro (http://powerpro.webeddie.com), it is a strange, non-intuitive, yet solid and versatile application. The program can do everything under the sun, including macros (sequences of keystrokes and commands), timed scripts, application launching, and pop-up and skinned menus. It seems designed to minimize the number of clicks and keystrokes you need to do any task, which is exactly what I wanted to do for my NAV program.

As mentioned in "Control Your Car PC with a Touchscreen" [Hack #57], big, easy-to-see, fixed-position buttons are far safer for a driver to use than pop-down menus. In PowerPro, you can create a menu full of clickable command buttons, known as a bar. You can specify the color, text size, and a background for these buttons. You can also tell the bar to be always on top and to position itself in all sorts of fixed and variable locations, related either to the main window or to the frontmost screen.

Navigation software tends to have two basic modes: route planning, and simply showing a map of where you are. In the case of my road trip, all of the basic routes were planned in advance (i.e., "Drive from Tacoma to Boise on this freeway"), so I didn't need the route-planning functionality in my application. What I did want to be able to do while I was driving was:

  • Zoom in and out on the map, so I could see the forest or the trees

  • Toggle pan-to-GPS-location, so I could glance ahead on the map and then snap back to showing where I was

Showing you how to set up these two functions should give you a feel for how PowerPro works and enable you to create your own custom uses. Setting up zooming was simple, because zoom in and zoom out functions were already enabled in the DeLorme application, using the keyboard shortcuts of Page Up and Page Down. Toggling pan-to-GPS-location was more difficult.

To get PowerPro to control Street Atlas, I had to learn its simple scripting language. After a while, I figured out that the syntax for sending Page Up and Page Down keystrokes to the window of a running program were the following (for up and down, respectively):

 *Keys {to *USA*} {pgup} *Keys {to *USA*} {pgdn} 

The *Keys command tells the button to send keypresses; the {to *USA*} sends them to a particular window of a running program, identified by the text in its titlebar (in this case, "USA"). The titlebar of the running Street Atlas program contained the text "startup.sa9DeLorme Street Atlas USA." In my matching string, the * wildcards before and after USA basically say, "Find a window with 'USA' somewhere in the title." I first tried the string DeLorme, but I ran into problems I couldn't debug; once I changed it to *USA*, it worked fine. If I were going to run another program that had "USA" in the window title, though, I would need to change my search string to something more specific.

PowerPro allows you to set a few button preferences, including the button transparency, the button size (I made it 80 x 80 pixels), and the font and position of the button text. The results were plain, but functional. I created two large, easily visible buttons on the righthand side of the screen that held their positions no matter what I did and allowed me to rapidly zoom in and out.

Toggling pan-to-GPS-location off and on was slightly trickier, as the check-box option in the menu can't be run with a single keypress. As you probably know, Windows menus usually have accelerator keys assigned to them. When you press and hold the Alt key, various letters on the menu become underlined. When you press those letters in combination with the Alt key, the corresponding menu item is selected. The PowerPro code for the Alt key is a %. Using that piece of information, I was able to use the following command to launch the menu item that was accessible with the Alt-A-G key combination:

 *Keys {to *USA*} %ag 

I experimented with putting a one-second delay between the two letters, but I found it wasn't necessary, and the option toggled without even showing me a pop-up menu. I wasn't finished yet, though. I had corny-looking buttonsfunctional but way uncooland I wanted to improve them a bit before I called the project done. So, I did a screen grab of Street Atlas, selected the tiny zoom buttons and a GPS button off the top of the screen, resized them, and pasted them into a rudimentary stack of three buttons.

Then, I simply configured a background for my button bar in PowerPro, and voilàmy big, iconic, touchscreen-friendly buttons were in place (see Figure 5-5)

Figure 5-5. Stylish PowerPro DeLorme buttons


In addition to everything else, PowerPro gives you 12 virtual desktops that you can instantly switch between with a button press. Using this feature, you can create a fixed-position button bar along the bottom of the screen, containing nothing but one-sentence "scripts" (which are just keypresses) that switch between your various virtual desktops. On each virtual desktop, you can run one in-car PC application, such as your navigation software, iTunes, a movie player, a video game emulator, and so on. Not only that, but using the facilities available with the {to NameOfWindow} command, you can configure buttons to operate on apps that are on different screens, so that, for example, your music controls (play, pause, rewind, fast forward, next track, shuffle, etc.) all appear on whatever screen you're looking at. You can then use whatever media player you'd like, whether it's "driverfriendly" or not.

With an image-editing program, a few solid hours spent learning the PowerPro program, and a couple of days to play, you can put together your own custom in-car PC application to automate your favorite programs, without having to "program" at all.

5.5.2. See Also

  • "Control Your Car PC with a Handheld Remote" [Hack #56]



    Car PC Hacks
    Car PC Hacks
    ISBN: 0596008716
    EAN: 2147483647
    Year: 2005
    Pages: 131

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net