| |
Declare Function GetDesktopWindow Lib "user32" () As Long
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmd As Long) As Long
Const GW_CHILD = 5
Private hWndDesktopListView As Long
Public Function EnumFunc(ByVal hwnd As Long, ByVal lParam As Long) As Long
Dim ClsName As String
Dim len5 As Long
If hwnd = 0 Then
EnumFunc = 0
Else
ClsName = String(255, 0)
len5 = GetClassName(hwnd, ClsName, 256)
ClsName = Left(ClsName, len5)
If ClsName = "Progman" Then
Dim hChild
hChild = GetWindow(hwnd, GW_CHILD)
hChild = GetWindow(hChild, GW_CHILD)
If hChild <> 0 Then
ClsName = String(255, 0)
len5 = GetClassName(hChild, ClsName, 256)
ClsName = Left(ClsName, len5)
If ClsName = "SysListView32" Then
hWndDesktopListView = hChild
EnumFunc = 0
End If
End If
Else
EnumFunc = 1
End If
End If
End Function
Sub TextCaptureLibSample()
'
' TextCaptureLibSample Macro
'
Dim hWndDesktop As Long
Dim TcServer As Object
Dim str As String
hWndDesktop = GetDesktopWindow
If hWndDesktop = 0 Then
MsgBox "Can't get desktop window handle"
Exit Sub
End If
hWndDesktopListView = 0
Call EnumChildWindows(hWndDesktop, AddressOf EnumFunc, 0)
If hWndDesktopListView = 0 Then
MsgBox "Don't find desktop listview control"
Exit Sub
End If
Set TcServer = CreateObject("TextCaptureLib.TextCapture")
Set TcWindow = CreateObject("TextCaptureLib.Window")
'Please set your license info
‘If TcServer.License("skesoft", "123456789") Then
‘ 'The registered version of Text Capture Library
‘Else
‘ 'The trial version of Text Capture Library
‘End If
TcWindow.Handle = hWndDesktopListView
str = TcServer.GetText(TcWindow)
' MsgBox str
With Selection
.Font.Name = "times new roman"
.Font.Bold = False
' Insert result here
.TypeText str
End With
Set TcWindow = Nothing
Set TcServer = Nothing
End Sub
|