MKANET Posted June 5, 2012 Share Posted June 5, 2012 Currently, it's not possible to change the buffer size of a console window via native Windows command-line commands. All I can do is change the columns and height of a window.I would like to make a simple autoit utility that will allow me to adjust the buffer size of a command window.For example MKANET.au3 300I would like to be able to type that command and respective argument at a Windows command-line; and, have it change the buffer size WITHOUT changing the height of the current window. I would like this only to be temporary if at all possiblepossible, so if I exit the command window, it will revert back to the system default.I'm guessing autoit would have to send some kind of api command? I couldn't find any information on this when doing a google search.PS: I'm still very very new to autoit. So, please.. if possible include a working example for me to try. I would really appreciate it!Thanks so much,MKANET Link to comment Share on other sites More sharing options...
BrewManNH Posted June 5, 2012 Share Posted June 5, 2012 Instead of using the console windows dimensions, you could use an edit box instead and pipe the information to IT instead of the command window. There doesn't seem to be a way to adjust the buffer size without adjusting the window size at the same time. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
MKANET Posted June 5, 2012 Author Share Posted June 5, 2012 I'm not familiar with an edit box. Unfotunately this is a HUGE batch file which uses colors, special characters; ascii art, etc. The output is already being piped through an external mtee command (to saving everything to a log file). If this was a very simple batch file, maybe redirecting the output to autoit would be feasible. I dont mind changing the window size while changing the buffer size. I could just set it to the command window defaults. I would love to know how to do this in autoit. Also, if you could give me an example of how to use an edit box for my batch file... who knows.. maybe it would work. Again, if it's possible please provide working examples for me to try. I would really appreciate it!! Link to comment Share on other sites More sharing options...
BrewManNH Posted June 5, 2012 Share Posted June 5, 2012 The way you'd do it in a command window would be to use "mode con lines=xxx" where xxx = the number of lines you want in the window. If you specify a number larger than can be displayed on the monitor, it will make a command box that's as tall as the monitor, but will have the buffer size set to what you want. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
MKANET Posted June 5, 2012 Author Share Posted June 5, 2012 I guess I misunderstood. That's how I've been doing it. But I can't change the buffer setting independantly of the window size. I know in VB.net (and possibly other programming languages) you can specify them independantly. Below is the VB.net way to do it (Which I dont have a compiler for). I was hoping for the AutoIt way to do this: Module ConsoleBuffer Sub Main() Console.WindowWidth = 100 Console.BufferWidth = 100 Console.BufferHeight = 1000 End Sub End Module Anyway, if there's no way to do this in AutoIt, how would I use the edit window (as suggested above)? Thanks in advance! Link to comment Share on other sites More sharing options...
JohnOne Posted June 5, 2012 Share Posted June 5, 2012 http://msdn.microsoft.com/en-us/library/windows/desktop/ms686044%28v=vs.85%29.aspx AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
MKANET Posted June 5, 2012 Author Share Posted June 5, 2012 Thanks. But, that code didn't seem to work. Link to comment Share on other sites More sharing options...
JohnOne Posted June 5, 2012 Share Posted June 5, 2012 What code? I just posted a link to a WINAPI. Did you wrap it with a dllcall? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
MKANET Posted June 5, 2012 Author Share Posted June 5, 2012 Im hoping you could be patient with me. I'm still brand new. I understand very basic code; especially when there's a working example code. When I make a test.au3 file out of the code you posted, it takes me to a help screen defaulting to how to make a helloworld.au3 script. I didn't see anything about dllcall or winapi. I hope i'm not asking too much if i could see a working example for this. I can tweak it once i have something that works. I would really REALLY appreciate it. Link to comment Share on other sites More sharing options...
JohnOne Posted June 5, 2012 Share Posted June 5, 2012 (edited) lol. that's in my signature. The function is in kernel32.dll and called SetConsoleScreenBufferSize. Edited June 5, 2012 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
JohnOne Posted June 5, 2012 Share Posted June 5, 2012 (edited) I'm not to clever with the WinAPI myself but it would be something like this. Untested #include <WinAPI.au3> Func _SetConsoleScreenBufferSize($x, $y) $hSTDOUT = _WinAPI_GetStdHandle(1) $struct = DllStructCreate("short x;short y") DllStructSetData($struct, 1, $x) ; where x and y are the new sixe DllStructSetData($struct, 2, $y) $bSetConsoleScreenBufferSize = DllCall("kernel32.dll", "bool", "SetConsoleScreenBufferSize", "handle", $hSTDOUT, "struct", $struct) If @error Then Exit MsgBox(0, 0, @error) EndFunc ;==>_SetConsoleScreenBufferSize Edited June 5, 2012 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
MKANET Posted June 5, 2012 Author Share Posted June 5, 2012 (edited) Thank you so much. I replaced X and Y with real numbers. There are no errors returned when execute the below code. I'm not too sure what to expect. I not even sure which variable is reponsible for the buffersize (not just window size). Maybe someone here might know how to change the buffer size. I'm really hoping that I'm not asking for something that's too difficult to do. #include <WinAPI.au3> $hSTDOUT = _WinAPI_GetStdHandle(1) $struct = DllStructCreate("short x;short y") DllStructSetData($struct,1,80) ; where x and y are the new size DllStructSetData($struct,1,100) $bSetConsoleScreenBufferSize = DllCall("kernel32.dll","bool","SetConsoleScreenBufferSize","handle",$hSTDOUT,"struct",$struct) If @error Then Exit MsgBox(0,0,@error) Edited June 5, 2012 by MKANET Link to comment Share on other sites More sharing options...
Inverted Posted June 6, 2012 Share Posted June 6, 2012 You can adjust all the options for a command window by making a shortcut to the batch file. Global command window options are unaffected. Link to comment Share on other sites More sharing options...
rover Posted June 6, 2012 Share Posted June 6, 2012 (edited) Use Mat's Console.au3 UDFhttp://matdiesel.co.uk/autoit/http://code.google.com/p/consoleau3/Sets the screen buffer height without resizing the cmd.exe console window heightEdit: Added attached console for GUI#Include "Console.au3" If Not _Console_Attach() Then Exit MsgBox(0, '', 'Console not attached') $aRet = _Console_GetScreenBufferSize() _Console_SetScreenBufferSize(-1, $aRet[0], 32766) _Console_Free() Exit#AutoIt3Wrapper_Change2CUI=y #Include "Console.au3" $aRet = _Console_GetScreenBufferSize() ConsoleWrite('Width: ' & $aRet[0] & @CRLF & 'Height: ' & $aRet[1]& @CRLF& @CRLF) ;The width must be >= the current console width or SetScreenBufferSize fails to set the buffer height. ;32766 is the maximum buffer height size in character cells. _Console_SetScreenBufferSize(-1, $aRet[0], 32766) $aRet = _Console_GetScreenBufferSize() ConsoleWrite('Width: ' & $aRet[0] & @CRLF & 'Height: ' & $aRet[1]& @CRLF& @CRLF) Exit Edited June 6, 2012 by rover I see fascists... Link to comment Share on other sites More sharing options...
MKANET Posted June 6, 2012 Author Share Posted June 6, 2012 Mat, you are awesome! I don't know what I would have done without your help. You have all sorts of cool stuff on your website. You even resolved my issue with changing the icon on the current command window. Thanks! #include "Console.au3" If Not _Console_Attach() Then Exit MsgBox(0, '', 'Console not attached') _Console_SetIcon("MyIcon.ico",0) $aRet = _Console_GetScreenBufferSize() _Console_SetScreenBufferSize(-1, $aRet[0], 32766) _Console_Free() Link to comment Share on other sites More sharing options...
rover Posted June 6, 2012 Share Posted June 6, 2012 Mat, you are awesome! I don't know what I would have done without your help. You have all sorts of cool stuff on your website. You even resolved my issue with changing the icon on the current command window. Thanks!A friend once told me he helped some woman whose car was stuck in the snow, and in response to his help she said:'oh thank you jesus for sending me this young man!'and didn't thank him...'Click' Jackass MKANET and JohnOne 2 I see fascists... Link to comment Share on other sites More sharing options...
MKANET Posted June 7, 2012 Author Share Posted June 7, 2012 Ooops.. I just realized that it's possible "rover" may not be Matt. I shouldn't have presumed. My sincerest appologies!! Thank you very much "rover" for helping me with a very useful example. I was able to use your example to do other thing with the Console.au3 UDF. Link to comment Share on other sites More sharing options...
JohnOne Posted June 7, 2012 Share Posted June 7, 2012 MKANET It is polite and welcomed to hit the like button when someone helped you. Just hit the like button on rovers post. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
MKANET Posted June 8, 2012 Author Share Posted June 8, 2012 Thanks for the tip. This forum full of friendly people! It makes using autoit even more enjoyable. 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