A special type when creating a structure

Ask for help, how to use AHK_H, etc.
arcticir
Posts: 543
Joined: 17 Nov 2013, 11:32

A special type when creating a structure

31 Aug 2017, 04:12

How to create the following structure in the special type? Such as: CLSID clsid;

Code: Select all

typedef struct _FILEDESCRIPTOR {
  DWORD    dwFlags;
  CLSID    clsid;
  SIZEL    sizel;
  POINTL   pointl;
  DWORD    dwFileAttributes;
  FILETIME ftCreationTime;
  FILETIME ftLastAccessTime;
  FILETIME ftLastWriteTime;
  DWORD    nFileSizeHigh;
  DWORD    nFileSizeLow;
  TCHAR    cFileName[MAX_PATH];
} FILEDESCRIPTOR, *LPFILEDESCRIPTOR;
From here:
https://msdn.microsoft.com/en-us/librar ... s.85).aspx
HotKeyIt
Posts: 1713
Joined: 29 Sep 2013, 18:35
Contact:

Re: A special type when creating a structure

31 Aug 2017, 10:01

Code: Select all

POINTL :="
(
  LONG x;
  LONG y;
)"

SIZEL:="
(
   LONG cx;
   LONG cy;
)"

GUID :="
(
  DWORD Data1;
  WORD  Data2;
  WORD  Data3;
  BYTE  Data4[8];
)"

CLSID := GUID

FILETIME :="
(
  DWORD dwLowDateTime;
  DWORD dwHighDateTime;
)"

FILEDESCRIPTOR := "
(
  DWORD    dwFlags;
  CLSID    clsid;
  SIZEL    sizel;
  POINTL   pointl;
  DWORD    dwFileAttributes;
  FILETIME ftCreationTime;
  FILETIME ftLastAccessTime;
  FILETIME ftLastWriteTime;
  DWORD    nFileSizeHigh;
  DWORD    nFileSizeLow;
  TCHAR    cFileName[MAX_PATH];
)"
arcticir
Posts: 543
Joined: 17 Nov 2013, 11:32

Re: A special type when creating a structure

07 Sep 2017, 12:31

The following script, why is the definition invalid?

Code: Select all

Error:  Invalid structure definition.

Specifically:  RAWINPUTDEVICE 

input_event(r){
	static RAWINPUTDEVICE:="struct { USHORT usUsagePage;USHORT usUsage;DWORD  dwFlags;HWND  hwndTarget;}"
	static static:=struct("RAWINPUTDEVICE raw[2]",{raw:[{usUsagePage:1,usUsage:2,dwFlags:0x00000100,hwndTarget:A_ScriptHWND},{usUsagePage:1,usUsage:6,dwFlags:0x00000100,hwndTarget:A_ScriptHWND}]})
}
HotKeyIt
Posts: 1713
Joined: 29 Sep 2013, 18:35
Contact:

Re: A special type when creating a structure

07 Sep 2017, 15:28

Because the structure is inside the function and as far as I remember the initialization of static lines does not happen in function's scope.
So you will need to tell it where the structure definition is input_event(RAWINPUTDEVICE):

Code: Select all

input_event(r){
	static RAWINPUTDEVICE:="struct{USHORT usUsagePage;USHORT usUsage;DWORD  dwFlags;HWND  hwndTarget}"
	static rid:=struct("input_event(RAWINPUTDEVICE) raw[2]",{raw:[{usUsagePage:1,usUsage:2,dwFlags:0x00000100,hwndTarget:A_ScriptHWND},{usUsagePage:1,usUsage:6,dwFlags:0x00000100,hwndTarget:A_ScriptHWND}]})
}

Return to “Ask For Help”

Who is online

Users browsing this forum: No registered users and 2 guests