Code Monkey home page Code Monkey logo

Comments (5)

dahall avatar dahall commented on July 24, 2024 1

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.

dahall avatar dahall commented on July 24, 2024 1

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.

dahall avatar dahall commented on July 24, 2024 1

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.

dahall avatar dahall commented on July 24, 2024

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.

oising avatar oising commented on July 24, 2024

Nope, EventType is always 0.

from vanara.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.