Page 1 of 1 1
Topic Options
#202828 - 2011-08-11 04:07 PM Re-Sizing the Console without loseing the content ?
MACE Offline
Starting to like KiXtart

Registered: 2004-09-07
Posts: 150
Loc: Manchester UK
I still do a great deal in the console and often need to enlarge it to clearly display the output. I use the following as an example to get the screen res and to set the console size...
 Code:
Global $LOG,$RES[1],$LC
$=ScrnRes()
If $RES[0]=0 ;No WMI
 $RES[0]=120
 $RES[1]=40
Endif
$Log='CON'
$E=Logit($Log,'This could be a very long bit of data which I need to display')
$E=Logit($Log,'Often the output is many lines of data which needs proofing at the console rather than just output to file.')


 Code:
FUNCTION LOGIT($File,$Data)
If $File='CON'
 If $LC=0
  shell '%comspec% /c mode CON cols='+$RES[0]+' lines='+2*Int($RES[1]/3)
  $=SETCONSOLE("MAXIMIZE")
 Endif
 If len($Data)>$RES[0]
  $LC=$LC+int(len($Data)/$RES[0])+1
 Else
  $LC=$LC+1
 Endif
 ? $DATA
Else
 If open(7,$File,5)=0
  $=Writeline(7,$Data+@crlf)
  $=Close(7)
 Else
  $Logit=9
  Exit $Logit
 Endif
Endif
ENDFUNCTION

Function ScrnRes()
Dim $objWMIService,$colItems,$objItem,$HT,$WI,$COL,$LIN
 $objWMIService = GetObject("Winmgmts:\\.\root\cimv2")
 $colItems = $objWMIService.ExecQuery("Select * From Win32_DesktopMonitor where DeviceID = 'DesktopMonitor1'",,0)
 For Each $objItem in $colItems
  $WI = $objItem.ScreenWidth
  $HT = $objItem.ScreenHeight
 Next
 ;Estimate Max Console Size based on default 8x12 font and 10+10x10+30 frame borders
 $RES[0]=int(($WI-20)/8)
 $RES[1]=int(($HT-40)/12)
EndFunction


I have a frustration that I don't generally want to maximise the console to fill the screen unless necessary. If I use the shell MODE option to re-size the console it will WIPE any existing content. Similarly I have so far been unable to find a standard WMI or similar method to read the default settings for the Console i.e. Shell 'MODE CON:' and the font size in use.
I have been forced to make general assumptions as to 8x12 font and the windows styles.
As I often only have the wkix32.exe to play with, no kix#.dll I would need to query readily available windows resources for the necessary information.

Anyone know how to read and or change on the fly the Console settings without wiping the content (buffer) ?

Top
#202845 - 2011-08-12 07:05 PM Re: Re-Sizing the Console without loseing the content ? [Re: MACE]
Bonji Offline
Starting to like KiXtart

Registered: 2001-09-28
Posts: 169
Loc: Virginia
I never use the console anymore (go go Kixforms.dll!!), but what about setting the console size prior to populating it? Then you just show it when you need to.

I think I see what you are saying now...you show it all the time, but only maximize it sometimes. I'll think about this one some more...

I also use the following to determine what DPI is in use, but I don't remember if this only applies to Win7 or if it's applicable everywhere. I then modify the relative size of everything based on this number.

 Code:
$DPI = ReadValue("HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics", "AppliedDPI")


Edited by Bonji (2011-08-12 07:06 PM)

Top
#202846 - 2011-08-12 07:20 PM Re: Re-Sizing the Console without loseing the content ? [Re: Bonji]
Bonji Offline
Starting to like KiXtart

Registered: 2001-09-28
Posts: 169
Loc: Virginia
What about maintaining a variable that you can use to "paint" a new console window? Anytime you want to output something, append (or replace if necessary) it to this Console variable, and then you can re-populate a blank Console if needed. You can use the Shell object in Kixforms.dll to capture console output without redirection or you can redirect output to a text file that you can then import into this Console variable.

It seems viable, but I'm just thinking off the top of my head.

Also, there are some registry settings that control the Console's appearance, although they do seem to be for new sessions versus active ones.

HKCU\Console
http://support.microsoft.com/kb/105674

Top
#202847 - 2011-08-12 07:30 PM Re: Re-Sizing the Console without loseing the content ? [Re: Bonji]
Bonji Offline
Starting to like KiXtart

Registered: 2001-09-28
Posts: 169
Loc: Virginia
Here's an example of what I was thinking of:

 Code:
Break On

$ = SetConsole("Show")
$Var1 = Dir("C:\*.*")
$Var1 = Dir()
$Var1 = Dir()
$Var2 = Dir()
$Console = $Var1 + @CRLF + $Var2
? $Console
Sleep 3

Shell "%ComSpec% /C Mode CON cols=90 lines=40"
? $Console
Sleep 3

$ = SetConsole("Maximize")
$Console = $Console + @CRLF + "Hi There"
Shell "%ComSpec% /C Mode CON cols=90 lines=40"
? $Console
Sleep 3


I'm not sure the best way to clear a console, but with this technique it should be done every time you want to populate it with the Console variable. I'm just executing the MODE command again to clear it out.

Top
#202863 - 2011-08-15 11:10 AM Re: Re-Sizing the Console without loseing the content ? [Re: Bonji]
MACE Offline
Starting to like KiXtart

Registered: 2004-09-07
Posts: 150
Loc: Manchester UK
The priniple of an accumulating variable and re-drawing the screen is fine until I consider the memory overhead. Additionally the buffer for the console is seldom up to the sizes we are thinking of. The use of repeated MODE commands to re-size to best fit Output is a very SLOW process. Each MODE on my W7x64 Workstation can add 2 seconds to the execution as it spawns a shell etc.
I have also notice, which is another gripe, that if I Maximize a console which has not had a MODE applied to it, it will maintain the pre-defined width = Usually 80 chrs, and will do full height on the default screen size. If however I have applied a MODE to it, SetConsole("Maximize") has no effect at all as I have already specified 'MY' size.

What I think has potential is the DPI and similar registry entries. I need to collate a bank of information covering XP to Win7 64 which will give me DPI, Default FONT etc...
I still however have no idea other than MODE whether I can script a change to the size and font size of a console in use !
It SHOULD be possible as in the GUI it is possible to change the chosen console using (Right Click) Context Menu, Properties !

Top
#202866 - 2011-08-15 05:28 PM Re: Re-Sizing the Console without loseing the content ? [Re: MACE]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
I create a scrndump utility a while back for exactly this type of need - when you run it it will create a KiXtart file containing current content of the console. You can CALL the file (to load the screen array), resize the console and re-display the data.

I've also got a KiXtart UDF which allows you to define and manage windows within the console which might help, but I'm struggling to find it at the moment.

Scrndump attached.

[edit] Found the windowing udf (Pane.udf). It may give you some ideas how to create and manage a virtual KiXtart console (run the UDF for a simple example) [/edit]


Attachments
scrndump.zip (362 downloads)
Description:

Pane.udf (369 downloads)
Description:



Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 323 anonymous users online.
Newest Members
Audio, Hoschi, Comet, rrosell, PatrickPinto
17880 Registered Users

Generated in 0.055 seconds in which 0.028 seconds were spent on a total of 14 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org