エラーはかなり一般的なようですが、ここにあります:
eCA1901 P/Invoke declarations should be portable As it is declared in your code, parameter 'dwExtraInfo' of P/Invoke 'NativeMethods.mouse_event(int, int, int, int, int)' will be 4 bytes wide on 64-bit platforms. This is not correct, as the actual native declaration of this API indicates it should be 8 bytes wide on 64-bit platforms. Consult the MSDN Platform SDK documentation for help determining what data type should be used instead of 'int'
コード行は次のとおりです。
[System.Runtime.InteropServices.DllImport("user32.dll")]
internal static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
今、私は64ビットと互換性のある、または両方で使用できるUintまたは何かに変更しようとしました(Pintまたは何か、名前を思い出せません)。
しかし、Int から Uint などに変更すると、次のコードが壊れます。
if (click == "Left")
{
NativeMethods.mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, MousePosition.X, MousePosition.Y, MousePosition.X, MousePosition.Y);
}
if (click == "Right")
{
NativeMethods.mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, MousePosition.X, MousePosition.Y, MousePosition.X, MousePosition.Y);
}
if (down == "Left"+"True")
{
NativeMethods.mouse_event(MOUSEEVENTF_LEFTDOWN , MousePosition.X, MousePosition.Y, MousePosition.X, MousePosition.Y);
}
if (down == "Right"+"True")
{
NativeMethods.mouse_event(MOUSEEVENTF_RIGHTDOWN, MousePosition.X, MousePosition.Y, MousePosition.X, MousePosition.Y);
}
それが言うように(intから変換できません...)そこにあるすべてのものに(uint)を使用すると「うまくいく」ようですが、それが最適な方法だとは思いません。
MouseEvent コードは次のとおりです。
private const int MOUSEEVENTF_LEFTDOWN = 0x02;
private const int MOUSEEVENTF_LEFTUP = 0x04;
private const int MOUSEEVENTF_RIGHTDOWN = 0x08;
private const int MOUSEEVENTF_RIGHTUP = 0x10;
また、それらを Uint に変更してみました。
今、私が Uint について話しているのは、それを変更する必要があることを読んだからです。Uint が Int と比べて何なのか、私にはまったくわかりません。
より良い方法がある場合、または私が間違っている場合は、教えてください。