|
-
Dec 5th, 2001, 06:32 PM
#1
Thread Starter
Hyperactive Member
Hard: LB_GETTEXT?
Alright, well, I have some code that will sequentially go through a list and get the test of each in another application. The code gets the right amount of items, however when it gets the text it appears to be garbled, or in code. I remember reading somewhere that you've got to use ReadProcessMemory or something... any ideas? Thanks in advance.
-
Dec 5th, 2001, 06:42 PM
#2
Frenzied Member
This code is used to find a window with a caption
somewhat like the string you have.
You should be able to understand from this.
VB Code:
Option Explicit
Declare Function GetWindow Lib "user32" (ByVal hWnd As Long, ByVal wCmd As Long) As Long
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Function GetForegroundWindow Lib "user32.dll" () As Long
Public Const GW_HWNDNEXT = 2
Public Const GW_CHILD = 5
'********************************************
'*Give it part of the window text your looking for
'*it will give you the hWnd
'*usefull for windows that text is like "[project] - microsoft visual basic [design]"
'*usage:
'*Msgbox FindWindowLike("visual basic")
'*Returns 0 if not found
'*******************************************
Function FindWindowLike(strPartOfCaption As String) As Long
Dim hWnd As Long
Dim strCurrentWindowText As String
Dim r As Integer
hWnd = GetForegroundWindow
Do Until hWnd = 0
strCurrentWindowText = Space$(255)
r = GetWindowText(hWnd, strCurrentWindowText, 255)
strCurrentWindowText = Left$(strCurrentWindowText, r)
'hWnd = GetWindow(hWnd, GW_CHILD)
If InStr(1, LCase(strCurrentWindowText), LCase(strPartOfCaption)) <> 0 Then GoTo Found
hWnd = GetWindow(hWnd, GW_HWNDNEXT)
Loop
Exit Function
Found:
FindWindowLike = hWnd
End Function
-
Dec 5th, 2001, 07:18 PM
#3
Thread Starter
Hyperactive Member
What?
Maybe you didn't quite understand what I was was asking.... I meant a list as a ListBox, and the items it holds. I can get the correct amount of items, but LB_GETTEXT does not return the text, but garbled or coded information... and I know I am calling it right. I think that you have to somehow use ReadProcessMemory to get the specified information, but I don't know how to approach it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|