I have started a project under the ahkscript GitHub group as a central repository for definitions of Windows Structures.
With HotkeyIt's excellent _Struct greatly simplifying the process of dealing with the results of DllCall, OnMessage etc, as long as you know how to define the _Struct correctly, it seems wise to have a central repo so we only ever need to correctly transcribe each Structure once
That way, once we build up a decent library, playing around with Windows APIs and Messages becomes a lot more accessible, with less bugs due to incorrect bitwise ops.
GitHub Page
WinStructs - Windows Structure definitions for _Struct
Re: WinStructs - Windows Structure definitions for _Struct
Yes interesting idea!
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
Re: WinStructs - Windows Structure definitions for _Struct
Please speak now if you think the name is non-descriptive etc...
I think it works though? I kind of like the allusion to "Instructs" as it would also serve as a reference material, of sorts.
Let me be clear though that I am NOT planning on mass going through Windows and populating this list.
I already have enough huge-scope projects on the boil, I don't need another. This, for me, is more about giving something back to the community after all my API questionings recently
At least then, poor HotkeyIt only gets bugged once about the ins and outs of a particular set of API calls
I think it works though? I kind of like the allusion to "Instructs" as it would also serve as a reference material, of sorts.
Let me be clear though that I am NOT planning on mass going through Windows and populating this list.
I already have enough huge-scope projects on the boil, I don't need another. This, for me, is more about giving something back to the community after all my API questionings recently
At least then, poor HotkeyIt only gets bugged once about the ins and outs of a particular set of API calls
Re: WinStructs - Windows Structure definitions for _Struct
LibStruct ?
AHKStructs ?
Structs.ahk ?
AHKStructs ?
Structs.ahk ?
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
Re: WinStructs - Windows Structure definitions for _Struct
Not a lib, just text strings.joedf wrote:LibStruct ?
_Struct already has an AHKStructs file for AHK structures, so too confusing.joedf wrote:AHKStructs ?
A little too broad maybe?joedf wrote:Structs.ahk ?
I think it would be wise to limit the scope to official MS APIs.
If Structs were needed for other APIs, I think they should belong in one project per API. Thoughts?
Re: WinStructs - Windows Structure definitions for _Struct
WinStructs now has a new friend!
AHK-SizeOf-Checker
(Requires compiler from Visual Studio)
This library can create and compile C code in order to perform a check that the size of a structure created with _Struct matches the size of the struct in actual C code
ie it checks whether sizeof(SOME_STRUCT) in AHK (ie using the sizeof command that comes with _Struct) equals sizeof(SOME_STRUCT) in a compiled C++ executable (ie using the sizeof() macro in C++)
This way, at least we have some way of vaguely validating that the Struct definitions in WinStructs are correct (And potentially also exposing bugs in _Struct)
So, for example, performing a check on RAWINPUTDEVICE would generate the following C code, compile and execute it:
Whereas to check HIDP_BUTTON_CAPS, you need to also tell it that HidUsage.h and Hidpi.h are required, which would generate the following code:
AHK-SizeOf-Checker
(Requires compiler from Visual Studio)
This library can create and compile C code in order to perform a check that the size of a structure created with _Struct matches the size of the struct in actual C code
ie it checks whether sizeof(SOME_STRUCT) in AHK (ie using the sizeof command that comes with _Struct) equals sizeof(SOME_STRUCT) in a compiled C++ executable (ie using the sizeof() macro in C++)
This way, at least we have some way of vaguely validating that the Struct definitions in WinStructs are correct (And potentially also exposing bugs in _Struct)
So, for example, performing a check on RAWINPUTDEVICE would generate the following C code, compile and execute it:
Code: Select all
#include <iostream>
#include <windows.h>
int main()
{
std::cout << sizeof(RAWINPUTDEVICE) << std::endl;
return 0;
}
Code: Select all
#include <iostream>
#include <windows.h>
#include <HidUsage.h>
#include <Hidpi.h>
int main()
{
std::cout << sizeof(HIDP_BUTTON_CAPS) << std::endl;
return 0;
}
Re: WinStructs - Windows Structure definitions for _Struct
IMPORTANT ANNOUNCEMENT
I changed the naming convention back to match exactly as it appears on MSDN.
My rationale, as it appears in the header for the file:
I changed the naming convention back to match exactly as it appears on MSDN.
My rationale, as it appears in the header for the file:
Apologies if you were using it for anything and have to make changes, I feel it's best to do it now rather than when it is more painful down the road.The reasons for this are two-fold.
1) The immediately obvious thing to do is to strip the lower case prefixes, however in some cases this would not be possible.
eg: KBDLLHOOKSTRUCT has vkCode and scanCode - you could not have two properties called "Code".
2) Consistency. Seeing as we cannot achieve consistency by stripping lower case prefixes, the next best solution is to keep them exactly as on MSDN.
Some properties on MSDN have prefixes, some do not. MSDN may not be consistent, be WinStructs is (With MSDN).
Re: WinStructs - Windows Structure definitions for _Struct
I am pleased to announce that it appears HotKeyIt has fixed the issues with _Struct and I am (tentatively) declaring WinStructs to be mature enough to consider using in projects - certainly stable enough to start playing with.
If you are using Windows DLL Calls or OnMessage in existing code, please attempt to convert it to WinStructs. If you need help getting the definitions right, just ask.
The more definitions we get, the more we can be sure _Struct doesn't have any bugs, and with every Structure added to WinStructs, using Windows APIs becomes less and less of an "Advanced" topic.
If you are not using Windows DLL Calls or OnMessage, but are interested, this is a great way to learn. You literally have to just copy and paste some text from the MSDN website, make a few alterations (follow a few simple rules) and you can easily interrogate those results like it were a regular AHK object - No scary NumGet() required! Furthermore, by doing it with WinStructs, as soon as you add the definition, ALL the data becomes visible, so it's quicker and easier to see if you got it right as you have the whole result laid out before you in one fell swoop.
The more structures we add, the more examples there are to copy, the easier subsequent structures become to transpose.
If you are using Windows DLL Calls or OnMessage in existing code, please attempt to convert it to WinStructs. If you need help getting the definitions right, just ask.
The more definitions we get, the more we can be sure _Struct doesn't have any bugs, and with every Structure added to WinStructs, using Windows APIs becomes less and less of an "Advanced" topic.
If you are not using Windows DLL Calls or OnMessage, but are interested, this is a great way to learn. You literally have to just copy and paste some text from the MSDN website, make a few alterations (follow a few simple rules) and you can easily interrogate those results like it were a regular AHK object - No scary NumGet() required! Furthermore, by doing it with WinStructs, as soon as you add the definition, ALL the data becomes visible, so it's quicker and easier to see if you got it right as you have the whole result laid out before you in one fell swoop.
The more structures we add, the more examples there are to copy, the easier subsequent structures become to transpose.
Re: WinStructs - Windows Structure definitions for _Struct
I am interested, but how do I use this? A very simple example may help tremendously.evilC wrote:If you are not using Windows DLL Calls or OnMessage, but are interested, this is a great way to learn. You literally have to just copy and paste some text from the MSDN website, make a few alterations (follow a few simple rules)
Re: WinStructs - Windows Structure definitions for _Struct
Yeah, it could do with an example script, I will get right on it.
Re: WinStructs - Windows Structure definitions for _Struct
Done.
I added a POINT structure definition (ie re-download WinStructs.ahk), as well as an example.
I added a POINT structure definition (ie re-download WinStructs.ahk), as well as an example.
Return to “Scripts and Functions (v1)”
Who is online
Users browsing this forum: No registered users and 128 guests