AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

translate a bit of C++ COM code into AHK?

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
vashk



Joined: 07 Jan 2008
Posts: 11

PostPosted: Tue Jan 08, 2008 6:03 am    Post subject: translate a bit of C++ COM code into AHK? Reply with quote

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
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group