PDA

Click to See Complete Forum and Search --> : Can I do this?


contortix
Aug 25th, 2000, 01:06 AM
I have made a text encryption program and am very happy with the result. It uses a simple encryption schyme of turning each character into ascii, adding a predefined number, and then converting it back to a character.

What I need help on is making it able to read and, if possible, manipulate text boxes from other programs (ie. AOL Instant Messanger). I know how to find each program (FindWindow API) but am stumped on how to do the rest. People have told me that it's possible but i dunno. Any help would be appreciated.


-contortix

Aug 25th, 2000, 01:17 AM
Here is how to get the text from other Windows:

Type POINTAPI
X As Long
Y As Long
End Type

Declare Function GetCursorPos Lib "user32" _
(lpPoint As POINTAPI) As Long
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hWnd As Long) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Public Declare Function WindowFromPointXY Lib "user32" Alias "WindowFromPoint" (ByVal xPoint As Long, ByVal yPoint As Long) As Long


Function GetCaption(hWnd)
hwndLength% = GetWindowTextLength(hWnd)
hwndTitle$ = String$(hwndLength%, 0)
a% = GetWindowText(hWnd, hwndTitle$, (hwndLength% + 1))

GetCaption = hwndTitle$
End Function

Private Sub Timer1_Timer()
Dim pnt As POINTAPI
MousePointer = 0
GetCursorPos pnt
yhwnd% = WindowFromPointXY(pnt.X, pnt.Y)
Text1.text = GetCaption(yhwnd%)
End Sub

Or you could get every caption off of every window.

'^API^ needed
For i = 1 To 10000
X = GetCaption(i)
List1.AddItem X
Next

Hope that helps a little.

Jerry Grant
Aug 25th, 2000, 02:50 AM
I suggest that you do some reading about DDE.

Dynamic Data Exchange, can link two applications and transfer data between (read & write), picture boxes, text boxes & labels.

See the VB files for sample code.