Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

external window text grabber with replace

Status
Not open for further replies.

antvon

Programmer
Dec 2, 2002
45
Hi All

Id like to write some code that
will allow me to read in some string
from an 'external window', manipulate it
and paste it back into the ext. window with
the modification.

i.e. assume that the app is running and that
the ext window is a vb6 design window.
the text i want to change is text1.text.
the app then graps text1.text and changes it
to Val(text1.text) and replaces it in the vb6
window.

This is more or less how find and replace works
within the some window.

The msgbox and error template routines from Zada
seem to work like this and I'd like to do the same
but unfortunately have no knowledge of api, hooking
and whatever else it seems to make use of.

Hoping there is some kind folks out there who don't
mind enlightening me.

Thanks.
 
It can be done with SendMessage API, but you have to get the handles of the app window and the text box to pass data to it and read data from it. Read up on SendMessage. You can find it on most VB sites.
 
cgfiend

I'm looking into it now
and it seems quite interesting

Thanks for the tip
 
Here are the declares you'll need. Get All API Guide off the net and reference these to see how they work.

Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Public Declare Function SendMessageByNum& Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long)
Public Declare Function SendMessageByString Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
Public Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
 
Thanks again

I will try to get a handle on it
as soon as possible
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top