Comments (5)
Thanks for finding this. I think the problem lies in aligning the structure to 4 byte boundaries. I have updated the code and will test shortly to confirm I've fixed the problem and then will report back. While I understand the PInvoke definition, it is not aligned well to the API code in that they removed the union. However, it did alert me to the boundary as they made it explicit.
from vanara.
Thank you. After trying a few methods from the link you shared and trying more of mine, I've determined that there is nothing very clean about either. I'm building a function by function test console app so I can work out all the bugs. I'll have a fully working wincon.h equivalent in the next day or so.
from vanara.
After a lot of toil, I believe what is pushed is the only complete, fully functional and fully tested WinCon p/invoke solution on the web. I found so many examples across the web that had some parts working, and others just wrong. I'll push in the next day or so as version v2.3.6. Thanks for alerting me to this section's incompleteness. I hope it helps your work.
from vanara.
Would you plug this structure into your project and confirm it works?
[StructLayout(LayoutKind.Explicit)]
public struct INPUT_RECORD
{
/// <summary>
/// <para>A handle to the type of input event and the event record stored in the <c>Event</c> member.</para>
/// <para>This member can be one of the following values.</para>
/// <para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// </listheader>
/// <item>
/// <term>FOCUS_EVENT 0x0010</term>
/// <term>The Event member contains a FOCUS_EVENT_RECORD structure. These events are used internally and should be ignored.</term>
/// </item>
/// <item>
/// <term>KEY_EVENT 0x0001</term>
/// <term>The Event member contains a KEY_EVENT_RECORD structure with information about a keyboard event.</term>
/// </item>
/// <item>
/// <term>MENU_EVENT 0x0008</term>
/// <term>The Event member contains a MENU_EVENT_RECORD structure. These events are used internally and should be ignored.</term>
/// </item>
/// <item>
/// <term>MOUSE_EVENT 0x0002</term>
/// <term>The Event member contains a MOUSE_EVENT_RECORD structure with information about a mouse movement or button press event.</term>
/// </item>
/// <item>
/// <term>WINDOW_BUFFER_SIZE_EVENT 0x0004</term>
/// <term>
/// The Event member contains a WINDOW_BUFFER_SIZE_RECORD structure with information about the new size of the console screen buffer.
/// </term>
/// </item>
/// <item/>
/// <item/>
/// <item/>
/// </list>
/// </para>
/// </summary>
[FieldOffset(0)]
public EVENT_TYPE EventType;
/// <summary>
/// The event information. The format of this member depends on the event type specified by the <c>EventType</c> member.
/// </summary>
[FieldOffset(4)]
public INPUT_RECORD_EVENT Event;
/// <summary>The event union.</summary>
[StructLayout(LayoutKind.Explicit)]
public struct INPUT_RECORD_EVENT
{
/// <summary>The key event</summary>
[FieldOffset(0)]
public KEY_EVENT_RECORD KeyEvent;
/// <summary>The mouse event</summary>
[FieldOffset(0)]
public MOUSE_EVENT_RECORD MouseEvent;
/// <summary>The window buffer size event</summary>
[FieldOffset(0)]
public WINDOW_BUFFER_SIZE_RECORD WindowBufferSizeEvent;
/// <summary>The menu event</summary>
[FieldOffset(0)]
public MENU_EVENT_RECORD MenuEvent;
/// <summary>The focus event</summary>
[FieldOffset(0)]
public FOCUS_EVENT_RECORD FocusEvent;
}
}
from vanara.
Nope, EventType is always 0.
from vanara.
Related Issues (20)
- IP_ADDRESS_PREFIX size seems wrong
- ShowContextMenu show Shell Context Menu but with no text and no icon HOT 3
- ShellItemPropertyStore do not update even if the property has already changed HOT 5
- Update DOT11_PHY_TYPE enumeration
- can't use lvitem struct in SendMessage for listview HOT 1
- ShellItemImages.GetImageAsync might throw NullReferenceException HOT 3
- Using char[] in place of StringBuilder HOT 2
- DPI_AWARENESS_CONTEXT enum values missing HOT 2
- Can't use the handle to read vhdx HOT 2
- `HRESULT.ToString()` is not thread-safe due to mutable global state. HOT 2
- Usage of `LibraryImport` instead of `DllImport` HOT 1
- RtlGetVersion not found in NtDll HOT 6
- A great project! HOT 1
- #nullableenabled brunch is not being merged into master HOT 4
- Kernel32.FILE_ID_128.Identifier returns incorrect values
- [Bug] MB_GetString make exe crashed and ExitCode is 3221226356 (0xc0000374) HOT 2
- RobiniaDocs API Explorer HOT 1
- Can not GetLastError HOT 1
- CM_REGISTER_NOTIFICATION callback: Incomplete eventData.u.DeviceInstance.InstanceId HOT 2
- FindNextPrinterChangeNotification SafePRINTER_NOTIFY_INFO is invalid HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vanara.