Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Windows 64bit (http://www.velocityreviews.com/forums/f46-windows-64bit.html)
-   -   SendInput() inconsistency between 32/64 bit function equivalents (http://www.velocityreviews.com/forums/t492527-sendinput-inconsistency-between-32-64-bit-function-equivalents.html)

=?Utf-8?B?TWFrc2lt?= 08-03-2006 05:30 PM

SendInput() inconsistency between 32/64 bit function equivalents
 
In C#, I made a program which sends Alt+Print key conbination using
SendInput() function. The function works on 32 bit WinXP. My executable
compiled for x86 also works on WinXP 64 bit. But when I use "AnyCPU" platform
target, SendInput() still sends the keys, but they are not processed. After
that, my left mouse button simulates my right one, until I press the right
button. I also tested Shift+Print and it works the same. Could it be a bug in
WinXP 64? I believe 32 and 64 bit dll versions should be identical. Anybody
knows how to fix this?

mabra 08-04-2006 09:02 AM

Re: SendInput() inconsistency between 32/64 bit function equivalents
 
Hi !

I am not a specialist on this, but made some similar things. Do do what
you described, so far I remember correctly - you have to use PInvoke and
the WIN32 API. Can you show your declarations please?

The problem could stem from declaring pointer as integer instead of IntPtr.

Just a thought,
Manfred

Maksim wrote:
> In C#, I made a program which sends Alt+Print key conbination using
> SendInput() function. The function works on 32 bit WinXP. My executable
> compiled for x86 also works on WinXP 64 bit. But when I use "AnyCPU" platform
> target, SendInput() still sends the keys, but they are not processed. After
> that, my left mouse button simulates my right one, until I press the right
> button. I also tested Shift+Print and it works the same. Could it be a bug in
> WinXP 64? I believe 32 and 64 bit dll versions should be identical. Anybody
> knows how to fix this?


=?Utf-8?B?TWFrc2lt?= 08-04-2006 05:05 PM

Re: SendInput() inconsistency between 32/64 bit function equivalen
 
At first that's what I thought, some wrong data type, but no I checked and
rewrote all PInvoke stuff to match Win32 declaration exactly, here it is:

// --------------------------->

internal enum DeviceMessageType : uint
{
Mouse = 0,
Keyboard = 1,
}

[StructLayout(LayoutKind.Sequential, Pack = 4)]
internal struct Point
{
public int X; // LONG
public int Y; // LONG
}

[StructLayout(LayoutKind.Sequential)]
internal struct MouseMessage // MOUSEINPUT
{
public Point Position; // LONG X, LONG Y
public uint MouseData; // DWORD
public uint Flags; // DWORD
public uint TimeStamp; // DWORD
public UIntPtr ExtraInfo; // ULONG_PTR
}

internal enum VirtualKey : int
{
PrintScreen = 0x2C,
Shift = 0x10,
Control = 0x11,
Alt = 0x12
}

internal enum KeyEvent : uint // DWORD
{
KeyUp = 0x0002
}

[StructLayout(LayoutKind.Sequential)]
internal struct KeyboardMessage // KEYBDINPUT
{
public ushort VirtualKey; // WORD
public ushort ScanCode; // WORD
public KeyEvent KeyEvent; // DWORD
public uint TimeStamp; // DWORD
public UIntPtr ExtraInfo; // ULONG_PTR
}

[StructLayout(LayoutKind.Explicit)]
internal struct DeviceMessageInfo // INPUT
{
[FieldOffset(0)]
public DeviceMessageType DeviceMessageType;

[FieldOffset(4)]
public MouseMessage MouseMessage;

[FieldOffset(4)]
public KeyboardMessage KeyboardMessage;

public DeviceMessageInfo(DeviceMessageType DeviceMessageType)
{
this.DeviceMessageType = DeviceMessageType;
this.MouseMessage = new MouseMessage();
this.KeyboardMessage = new KeyboardMessage();
}

public static readonly int SizeOf =
Marshal.SizeOf(typeof(DeviceMessageInfo));
}

[DllImport("User32.dll", EntryPoint = "SendInput", ExactSpelling = true)]
public static extern uint Send(uint Count, [In] DeviceMessageInfo[]
DeviceMessageInfo, int DeviceMessageInfoSize);

// <---------------------------

I really need to make it work on WinXP x64, so if you find anything wrong
with it, let me know.

"mabra" wrote:

> Hi !
>
> I am not a specialist on this, but made some similar things. Do do what
> you described, so far I remember correctly - you have to use PInvoke and
> the WIN32 API. Can you show your declarations please?
>
> The problem could stem from declaring pointer as integer instead of IntPtr.
>
> Just a thought,
> Manfred
>
> Maksim wrote:
> > In C#, I made a program which sends Alt+Print key conbination using
> > SendInput() function. The function works on 32 bit WinXP. My executable
> > compiled for x86 also works on WinXP 64 bit. But when I use "AnyCPU" platform
> > target, SendInput() still sends the keys, but they are not processed. After
> > that, my left mouse button simulates my right one, until I press the right
> > button. I also tested Shift+Print and it works the same. Could it be a bug in
> > WinXP 64? I believe 32 and 64 bit dll versions should be identical. Anybody
> > knows how to fix this?

>


mabra 08-04-2006 05:55 PM

Re: SendInput() inconsistency between 32/64 bit function equivalen
 
Hi !

I would just give the hint.

Sorry, I have never dealed with this APIs, just made some "SendMessage"
calls, which suceeds.

Best regards,
Manfred

Maksim wrote:
> At first that's what I thought, some wrong data type, but no I checked and
> rewrote all PInvoke stuff to match Win32 declaration exactly, here it is:
>
> // --------------------------->
>
> internal enum DeviceMessageType : uint
> {
> Mouse = 0,
> Keyboard = 1,
> }
>
> [StructLayout(LayoutKind.Sequential, Pack = 4)]
> internal struct Point
> {
> public int X; // LONG
> public int Y; // LONG
> }
>
> [StructLayout(LayoutKind.Sequential)]
> internal struct MouseMessage // MOUSEINPUT
> {
> public Point Position; // LONG X, LONG Y
> public uint MouseData; // DWORD
> public uint Flags; // DWORD
> public uint TimeStamp; // DWORD
> public UIntPtr ExtraInfo; // ULONG_PTR
> }
>
> internal enum VirtualKey : int
> {
> PrintScreen = 0x2C,
> Shift = 0x10,
> Control = 0x11,
> Alt = 0x12
> }
>
> internal enum KeyEvent : uint // DWORD
> {
> KeyUp = 0x0002
> }
>
> [StructLayout(LayoutKind.Sequential)]
> internal struct KeyboardMessage // KEYBDINPUT
> {
> public ushort VirtualKey; // WORD
> public ushort ScanCode; // WORD
> public KeyEvent KeyEvent; // DWORD
> public uint TimeStamp; // DWORD
> public UIntPtr ExtraInfo; // ULONG_PTR
> }
>
> [StructLayout(LayoutKind.Explicit)]
> internal struct DeviceMessageInfo // INPUT
> {
> [FieldOffset(0)]
> public DeviceMessageType DeviceMessageType;
>
> [FieldOffset(4)]
> public MouseMessage MouseMessage;
>
> [FieldOffset(4)]
> public KeyboardMessage KeyboardMessage;
>
> public DeviceMessageInfo(DeviceMessageType DeviceMessageType)
> {
> this.DeviceMessageType = DeviceMessageType;
> this.MouseMessage = new MouseMessage();
> this.KeyboardMessage = new KeyboardMessage();
> }
>
> public static readonly int SizeOf =
> Marshal.SizeOf(typeof(DeviceMessageInfo));
> }
>
> [DllImport("User32.dll", EntryPoint = "SendInput", ExactSpelling = true)]
> public static extern uint Send(uint Count, [In] DeviceMessageInfo[]
> DeviceMessageInfo, int DeviceMessageInfoSize);
>
> // <---------------------------
>
> I really need to make it work on WinXP x64, so if you find anything wrong
> with it, let me know.
>
> "mabra" wrote:
>
>> Hi !
>>
>> I am not a specialist on this, but made some similar things. Do do what
>> you described, so far I remember correctly - you have to use PInvoke and
>> the WIN32 API. Can you show your declarations please?
>>
>> The problem could stem from declaring pointer as integer instead of IntPtr.
>>
>> Just a thought,
>> Manfred
>>
>> Maksim wrote:
>>> In C#, I made a program which sends Alt+Print key conbination using
>>> SendInput() function. The function works on 32 bit WinXP. My executable
>>> compiled for x86 also works on WinXP 64 bit. But when I use "AnyCPU" platform
>>> target, SendInput() still sends the keys, but they are not processed. After
>>> that, my left mouse button simulates my right one, until I press the right
>>> button. I also tested Shift+Print and it works the same. Could it be a bug in
>>> WinXP 64? I believe 32 and 64 bit dll versions should be identical. Anybody
>>> knows how to fix this?


=?Utf-8?B?TWFrc2lt?= 08-06-2006 05:27 PM

Re: SendInput() inconsistency between 32/64 bit function equivalen
 
So anybody knows how to make SendInput() to work on WinXP x64?

"mabra" wrote:

> Hi !
>
> I would just give the hint.
>
> Sorry, I have never dealed with this APIs, just made some "SendMessage"
> calls, which suceeds.
>
> Best regards,
> Manfred
>
> Maksim wrote:
> > At first that's what I thought, some wrong data type, but no I checked and
> > rewrote all PInvoke stuff to match Win32 declaration exactly, here it is:
> >
> > // --------------------------->
> >
> > internal enum DeviceMessageType : uint
> > {
> > Mouse = 0,
> > Keyboard = 1,
> > }
> >
> > [StructLayout(LayoutKind.Sequential, Pack = 4)]
> > internal struct Point
> > {
> > public int X; // LONG
> > public int Y; // LONG
> > }
> >
> > [StructLayout(LayoutKind.Sequential)]
> > internal struct MouseMessage // MOUSEINPUT
> > {
> > public Point Position; // LONG X, LONG Y
> > public uint MouseData; // DWORD
> > public uint Flags; // DWORD
> > public uint TimeStamp; // DWORD
> > public UIntPtr ExtraInfo; // ULONG_PTR
> > }
> >
> > internal enum VirtualKey : int
> > {
> > PrintScreen = 0x2C,
> > Shift = 0x10,
> > Control = 0x11,
> > Alt = 0x12
> > }
> >
> > internal enum KeyEvent : uint // DWORD
> > {
> > KeyUp = 0x0002
> > }
> >
> > [StructLayout(LayoutKind.Sequential)]
> > internal struct KeyboardMessage // KEYBDINPUT
> > {
> > public ushort VirtualKey; // WORD
> > public ushort ScanCode; // WORD
> > public KeyEvent KeyEvent; // DWORD
> > public uint TimeStamp; // DWORD
> > public UIntPtr ExtraInfo; // ULONG_PTR
> > }
> >
> > [StructLayout(LayoutKind.Explicit)]
> > internal struct DeviceMessageInfo // INPUT
> > {
> > [FieldOffset(0)]
> > public DeviceMessageType DeviceMessageType;
> >
> > [FieldOffset(4)]
> > public MouseMessage MouseMessage;
> >
> > [FieldOffset(4)]
> > public KeyboardMessage KeyboardMessage;
> >
> > public DeviceMessageInfo(DeviceMessageType DeviceMessageType)
> > {
> > this.DeviceMessageType = DeviceMessageType;
> > this.MouseMessage = new MouseMessage();
> > this.KeyboardMessage = new KeyboardMessage();
> > }
> >
> > public static readonly int SizeOf =
> > Marshal.SizeOf(typeof(DeviceMessageInfo));
> > }
> >
> > [DllImport("User32.dll", EntryPoint = "SendInput", ExactSpelling = true)]
> > public static extern uint Send(uint Count, [In] DeviceMessageInfo[]
> > DeviceMessageInfo, int DeviceMessageInfoSize);
> >
> > // <---------------------------
> >
> > I really need to make it work on WinXP x64, so if you find anything wrong
> > with it, let me know.
> >
> > "mabra" wrote:
> >
> >> Hi !
> >>
> >> I am not a specialist on this, but made some similar things. Do do what
> >> you described, so far I remember correctly - you have to use PInvoke and
> >> the WIN32 API. Can you show your declarations please?
> >>
> >> The problem could stem from declaring pointer as integer instead of IntPtr.
> >>
> >> Just a thought,
> >> Manfred
> >>
> >> Maksim wrote:
> >>> In C#, I made a program which sends Alt+Print key conbination using
> >>> SendInput() function. The function works on 32 bit WinXP. My executable
> >>> compiled for x86 also works on WinXP 64 bit. But when I use "AnyCPU" platform
> >>> target, SendInput() still sends the keys, but they are not processed. After
> >>> that, my left mouse button simulates my right one, until I press the right
> >>> button. I also tested Shift+Print and it works the same. Could it be a bug in
> >>> WinXP 64? I believe 32 and 64 bit dll versions should be identical. Anybody
> >>> knows how to fix this?

>


WhatIThink 02-12-2010 03:55 PM

Try this
 
Try to muliplicate the values you send to sendinput by two if its on 64 bit.


All times are GMT. The time now is 03:48 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.