After spending a long time getting the following code (sends text to a non-VB application's textbox, then presses enter) to work in VB6 i tried to convert it to VB.NET without success. Is there anyone who could please help me by giving the VB.NET translation for the following VB6 code. Thanks
Code:Option Explicit Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private 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 Private Declare Function PostMessage Lib "user32.dll" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Private Declare Function SendMessageStr Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As String) As Long Private Const WM_SETTEXT As Long = &HC Private Const VK_RETURN As Long = &HD Private Const WM_KEYDOWN = &H100 Private Sub Form_Load() Dim hNotepad, hNotepadb, hNotepadc, hNotepadd, hNotepade as long Dim lRetVal, lretval2 As Long hNotepadb = FindWindow(CLASS, WINDOW CAPTION) hNotepadc = FindWindowEx(hNotepadb, 0&, CLASS, vbNullString) hNotepadd = FindWindowEx(hNotepadc, 0&, "edit", vbNullString) lRetVal = SendMessageStr(hNotepadd, WM_SETTEXT, 0&, ByVal TEXT) hNotepade = FindWindowEx(hNotepadb, 0&, "button", "&activate") lretval2 = PostMessage(hNotepadb, WM_KEYDOWN, VK_RETURN, 0&) End Sub


Reply With Quote