Jimekus
10/20/2011 7:13:00 AM
On Oct 20, 7:19 pm, MM <kylix...@yahoo.co.uk> wrote:
> Acrobat Reader 9 has a Find field that initially contains the text
> "Find". The class is named Edit.
>
> I've tried using FindWindow to get the hwnd, but there are too many
> windows of that class. The only way I can think of is
> EnumerateWindows, then check whether the text = "Find", but this has
> to be quite a costly process I should think, given the plethora of
> windows?
>
> OTOH does anyone know to what extent VB6 can "talk" to Reader 9 via
> DDE?
>
> MM
I downloaded the M$ tool called SpyXX.exe and then contructed some
snakes and ladder type loops to get me to the edit field to later
allpw me set the current track in Winamp's Shoutcast DSP plugin. Much
easier than using Autoit.
-----------------------------------------
Dim lngHandle As Long
' Find the window based on SpyXX.exe
lngHandle = FindWindow(vbNullString, "Nullsoft SHOUTcast Source")
If lngHandle <> Zero Then
'get the first child-window...
lngHandle = GetWindow(lngHandle, GW_CHILD)
'loop through all of the child windows after the first...
Do Until WindowClass(lngHandle) = "#32770"
lngHandle = GetWindow(lngHandle, GW_HWNDNEXT)
Debug.Print WindowClass(lngHandle)
Loop
lngHandle = GetWindow(lngHandle, GW_HWNDNEXT)
Debug.Print WindowClass(lngHandle)
'loop through all of the child windows after the first...
lngHandle = GetWindow(lngHandle, GW_CHILD)
Do Until WindowClass(lngHandle) = "#32770"
lngHandle = GetWindow(lngHandle, GW_HWNDNEXT)
Debug.Print WindowClass(lngHandle)
Loop
lngHandle = GetWindow(lngHandle, GW_HWNDNEXT)
Debug.Print WindowClass(lngHandle)
lngHandle = GetWindow(lngHandle, GW_CHILD)
'loop through all of the child windows after the first...
Do Until WindowTextGet(lngHandle) = "Now"
lngHandle = GetWindow(lngHandle, GW_HWNDNEXT)
Debug.Print WindowClass(lngHandle)
Loop
lngHandle = GetWindow(lngHandle, GW_HWNDNEXT)
Debug.Print WindowTextGet(lngHandle) 's/b test7
lYellowPagesTrackTitle = lngHandle
lngHandle = GetWindow(lngHandle, GW_HWNDNEXT)
lngHandle = GetWindow(lngHandle, GW_HWNDNEXT)
lYellowPagesSendUpdate = GetWindow(lngHandle, GW_HWNDNEXT)
FilenameNowPlaying = NotString
If Not fHIDJ Is Nothing Then fHIDJ.TreeSync
End If
------------------------
Private Function WindowClass(ByVal hwnd As Long) As String
Const MAX_LEN As Byte = 255
Dim strBuff As String, intLen As Integer
strBuff = String(MAX_LEN, vbNullChar)
intLen = GetClassName(hwnd, strBuff, MAX_LEN)
WindowClass = Left(strBuff, intLen)
End Function
Public Function WindowTextGet(ByVal hwnd As Long) As String
Dim strBuff As String, lngLen As Long
lngLen = SendMessageAny(hwnd, WM_GETTEXTLENGTH, 0, 0)
If lngLen > 0 Then
lngLen = lngLen + 1
strBuff = String(lngLen, vbNullChar)
lngLen = SendMessageAny(hwnd, WM_GETTEXT, lngLen, ByVal
strBuff)
WindowTextGet = Left(strBuff, lngLen)
End If
End Function
Public Function WindowTextSet(ByVal hwnd As Long, ByVal strText As
String) As Boolean
WindowTextSet = (SendMessageAny(hwnd, WM_SETTEXT, Len(strText),
ByVal strText) <> 0)
End Function