Click here to Skip to main content
15,884,986 members
Home / Discussions / C#
   

C#

 
AnswerRe: get an indication when a control added to a pnel in CF 3.5 Pin
Luc Pattyn20-Apr-11 1:13
sitebuilderLuc Pattyn20-Apr-11 1:13 
QuestionLists should not accept duplicate user names. Pin
DivyaReddyM20-Apr-11 0:50
DivyaReddyM20-Apr-11 0:50 
AnswerRe: Lists should not accept duplicate user names. Pin
Wayne Gaylard20-Apr-11 1:06
professionalWayne Gaylard20-Apr-11 1:06 
AnswerRe: Lists should not accept duplicate user names. Pin
John-ph20-Apr-11 1:09
John-ph20-Apr-11 1:09 
GeneralRe: Lists should not accept duplicate user names. Pin
DivyaReddyM20-Apr-11 1:23
DivyaReddyM20-Apr-11 1:23 
GeneralRe: Lists should not accept duplicate user names. Pin
Alan Balkany20-Apr-11 3:52
Alan Balkany20-Apr-11 3:52 
GeneralRe: Lists should not accept duplicate user names. Pin
Prasanta_Prince20-Apr-11 21:58
Prasanta_Prince20-Apr-11 21:58 
QuestionSendMessage API and WM_PASTE Pin
John-ph19-Apr-11 19:20
John-ph19-Apr-11 19:20 
I have been trying to write the clipboard content to an external windows application (currently running process) from a C#(WPF) application using SendMessage API and WM_PASTE. Can't get it work. Here is the sample code

public const int WM_PASTE = 0x0302;

[DllImport("User32.dll")]
public static extern Int32 FindWindow(String lpClassName,String lpWindowName);

[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern int SendMessage(int hWnd, int msg, int wParam, IntPtr lParam);

private void btn_Click(object sender, System.EventArgs e)
{
	int hwnd=0;
	hwnd = FindWindow(null, "Untitled - Notepad");

	if (hwnd != 0)
	{
		Clipboard.SetText("sample text from clipboard");
		hwnd = FindWindow(null, "Untitled - Notepad");
		SendMessage(hwnd, WM_PASTE, 0, IntPtr.Zero);
	}
}


Note: have to Notepad app opened to test the code

tried some other possible combinations

SendMessage, WM_PASTE<br />
SendMessage, WM_CHAR<br />
PostMessage, WM_PASTE<br />
PostMessage, WM_CHAR


An alternate way to send keystrokes to an extern app using SendMessage and PostMessage

SendMessage, (WM_KEYDOWN, WM_KEYUP) For CTRL+V<br />
PostMessage, (WM_KEYDOWN, WM_KEYUP) For CTRL+V


Windows.System.Forms.SendKeys.SendWait("^V") -> works but not always

any idea?
- Regards -
   J O N


     A good thing is a bad thing if it keeps you from the best thing. - Dr. Adrian Rogers


modified on Wednesday, April 20, 2011 6:17 AM

AnswerRe: SendMessage API and WM_PASTE Pin
John-ph19-Apr-11 22:43
John-ph19-Apr-11 22:43 
AnswerRe: SendMessage API and WM_PASTE Pin
John-ph20-Apr-11 0:23
John-ph20-Apr-11 0:23 
QuestionSmart Card ACOS3-24 1.07.18 [modified] Pin
Ari Astika19-Apr-11 17:41
Ari Astika19-Apr-11 17:41 
AnswerRe: Smart Card ACOS3-24 1.07.18 Pin
OriginalGriff19-Apr-11 21:18
mveOriginalGriff19-Apr-11 21:18 
GeneralRe: Smart Card ACOS3-24 1.07.18 Pin
Ari Astika19-Apr-11 21:30
Ari Astika19-Apr-11 21:30 
GeneralRe: Smart Card ACOS3-24 1.07.18 Pin
OriginalGriff19-Apr-11 21:35
mveOriginalGriff19-Apr-11 21:35 
GeneralRe: Smart Card ACOS3-24 1.07.18 Pin
Ari Astika19-Apr-11 21:39
Ari Astika19-Apr-11 21:39 
QuestionQuestion about Weak Events... Pin
SledgeHammer0119-Apr-11 7:51
SledgeHammer0119-Apr-11 7:51 
AnswerRe: Question about Weak Events... Pin
David198719-Apr-11 7:58
David198719-Apr-11 7:58 
GeneralRe: Question about Weak Events... Pin
SledgeHammer0119-Apr-11 8:05
SledgeHammer0119-Apr-11 8:05 
GeneralRe: Question about Weak Events... Pin
David198719-Apr-11 8:32
David198719-Apr-11 8:32 
AnswerRe: Question about Weak Events... Pin
DaveyM6919-Apr-11 8:42
professionalDaveyM6919-Apr-11 8:42 
GeneralRe: Question about Weak Events... Pin
SledgeHammer0119-Apr-11 10:06
SledgeHammer0119-Apr-11 10:06 
GeneralRe: Question about Weak Events... Pin
DaveyM6919-Apr-11 12:13
professionalDaveyM6919-Apr-11 12:13 
GeneralRe: Question about Weak Events... Pin
SledgeHammer0119-Apr-11 12:27
SledgeHammer0119-Apr-11 12:27 
GeneralRe: Question about Weak Events... Pin
Mark198619-Apr-11 19:36
Mark198619-Apr-11 19:36 
QuestionHow To Use a C Libray in your C# Program Pin
Andy20219-Apr-11 0:43
Andy20219-Apr-11 0:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.