Click here to Skip to main content
15,918,471 members
Home / Discussions / C#
   

C#

 
AnswerRe: Window Handles and Mouse Clicks Pin
Heath Stewart5-Oct-05 8:35
protectorHeath Stewart5-Oct-05 8:35 
You can either enumerate top-leve windows by P/Invoking EnumWindows, or simply use Process.GetProcesses like so:
foreach (Process p in Process.GetProcesses())
{
  if (p.MainWindowHandle != IntPtr.Zero)
  {
    // Do something with p.MainWindowHandle - your wrapped HWND.
  }
}
To simulate a mouse click, you can get a window handle (from a top-level window handle, P/Invoke FindWindowEx[^] and post WM_LBUTTONDOWN and WM_LBUTTONUP, which you can find the values for in the Platform SDK.

You could also P/Invoke SendInput[^]. For further help on that, see the Platform SDK on MSDN[^] or search this forum for "SendInput". I have posted this solution a couple of times that I can remember in the past.

This posting is provided "AS IS" with no warranties, and confers no rights.

Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft

[My Articles] [My Blog]
GeneralRe: Window Handles and Mouse Clicks Pin
budidharma5-Oct-05 8:42
budidharma5-Oct-05 8:42 
GeneralRe: Window Handles and Mouse Clicks Pin
budidharma6-Oct-05 6:57
budidharma6-Oct-05 6:57 
Questionhow handle objects and code of setup forms? Pin
Anonymous5-Oct-05 8:26
Anonymous5-Oct-05 8:26 
QuestionAccessing dBase files with C# Pin
TheMajorRager5-Oct-05 8:02
TheMajorRager5-Oct-05 8:02 
AnswerRe: Accessing dBase files with C# Pin
Heath Stewart5-Oct-05 9:15
protectorHeath Stewart5-Oct-05 9:15 
GeneralRe: Accessing dBase files with C# Pin
TheMajorRager5-Oct-05 11:37
TheMajorRager5-Oct-05 11:37 
AnswerRe: Accessing dBase files with C# Pin
Heath Stewart5-Oct-05 11:40
protectorHeath Stewart5-Oct-05 11:40 
GeneralRe: Accessing dBase files with C# Pin
TheMajorRager5-Oct-05 12:14
TheMajorRager5-Oct-05 12:14 
GeneralRe: Accessing dBase files with C# Pin
TheMajorRager5-Oct-05 13:54
TheMajorRager5-Oct-05 13:54 
Questioncheckbox ques Pin
ter815-Oct-05 7:13
susster815-Oct-05 7:13 
GeneralRe: checkbox ques Pin
Guffa5-Oct-05 8:57
Guffa5-Oct-05 8:57 
AnswerRe: checkbox ques Pin
Heath Stewart5-Oct-05 9:10
protectorHeath Stewart5-Oct-05 9:10 
QuestionChanging the colour & font of (null) value datagrid entries Pin
Red_Wizard_Shot_The_Food5-Oct-05 6:58
Red_Wizard_Shot_The_Food5-Oct-05 6:58 
AnswerRe: Changing the colour & font of (null) value datagrid entries Pin
Heath Stewart5-Oct-05 8:43
protectorHeath Stewart5-Oct-05 8:43 
QuestionAdding a chart to my form Pin
james3775-Oct-05 6:25
james3775-Oct-05 6:25 
AnswerRe: Adding a chart to my form Pin
enjoycrack5-Oct-05 14:24
enjoycrack5-Oct-05 14:24 
GeneralRe: Adding a chart to my form Pin
james3776-Oct-05 7:16
james3776-Oct-05 7:16 
GeneralRe: Adding a chart to my form Pin
enjoycrack6-Oct-05 10:43
enjoycrack6-Oct-05 10:43 
Questionpaste/insert text at cursor position in a rich text box Pin
Agyeman5-Oct-05 6:13
Agyeman5-Oct-05 6:13 
AnswerRe: paste/insert text at cursor position in a rich text box Pin
Heath Stewart5-Oct-05 8:39
protectorHeath Stewart5-Oct-05 8:39 
QuestionSocket.BeginSend and AsyncCallBack Delegate problems Pin
Lilli Alexis5-Oct-05 5:57
Lilli Alexis5-Oct-05 5:57 
Questionpaste/insert text at cursor position in a rich text box Pin
Agyeman5-Oct-05 5:34
Agyeman5-Oct-05 5:34 
AnswerRe: paste/insert text at cursor position in a rich text box Pin
mav.northwind5-Oct-05 8:24
mav.northwind5-Oct-05 8:24 
GeneralRe: paste/insert text at cursor position in a rich text box Pin
Agyeman5-Oct-05 8:34
Agyeman5-Oct-05 8:34 

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.