homebrew311 Posted October 25, 2003 Posted October 25, 2003 hey i wanna kno if and how u enter text into another progs textbox. ive seen other programs enter text into an AIM box and automatically send. More specific: u have the main exec. (call it "hi"), and one that is already running ("bye"). u load up "hi". lets say 'hi' has a textbox that when typed in, enters its text to 'bye's textbox. how do u do this? ill repost if u dont understand. thx for the help p.s. if possible give code in vb.net. Quote
*Gurus* Derek Stone Posted October 25, 2003 *Gurus* Posted October 25, 2003 Use the Win32 API function [api]SendMessage[/api] and the window messages WM_GETTEXT and WM_SETTEXT. Quote Posting Guidelines
homebrew311 Posted November 1, 2003 Author Posted November 1, 2003 thx but i dont know how to get handles of other windows, or to send messages to that windows textbox. could someone give me an example please? im dumb with this API stuff Quote
Leaders dynamic_sysop Posted November 2, 2003 Leaders Posted November 2, 2003 Private Declare Ansi Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As String) As Integer Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer Private Declare Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" (ByVal hWnd1 As Int32, ByVal hWnd2 As Int32, ByVal lpsz1 As String, ByVal lpsz2 As String) As Int32 Private Const WM_SETTEXT As Integer = &HC Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim hwnd As Integer = FindWindow(vbNullString, "Untitled - Notepad") '/// assuming you have notepad open. Dim x As Integer = FindWindowEx(hwnd, 0, "Edit", vbNullString) Dim strText As String = "some text" If Not x = 0 Then SendMessage(x, WM_SETTEXT, 256, strText) End If End Sub Quote
homebrew311 Posted November 3, 2003 Author Posted November 3, 2003 hey thanx a lot, but heres another: wut if i made a program and i called its textbox "1xoBtxeT". would i just change the "Edit" in ur code to "1xoBtxeT"? (and the caption of course) Quote
Leaders dynamic_sysop Posted November 3, 2003 Leaders Posted November 3, 2003 something like that yes :) Quote
homebrew311 Posted November 3, 2003 Author Posted November 3, 2003 it doesnt seem to work when i try it. i make sure i get the right window title and i remember wut i named the control, but it doesnt work. Quote
*Gurus* Derek Stone Posted November 3, 2003 *Gurus* Posted November 3, 2003 The name of the control has nothing to do with the Win32 windowing system. The control name is just a programmatic method of addressing an object that will ultimately be rendered as a window of class type EDIT. The code provided by dynamic_sysop should work as is. Quote Posting Guidelines
Leaders dynamic_sysop Posted November 3, 2003 Leaders Posted November 3, 2003 you are using the modified version of SendMessage that i posted aren't you? with Ansii just before the word " Function " and the ByRef's replaced by ByVal's ,eg: Private Declare Ansi Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As String) As Integer '/// " Declare Ansi Function " and " ByVal lParam As String " rather than " ByRef lParam As String " Quote
*Experts* Volte Posted November 3, 2003 *Experts* Posted November 3, 2003 The 'EDIT' refers to the window class, not the name given in VB. When compiled, the name given by VB is lost (as far as I know, at least). You should set the classname to "WindowsForms10.EDIT.app1" and try that. Quote
*Gurus* Derek Stone Posted November 3, 2003 *Gurus* Posted November 3, 2003 Just to clarify the class name for a non-.NET application text box would be "EDIT", while the class name for a .NET application text box would be "WindowsForms10.EDIT.app1". Quote Posting Guidelines
homebrew311 Posted November 4, 2003 Author Posted November 4, 2003 thx a lot for all the input it really helps. I kno how to use the language to do a lot of practical things like designing a program that makes making web pages easier and wutnot but im still new to using the API in vb. sry if i get u guys frustrated. anyway wut if there were 15 textboxes? how would i choose, lets say, #7? Quote
Trancedified Posted May 18, 2004 Posted May 18, 2004 Reverse it How would you do the opposite idea: Get textbox contents from another application and put it in your own application w/out doing copy/paste w/ the mouse. Chris Quote
Recommended Posts