by Mike DeVoe
I’m surprised at how many times I’ve been asked how scripting FOCUS applications is possible since it is so mouse-driven. I get this question from seasoned script programmers as well as non-programmers. I’m sure they’ve conjured up visions of counting pixels to deliver a mouse-click to a particular dot on the screen and hope their target is somewhere under that dot.
Let’s see how this nightmare would play out. First, we need to know which FOCUS child window to look at as well as its coordinates within the main FOCUS window. Then we need to count the pixels inside the window to our target click location, subtract the width of the window border and the height of the window’s caption bar, and then… and then… and then… and finally… click. I suspect if this is how we had to script mouse activity in FOCUS, we would all become musophobic and stand on our chairs.
The good news is you should expect your scripting tool to manage all this complexity for you. Let’s consider what kind of stuff we usually click in a FOCUS window. Buttons immediately come to mind but we also click in text boxes, check boxes, tabs and a variety of other Windows objects. In FOCUS, we can even click on words such as the names of menu items. Your scripting tool should give you an option to say something like “click the HOME button” or “click on the text that says Process Account.” This way you can write your script in a way that makes sense to you and let the scripting tool do all the nasty math to deliver the mouse click. For those rare times you have to click somewhere on the screen that isn’t a button, text box or other typical Windows object, your scripting tool should give you a recording feature to collect all these details and still do all the behind-the-scenes math on your behalf.
When I explain this to programmers, many ask what happens if the window is under another window. Won’t the mouse click hit the wrong window? While there is a way to simulate a mouse click to the screen, your scripting tool should deliver the mouse click directly to the window and not the screen, eliminating this and many other issues.
With the right scripting tool, writing scripts for mouse-driven applications can be very intuitive and just as reliable as more traditional scripting methods such as sending keystrokes. Secure in this knowledge, it is time to step down from our chairs and proudly proclaim “We Ain’t Afraid of No Mice.”
0 responses so far ↓
There are no comments yet...Kick things off by filling out the form below.
Leave a Comment