Oldschool

DllStructCreate

6 posts in this topic

From MSDN:

BOOL WINAPI GetConsoleScreenBufferInfo(
  __in   HANDLE hConsoleOutput,
  __out  PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo
);

;------------------------------------------------------;
CONSOLE_SCREEN_BUFFER_INFO Structure

typedef struct _CONSOLE_SCREEN_BUFFER_INFO {
  COORD dwSize;
  COORD dwCursorPosition;
  WORD wAttributes;
  SMALL_RECT srWindow;
  COORD dwMaximumWindowSize;
} CONSOLE_SCREEN_BUFFER_INFO;

;-----------------------------------------------------;
SMALL_RECT Structure

typedef struct _SMALL_RECT {
  SHORT Left;
  SHORT Top;
  SHORT Right;
  SHORT Bottom;
} SMALL_RECT;

;----------------------------------------------------;
COORD Structure

typedef struct _COORD {
  SHORT X;
  SHORT Y;
} COORD, 
 *PCOORD;

So...based on the MSDN info these

COORD dwSize;

COORD dwCursorPosition;

SMALL_RECT srWindow;

COORD dwMaximumWindowSize;

should equal

$dwSize = DllStructCreate("short;short")
$dwCursorPosition = DllStructCreate("short;short")
$srWindow = DllStructCreate("short;short;short;short")
$dwMaximumWindowSize = DllStructCreate("short;short")oÝ÷ Ù»­²)Ü{jz'*Z²Ê'y+k¹Ëi¢)íz¸§¶´*'²^IÊÞzpn}÷«"wèËaÇ(®·¶Ø^«­¢+ØÀÌØí
=9M=1}M
I9} UI}%9

Share this post


Link to post
Share on other sites



Up...

No one knows the answer?? Any other example of a multilevel struct will do...

Share this post


Link to post
Share on other sites

Up...

No one knows the answer?? Any other example of a multilevel struct will do...

It looks correct to me. Have you passed DllStructGetPtr?

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

It looks correct to me. Have you passed DllStructGetPtr?

Right now I'm having trouble getting a handle to the console screen buffer, so I'm not sure if the struct fills right or not...

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

$stdOutHandle = _WinAPI_GetStdHandle(1)
If Not $stdOutHandle Then MsgBox(0, "", "Error getting std handle...")
$CONSOLE_SCREEN_BUFFER_INFO = DllStructCreate("short;short,short;short;short;short,short;short;short;short;short")
DllCall("Kernel32.dll", "int", "GetConsoleScreenBufferInfo", "int", $stdOutHandle, "ptr", DllStructGetPtr($CONSOLE_SCREEN_BUFFER_INFO))
If @Error Then MsgBox(0, "", "Error during dll call...")
MsgBox(0,"",DllStructGetData($CONSOLE_SCREEN_BUFFER_INFO, 2))

Always returns 0 for example...

Although this supposedly works:

{

  cchWidth = -1;
  cchHeight = -1;
  const int STD_OUTPUT_HANDLE = -11;

  CONSOLE_SCREEN_BUFFER_INFO csbi;
  if ( GetConsoleScreenBufferInfo( GetStdHandle( STD_OUTPUT_HANDLE ), out csbi ) )
  {
    cchWidth = csbi.dwSize.X;
    cchHeight = csbi.dwSize.Y;
    return true;
  }
  return false;

}
Edited by Oldschool

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

On 16/03/2008 at 1:23 PM, Oldschool said:

 

$stdOutHandle = _WinAPI_GetStdHandle(1)
If Not $stdOutHandle Then MsgBox(0, "", "Error getting std handle...")
$CONSOLE_SCREEN_BUFFER_INFO = DllStructCreate("short;short,short;short;short;short,short;short;short;short;short")
DllCall("Kernel32.dll", "int", "GetConsoleScreenBufferInfo", "int", $stdOutHandle, "ptr", DllStructGetPtr($CONSOLE_SCREEN_BUFFER_INFO))
If @Error Then MsgBox(0, "", "Error during dll call...")
MsgBox(0,"",DllStructGetData($CONSOLE_SCREEN_BUFFER_INFO, 2))

 

Always returns 0 for example...

 

Just so anyone looking for the answer actually gets one...  The above code is almost correct.  There is just a mistake in the structure.  This works:

$stdOutHandle = _WinAPI_GetStdHandle(1)
If Not $stdOutHandle Then MsgBox(0, "", "Error getting std handle...")
$CONSOLE_SCREEN_BUFFER_INFO = DllStructCreate("short;short;short;short;word;short;short;short;short;short;short")
DllCall("Kernel32.dll", "int", "GetConsoleScreenBufferInfo", "int", $stdOutHandle, "ptr", DllStructGetPtr($CONSOLE_SCREEN_BUFFER_INFO))
If @Error Then MsgBox(0, "", "Error during dll call...")
MsgBox(0,"","Height = "&DllStructGetData($CONSOLE_SCREEN_BUFFER_INFO, 2))
Edited by BrunoJ

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now