Oldschool Posted March 15, 2008 Share Posted March 15, 2008 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 Link to comment Share on other sites More sharing options...
Oldschool Posted March 16, 2008 Author Share Posted March 16, 2008 Up... No one knows the answer?? Any other example of a multilevel struct will do... Link to comment Share on other sites More sharing options...
martin Posted March 16, 2008 Share Posted March 16, 2008 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. Link to comment Share on other sites More sharing options...
Oldschool Posted March 16, 2008 Author Share Posted March 16, 2008 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... Link to comment Share on other sites More sharing options...
Oldschool Posted March 16, 2008 Author Share Posted March 16, 2008 (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 March 16, 2008 by Oldschool Link to comment Share on other sites More sharing options...
BrunoJ Posted July 7, 2017 Share Posted July 7, 2017 (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 July 7, 2017 by BrunoJ Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now