Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

  • Leaders
Posted
   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

Posted
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)
  • *Gurus*
Posted
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.
  • Leaders
Posted

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 "

  • *Experts*
Posted
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.
Posted
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?
  • 6 months later...
Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...