Red Gate forums :: View topic - Send key presses to background application window
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
PInvoke.Net
PInvoke.Net forum

Send key presses to background application window

Search in PInvoke.Net forum
Post new topic   Reply to topic
Jump to:  
Author Message
Hooch



Joined: 29 May 2011
Posts: 1

PostPosted: Sun May 29, 2011 10:42 am    Post subject: Send key presses to background application window Reply with quote

Hello.
Can you help me to transfer that code to C#?

Code:
    HWND Notepad = FindWindowEx( GetDesktopWindow( ), 0, "Notepad", 0 );
   
    SendMessage( GetDlgItem( Notepad, MB_TYPEMASK ), WM_SETTEXT, 0, (LPARAM)"Hello Notepad, what's up?" );


Thank you in advance

I want to send key presses to background window.
I don't want to use SendKeys.Send because I want that window to be in background.
SendKeys requires that window is active.
Back to top
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6667

PostPosted: Tue May 31, 2011 9:46 am    Post subject: Reply with quote

You can find the signatures for both functions on http://www.pinvoke.net. Once you insert the signature suggested by PInvoke, you can use both native functions from C#, for example:
Code:
    [DllImport("User32.DLL")]
    public static extern int SendMessage(IntPtr hWnd, UInt32 Msg, Int32 wParam, Int32 lParam);
You'll also want to read the notes carefully on the PInvoke page for that function.
Back to top
View user's profile Send private message
twain



Joined: 14 Nov 2011
Posts: 2

PostPosted: Fri Nov 25, 2011 6:05 am    Post subject: Reply with quote

Well, I too had been recently working on this one. First of all, you need to search for the signatures for the two functions. The link for that has been given here by Brian. After you insert the signature, you can effectively use both of the native functions in C#. Has anyone used Port 25? Are they good in email delivery solutions?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group