by Mike DeVoe
Regardless of the mysteries under the hood of the new FOCUS client, we’ll always be able to control it from a script. In a nutshell, scripting is nothing more than reading screens and sending keystrokes. In the MEDITECH MAGIC days of terminal emulation we could write our own emulation to send keystrokes and manage the screens ourselves. Later, MEDITECH was kind enough to give us a “script DLL” widget so we could read their screens and send keystrokes through the workstation application.
In FOCUS, the client is not a terminal emulator and even if it were, we probably couldn’t figure it out. MEDITECH no longer provides a scripting DLL widget so it seems we’re on our own. As far as the scripting basics of “screens and keystrokes,” we’ve got keystrokes figured out. If you’ve done much Windows programming, you know sending keystrokes and simulating mouse clicks are fairly straightforward tasks. Reading screens, however, is a whole different story. In a Windows application, by the time text hits the screen, it is no longer text. Instead, it is a collection of pixels that represent the text. Much like closing the barn door after the horse has run off, by the time text hits the screen, we’ve missed it.
The trick to reading text is to read it before it gets to the screen. Windows applications don’t get to talk directly to hardware such as screens and keyboards. Instead, when an application wants to draw text on the screen, it has to ask the Windows operating system to do the drawing. If a scripting tool can wedge itself between the FOCUS client and the Windows operating system, we can watch FOCUS ask the OS to draw text. If we can watch this happen, we don’t need to read the screen. We’ll know what is on the screen as it is being written.
In fact, we can watch the FOCUS client ask Windows to do all kinds of stuff so we can know exactly what it is up to at all times. As Fleetwood Mac suggested in their 1987 single, we can also choose to tell “sweet little lies” if it suits us. A scripting tool might benefit from watching the FOCUS client ask Windows how big the screen is and then tamper with the answer. If FOCUS thinks it’s always running on an 800×600 display, it will draw screens at the exact same size, which helps us write more portable and consistent scripts.
As long as MEDITECH runs on Windows we’ll always be able to control it from a script. Instead of trying to figure out what the FOCUS client is thinking, we can just watch it interact with the outside world to know what its doing. Short of MEDITECH abandoning the Microsoft platform, scripting is here to stay and will continue to work just fine in FOCUS.
Check out the video below to see a script running on the 6.x platform:
3 responses so far ↓
1 John Sharpe // Feb 3, 2010 at 2:07 am
Mike,
If a picture is worth a 1000 words … your video says a lot. It is always great to watch a professional at work.
MEDITECH analysts often ask – if I want to use a scripting vendor other than Boston, Iatrics, or Summit, are there other options like AutoIt for FOCUS? My feeling is … not likely.
If I understand what you are saying here, it is this intervention between MEDITECH and WINDOWS that other vendors most likely aren't and won't be doing. Solving the MEDITECH scripting problem requires a significant investment, one vendors outside the MEDITECH marketplace aren't likely to hurdle for another sale of 1-2000 licenses. Hence their low price; but also low value to the MEDITECH customer.
Your thoughts?
Thank you,
John
2 Mike DeVoe // Feb 3, 2010 at 10:11 am
Hi John,
First, thanks for the kind words and the great feedback. I’m not sure what technology other vendors put into their scripting tools but it seems if you’re going to be scripting FOCUS and the newer C/S 5.6 application, you’re going to need to do something similar to the OS API hooking I’ve described. You’re correct that it isn’t particularly easy but short of OCR, I can’t think of any other ways to know what text is on the screen. Since I’ve moved Scriptlink away from doing its own terminal emulation (MAGIC 3x style), this is the technology I’m using for all MEDITECH emulations and it works well.
As for their low price, I have no idea what other scripting vendors charge but we’re giving away a version of Scriptlink which does FOCUS (as well as all the MEDITECH emulations) so that would seem to be a hard price to beat.
Again, thanks for the great feedback.
3 John Sharpe // Feb 11, 2010 at 5:40 pm
Thank you Mike.
I'm spreading the word on Script+ Standard Edition here: http://meditech.stackexchange.com/questions/122....
Leave a Comment