Text Capture Library COM Server Quick Tutorial - AutoIt Sample

Download the source code for this article: AutoItSample.zip                      More samples...

SUMMARY

This code snippet shows how to use Text Capture Library as a COM server in AutoIt and get text from selected window.

 

 1 ;
 2 ; AutoIt Version: 3.0
 3 ; Language:       English
 4 ; Platform:       Win9x/NT
 5 ; Author:         skesoft.com
 6 ;
 7 
 8 #include <GuiConstantsEx.au3>
 9 #include <WindowsConstants.au3>
10 
11 _Main()
12 
13 Func _Main()
14     $tcServer = ObjCreate('TextCaptureLib.TextCapture')
15     $tcWindow = ObjCreate('TextCaptureLib.Window')
16 
17     ;Please set your license info here
18 
19     ;If $TcServer.License ("skesoft", "123456789") Then
20         ;The registered version of Text Capture Library
21         ;MsgBox(0, "OK", "License is OK")
22     ;Else
23         ;The trial version of Text Capture Library
24         ;MsgBox(0, "ERROR", "License is ERROR")
25     ;EndIf
26 
27     GUICreate("Text Capture Library Auto-it example", 469, 200, (@DesktopWidth - 469) / 2, (@DesktopHeight - 200) / 2, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
28 
29     GUICtrlCreateLabel("Window handle ", 10, 10, 150, 20)
30 
31     $Handle_Edit = GUICtrlCreateInput("", 170, 10, 280, 20)
32 
33     ;Create an "OK" button
34     $OK_Btn = GUICtrlCreateButton("Capture", 20, 80, 70, 25)
35 
36     ;Create an "Exit" button
37     $Exit_Btn = GUICtrlCreateButton("Exit", 290, 80, 70, 25)
38 
39     GUISetState()
40     While 1
41         $msg = GUIGetMsg()
42         Select
43             Case $msg = $OK_Btn
44                 $tcWindow.Handle = Int(GUICtrlRead ($Handle_Edit))
45                 If $tcWindow.IsValidWindow Then
46                     $strResult = $tcServer.GetText($tcWindow)
47                     MsgBox(0, "GetIt!", $strResult)
48                 Else
49                 EndIf
50 
51             Case $msg = $GUI_EVENT_CLOSE
52                 ExitLoop
53 
54             case $msg = $Exit_Btn
55                 ExitLoop
56 
57             Case Else
58                 ;;;
59         EndSelect
60     WEnd
61     Exit
62 EndFunc   ;==>_Main
More samples...