Nighty Posted March 20, 2006 Posted March 20, 2006 Hi I want to send some keys to a Notepad. It work in VB6, but it wont work with VB.net. I test SendMessage PostMessage, ...... Have anyone an example written in vb.net that sends keys to a notepad that have not the focus ? (Notepad=MyDemoAppliction, later I will send Keys to another Exe) regards Nighty :cool: Quote
Jay1b Posted March 21, 2006 Posted March 21, 2006 Cant say i have a clue about how to do that... But have you tried importing your VB6 app? Then look at the imported code? May give you a few pointers. Quote
Administrators PlausiblyDamp Posted March 21, 2006 Administrators Posted March 21, 2006 If you are converting a VB6 declare statement remember that under .Net all Longs are now Integer and all Integers are now Short. Also As Any is no longer supported and needs to be declared as the correct parameter types. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Sweetve13 Posted May 24, 2006 Posted May 24, 2006 hwnd gets that handle for the notepad window. x gets tha handle for the control to send messages to (the white space). Hope this helps. Sample Code: ------------ 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 FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Integer, ByVal hWnd2 As Integer, ByVal lpsz1 As String, ByVal lpsz2 As String) As Integer Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer Public Const WM_CHAR = &H102 ' assuming you have notepad open. Dim hwnd As Integer = FindWindow(vbNullString, "Untitled - NotePad") Dim x As Integer = FindWindowEx(hwnd, 0, "Edit", vbNullString) ' send some keys SendMessage(x, WM_CHAR, Keys.C, 0) SendMessage(x, WM_CHAR, Keys.L, 0) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.