2

たくさんのスクリーンショットを連続して作成するプログラムを作成しようとしています。スクリーンショットを何度も作り直すのではなく、画面間の変更のみを見つけたいのです。

これを行うために、画面レベルで GetUpdateRect() メソッドを使用しました。残念ながら、正しいデータが得られません。私はC#に比較的慣れていないので、何か間違ったことをしたと確信しています:P

このコードはすべての画面変更をログに記録する必要がありますが、代わりに [0,0,0,0] を返します。

    [DllImport("User32.dll")]
    public static extern IntPtr GetDesktopWindow();
    [DllImport("User32.dll")]
    public static extern bool GetUpdateRect(IntPtr hWnd, out Rectangle lpRect, bool bErase);

    static void Main()
    {
        Rectangle updateRect;
        GetUpdateRect(GetDesktopWindow(), out updateRect, false);
        while (true)
        {
            Thread.Sleep(100);
            Console.WriteLine(updateRect);
        }
    }

すべてのヘルプは大歓迎です! :D

4

1 に答える 1

1

Try using the code listed on Pinvoke.Net to import the RECT type instead of using System.Drawing.Rectangle (as @Alvin Wong suggests) and changing the signature of the GetUpdateRect() method to match.

HTH

于 2013-01-30T13:48:51.143 に答える