vashk
Joined: 07 Jan 2008 Posts: 11
|
Posted: Tue Jan 08, 2008 6:03 am Post subject: translate a bit of C++ COM code into AHK? |
|
|
I'm trying to use the COM.ahk library to implement the following idea in AHK:
| Code: | 1.1.1. Visual C++:
In order to use the COM object in your C++ application, add the following import statement to your C++ source file, like this:
#import “<path>\TCaptureX.dll”
Optionally, you may add also:
using namespace TCaptureXLib;
in order to reference the objects without specifying the namespace.
Then create the object in one of the following two ways:
ITextCaptureXPtr obj(__uuidof(TextCaptureX));
Or
ITextCaptureXPtr obj = NULL;
HRESULT hr = obj.CreateInstance(__uuidof(TextCaptureX));
In order to destroy the object, call:
obj.Release();
Remark: before creating the object, CoInitialize API function must be called.
1.2. Using a TextCaptureX object
TextCaptureX object exposes the following methods:
- GetActiveWindowHwnd
- CaptureInteractive
- CaptureActiveWindow
- GetTextFromPoint
- GetTextFromRect
1.2.4. GetTextFromPoint method
HRESULT GetTextFromPoint([in] LONG hwnd, [in] LONG x, [in] LONG y, [out,retval] BSTR* result);
This method captures the word specified by the point (x, y) in screen coordinates, in the window specified by hwnd.
Remark: One may use CaptureIntercative method to grab these parameters, that is window handle and coordinates.
Parameters: LONG hwnd : handle of the window to capture from
LONG X : X coordinate of the point
LONG Y : Y coordinate of the point
coorBSTR* result : the word (if any) located at the specified point
Examples:
Visual C++:
LONG hwnd = 0;
LONG X = 0;
LONG Y = 0;
//set the values
.......
bstr_t bstrResult = obj->GetTextFromPoint(hwnd, X, Y)
|
My idea would be to use MouseGetPos command in AHK and pass the resulting coordinates and HWND to GetTextFromPoint method above, but I'm having trouble instantiating and using a TextCaptureX object using my limited knowledge. I'm trying to add some much-needed functionality to AHK (get text from anywhere on the screen) so anyone willing to lend their experience would be greatly appreciated.
More detail here: http://www.autohotkey.com/forum/viewtopic.php?t=27331 _________________ --v |
|