Click here to Skip to main content
15,914,111 members
Home / Discussions / C#
   

C#

 
GeneralRe: A silly socket question Pin
S. Senthil Kumar4-Mar-05 11:17
S. Senthil Kumar4-Mar-05 11:17 
GeneralRe: A silly socket question Pin
Sebastian Schneider7-Mar-05 1:50
Sebastian Schneider7-Mar-05 1:50 
GeneralTroubles with dynamically created WUC Pin
see074-Mar-05 9:29
see074-Mar-05 9:29 
GeneralRe: Troubles with dynamically created WUC Pin
see077-Mar-05 5:54
see077-Mar-05 5:54 
GeneralRe: Troubles with dynamically created WUC Pin
see077-Mar-05 7:11
see077-Mar-05 7:11 
QuestionHow to catch system KeyDown or Mousemove events. Pin
491524-Mar-05 8:48
491524-Mar-05 8:48 
AnswerRe: How to catch system KeyDown or Mousemove events. Pin
S. Senthil Kumar4-Mar-05 9:03
S. Senthil Kumar4-Mar-05 9:03 
GeneralUsing SendMessage and PostMessage APIs Pin
Guinness4Strength4-Mar-05 8:42
Guinness4Strength4-Mar-05 8:42 
I'm attempting to send Keyboard and Mouse events to windows other than my own using the SendMessage and/or PostMessage APIs. I've looked pretty closely at the messageboards here and am still having a hell of a time getting it to work.

[DllImport("User32.dll", CharSet = CharSet.Auto)]
private static extern IntPtr FindWindow(string winClass, string WinName);
[DllImport("User32.dll", CharSet = CharSet.Auto)]
private static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
[DllImport("User32.dll", CharSet = CharSet.Auto)]
private static extern IntPtr PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);

private const uint  WM_ACTIVATEAPP=0x001C;
private const uint  WM_KEYDOWN= 0x0100;
private const uint  WM_KEYUP=0x0101;
private const uint  WM_SETFOCUS=0x0007;

private void CheckWindows()
{
	IntPtr WinHandle=IntPtr.Zero;
	WinHandle = FindWindow(null,"Untitled - Notepad");
	if(WinHandle!=IntPtr.Zero)
	{
		SendMessage(WinHandle,WM_ACTIVATEAPP,(IntPtr)1,IntPtr.Zero);		
		SendMessage(WinHandle,WM_SETFOCUS,IntPtr.Zero,IntPtr.Zero);
		SendMessage(WinHandle,WM_KEYDOWN,(IntPtr)0x31,(IntPtr)1);
		SendMessage(WinHandle,WM_KEYUP,(IntPtr)0x31,(IntPtr)1);
	}
}

At this point I assume I'm not sending the correct messages, but I was hoping someone could point me in the right direction.
GeneralRe: Using SendMessage and PostMessage APIs Pin
Judah Gabriel Himango4-Mar-05 12:01
sponsorJudah Gabriel Himango4-Mar-05 12:01 
GeneralRe: Using SendMessage and PostMessage APIs Pin
Guinness4Strength5-Mar-05 8:20
Guinness4Strength5-Mar-05 8:20 
GeneralRe: Using SendMessage and PostMessage APIs Pin
mav.northwind4-Mar-05 21:52
mav.northwind4-Mar-05 21:52 
GeneralRe: Using SendMessage and PostMessage APIs Pin
Guinness4Strength5-Mar-05 8:16
Guinness4Strength5-Mar-05 8:16 
GeneralLoading an assembly dynamically and using types/functions in it Pin
Bojan Rajkovic4-Mar-05 8:16
Bojan Rajkovic4-Mar-05 8:16 
GeneralRe: Loading an assembly dynamically and using types/functions in it Pin
S. Senthil Kumar4-Mar-05 9:08
S. Senthil Kumar4-Mar-05 9:08 
GeneralRunning an IO application on a network Pin
TOVB4-Mar-05 7:41
sussTOVB4-Mar-05 7:41 
GeneralRe: Running an IO application on a network Pin
Joel Lucsy4-Mar-05 8:40
Joel Lucsy4-Mar-05 8:40 
GeneralInstalling a service without using ServiceProcessInstaller/ServiceInstaller Pin
Lakitu4-Mar-05 5:18
Lakitu4-Mar-05 5:18 
Generalping use too long time Pin
haha200014-Mar-05 4:47
haha200014-Mar-05 4:47 
GeneralRe: ping use too long time Pin
Dave Kreskowiak4-Mar-05 7:34
mveDave Kreskowiak4-Mar-05 7:34 
GeneralRe: ping use too long time Pin
haha200014-Mar-05 15:22
haha200014-Mar-05 15:22 
GeneralRe: ping use too long time Pin
haha200014-Mar-05 15:39
haha200014-Mar-05 15:39 
GeneralRe: ping use too long time Pin
Dave Kreskowiak4-Mar-05 16:15
mveDave Kreskowiak4-Mar-05 16:15 
GeneralRe: ping use too long time Pin
haha200015-Mar-05 6:08
haha200015-Mar-05 6:08 
GeneralRe: ping use too long time Pin
Dave Kreskowiak5-Mar-05 6:17
mveDave Kreskowiak5-Mar-05 6:17 
QuestionAuthorisation Code Ideas? Pin
Tom John4-Mar-05 3:18
Tom John4-Mar-05 3:18 

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.