2012-02-01 8 views
3

私がX座標とY座標を知っている場合、Windows APIや、マウスポインタをその点に移動させるために使用できる.Netの技術がありますか?マウスを強制的に動かせますか?

マウスを動かすようなツールがあるので、何かがあるはずです。しかし、これらのAPIが.NETで簡単にアクセスできるかどうかはわかりません。 ありますか?

もちろん、WPF、.Net、Windowsを想定してください。

ソリューション

public Window1() 
{ 
    InitializeComponent(); 
    NativeMethods.SetCursorPos(300, 300); 
} 
public partial class NativeMethods 
{ 
    [System.Runtime.InteropServices.DllImportAttribute("user32.dll", 
     EntryPoint = "SetCursorPos")] 
    [return: System.Runtime.InteropServices.MarshalAsAttribute 
     (System.Runtime.InteropServices.UnmanagedType.Bool)] 
    public static extern bool SetCursorPos(int X, int Y); 
} 

答えて

2

宣言インポート:。

[DllImport("user32.dll")] 
static extern bool SetCursorPos(int X, int Y); 

そして、このように使用:

SetCursorPos(x, y); 
0

あなたはP /呼び出しを使用することに反対していますか?そうでない場合、これがで引くにはかなりシンプルなAPIである。このような

http://pinvoke.net/default.aspx/user32/SetCursorPos.html

[DllImport("user32.dll")] 
static extern bool SetCursorPos(int X, int Y); 
関連する問題