Click here to Skip to main content
15,902,636 members
Home / Discussions / Design and Architecture
   

Design and Architecture

 
GeneralRe: XNA Sprite shooting a bullet, what is a good design for this? Pin
venomation26-Jan-10 5:15
venomation26-Jan-10 5:15 
QuestionBook recommendation Pin
hammerstein0518-Jan-10 11:16
hammerstein0518-Jan-10 11:16 
AnswerRe: Book recommendation Pin
Jimmanuel18-Jan-10 13:31
Jimmanuel18-Jan-10 13:31 
GeneralRe: Book recommendation Pin
hammerstein0518-Jan-10 16:22
hammerstein0518-Jan-10 16:22 
QuestionAzure is cool but makes me nervous Pin
Ray Cassick21-Dec-09 4:57
Ray Cassick21-Dec-09 4:57 
AnswerRe: Azure is cool but makes me nervous Pin
Eddy Vluggen21-Dec-09 6:12
professionalEddy Vluggen21-Dec-09 6:12 
QuestionHow to control another application Pin
cullyk11-Dec-09 16:13
cullyk11-Dec-09 16:13 
AnswerRe: How to control another application Pin
Luc Pattyn11-Dec-09 17:35
sitebuilderLuc Pattyn11-Dec-09 17:35 
Hi,

I would do such things (and most others) in C#.
For keyboard input, .NET has a SendKeys class.
For mouse input, you would need P/Invoke to call native code in Windows DLL libraries, such as
[DllImport("user32.dll", CallingConvention=CallingConvention.StdCall, SetLastError=true)]
public static extern IntPtr SendInput(int count, ref INPUT input, int size);

[DllImport("user32.dll", CallingConvention=CallingConvention.StdCall, SetLastError=true)]
public static extern IntPtr SendInput(int count, ref INPUT2 input, int size);

[DllImport("user32.dll", CallingConvention = CallingConvention.StdCall, SetLastError = true)]
public static extern IntPtr SetCursorPos(int x, int y);

public struct MOUSEINPUT {
    public int dx;
    public int dy;
    public int mouseData;
    public int dwFlags;
    public int time;
    public IntPtr dwExtraInfo;
}

public struct INPUT {
    public uint type;
    public MOUSEINPUT mi;
}

public struct INPUT2 {
    public uint type1;
    public MOUSEINPUT mi1;
    public uint type2;
    public MOUSEINPUT mi2;
}


Now most of this is considered a hack as you can't do it reliably: it suffices for another application, window or control to suddenly get focus or being shown on the display, for your keys and/or mouse clicks to be intercepted by them (and maybe causing havoc).

The better way is to use application interfaces, if they exist.
Example: there are "Primary Interop Assemblies" for controlling Office from .NET

Smile | :)

Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]

I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages


GeneralRe: How to control another application Pin
cullyk11-Dec-09 18:02
cullyk11-Dec-09 18:02 
QuestionBest way to share the load on a project for two developers? Pin
buzzwright3-Dec-09 11:36
buzzwright3-Dec-09 11:36 
AnswerRe: Best way to share the load on a project for two developers? Pin
Eddy Vluggen11-Dec-09 11:40
professionalEddy Vluggen11-Dec-09 11:40 
Questiongood production software should contain some or most of the following? Pin
boyGenius22-Nov-09 3:02
boyGenius22-Nov-09 3:02 
QuestionDynamic filters in n-tier applications - how to implement? Pin
midix18-Nov-09 5:13
midix18-Nov-09 5:13 
QuestionDocument Management Syatem Pin
Odd Arne17-Nov-09 7:16
Odd Arne17-Nov-09 7:16 
AnswerRe: Document Management Syatem Pin
Sir Dot Net19-Nov-09 7:58
Sir Dot Net19-Nov-09 7:58 
AnswerRe: Document Management Syatem Pin
Robin_Roy2-Dec-09 18:42
Robin_Roy2-Dec-09 18:42 
AnswerRe: Document Management Syatem Pin
Eddy Vluggen6-Dec-09 2:11
professionalEddy Vluggen6-Dec-09 2:11 
AnswerRe: Document Management Syatem Pin
puri keemti7-Dec-09 0:34
puri keemti7-Dec-09 0:34 
AnswerRe: Document Management Syatem Pin
David Lario22-Jan-10 9:12
David Lario22-Jan-10 9:12 
QuestionDoes a developer need local administrator rights? Pin
Windswept13-Nov-09 21:55
Windswept13-Nov-09 21:55 
AnswerRe: Does a developer need local administrator rights? Pin
Pete O'Hanlon15-Nov-09 9:36
mvePete O'Hanlon15-Nov-09 9:36 
GeneralRe: Does a developer need local administrator rights? Pin
Windswept16-Nov-09 9:32
Windswept16-Nov-09 9:32 
AnswerRe: Does a developer need local administrator rights? Pin
Ian Shlasko16-Nov-09 10:41
Ian Shlasko16-Nov-09 10:41 
GeneralRe: Does a developer need local administrator rights? Pin
Windswept16-Nov-09 21:41
Windswept16-Nov-09 21:41 
GeneralRe: Does a developer need local administrator rights? Pin
Ian Shlasko17-Nov-09 3:32
Ian Shlasko17-Nov-09 3:32 

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.