Monday, May 14, 2007

Lesson 5: The Extra Mile

Ok, so there's more than one way to skin a cat and there's more than just a few ways to get text into a window. This next method is much more complicated but hang with me; if I can do it, I think you will be able to as well.

Go to the "Windows, controls" icon on the QM Toolbar and go down to the "Accessible object actions" menu choice. This opens up a dialog that looks like this:

Take a look at all the different actions on the left-hand side. These will really start to open up your possibilities as you get more and more skilled at QM (or as some say, 'more kung-fu'). In this lesson, I'm just going to be dealing with the 'Get value' and the 'Set value'.

Let's start with a text editor of your choice; I'm going to use Notepad but you can use anything you like. First, let's set the value of a window/field or whatever you are wanting to change. Click on 'Set value' and then click-and-hold the 'Drag' icon; drag it over and drop it on the part of the window for which you want to set the value.

You'll notice that there is a thick black line surrounding the parts of the window as you hover over them. Let go of the mouse button when you have selected the right part of the window. QM now shows you what it 'sees' of that area.
Most of the time, you'll need to modify the 'Window' title; you can do that by clicking the button with three dots right next to it. You'll see this dialog after doing so.

The first thing I usually do is start adding wildcards to the Title. So, '- Notepad' becomes '*- Notepad'. Don't forget to also check the 'Use *' checkbox below! There are other options you can modify but I rarely have to.

There are also other values you can change in the main dialog too but I'll not be covering that in this lesson. So, now my dialog looks like this:

You can change the variable assignment if you wish within this dialog before letting QM enter this info into the macro. Now, hit 'Ok' and it puts this info into your macro.
Acc a=acc("" "TEXT" win("*- Notepad" "Notepad" "" 0x3) "Edit" "" 0x1800 0x0 0x20000040)
a.SetValue("Hey, set this value.")
Now that we have a target, let's start putting in the info. As you can see, the second line of my code is already doing just that. I can also have it set the value using a variable as well. Now, the thing to keep in mind about this function is that it will erase anything that is there already....unless......
_s=a.Value();;this, of course, gets the value
_s.from(_s "[]Now it's both values")
Yep, that's just what we were looking for. Now, you can 'append' info to the window by feeding its value back into a variable and manipulating than variable. You may not want to use this technique for more than small dialog fields but who knows, it may be just the thing you're looking for in that hard to get-at window.

So have at it and I'll see you next time cause the hook always brings you back.

No comments: