Page 1 of 1 1
Topic Options
#81713 - 2003-07-10 05:39 PM New GetConsoleState() function
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Request for thoughts ...

Was following this thread with much interest. And since one can get mildy annoyed when one loose's the console window (when SetConsole("HIDE") is used), would like to suggest the following new function. The state can then be saved and (if required) restored later.

$State = GetConsoleState()

Where $State is:

0 Console is HIDDEN
1 Console is SHOWN
2 Console is MINIMIZED
3 Console is MAXIMIZED

Maybe need another value meaning "N/A" when running wkix32 ? Thought about asking for return codes from SetConsole() (ie, previous state) but that would probably break too many existing scripts.

[ 10. July 2003, 17:40: Message edited by: Shawn ]

Top
#81714 - 2003-07-10 05:59 PM Re: New GetConsoleState() function
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
this could also be included in setconsole.
it currently outputs errorcodes but could fine output the original state.
_________________________
!

download KiXnet

Top
#81715 - 2003-07-10 06:06 PM Re: New GetConsoleState() function
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
It does make sense to return this from SetConsole(), that would be the perfect solution, but (I) can't see how to do that without breaking existing scripts ... [Frown]
Top
#81716 - 2003-07-10 06:14 PM Re: New GetConsoleState() function
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
Still on the fence with this one. I think it's safe to say that I know the state of my console at all times, but if for some reason you don't this could be useful.

Anyway, if getConsoleState is added, you could write a wrapper for setconsole

code:
 
function setconsole2($state)
$setconsole2 = getConsoleState()
setconsole($state)
endfunction

_________________________
Eric

Top
#81717 - 2003-07-10 06:25 PM Re: New GetConsoleState() function
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Thats the thing, you know the state of your console ... but do you know the state of mine ?
Top
#81718 - 2003-07-10 06:32 PM Re: New GetConsoleState() function
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
hmmm, but good point ... what if we viewed this as a kixtart bug ? ok, maybe not a bug but a lack of important feature ?

If i run this script from the cmdline:

Break On

$= SetConsole("HIDE")

Exit 1

The script runs, Kixtart hides the console, then Kixtart exists. Am I wrong in the assertion that since Kixtart hide the console, that it should not also restore the console, by itself, before it finishes ? As it is now, one gets this orphaned CMD.EXE proggy running in the background ... how does one reclaim that window, other than killing it off using taskmgr ?

-Shawn

Top
#81719 - 2003-07-10 06:40 PM Re: New GetConsoleState() function
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
This whole business is getting rather complicated ... I guess because folk have a few different ways to start kixscript. Some (like me) start them from the cmdline. Some double-click on .kix files. Some use kix32 and some use wkix32. Some scripts run interactive and some scripts run during login and some do both. When running a script during login - its OK to discard the console ... otherwise maybe not. Maybe this new @LoginMode macro can help here.

-Shawn

[ 10. July 2003, 18:40: Message edited by: Shawn ]

Top
#81720 - 2003-07-10 06:49 PM Re: New GetConsoleState() function
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
Good point. But think that is a different topic all together. As far as getConsoleState() goes, I would only need it if I call another script and don't know the state that script left it in.

Which in that case, i would just set it to what i want, rather than having an if-else to decide if i need to reset it. That's just me.

If setconsole returned the previous state, that still wouldn't help you if you don't know the state. You'd have to call setconsole to get the current state, which would just then be the previous state. And what is the point of that?
_________________________
Eric

Top
#81721 - 2003-07-10 07:01 PM Re: New GetConsoleState() function
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
The easiest way would be to add the option of no parameter so that:

$State = SetConsole()

would simply return the current state without changing it. This would leave it backward compatible.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#81722 - 2003-07-10 08:03 PM Re: New GetConsoleState() function
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Well, I know I may be ranting about this a little bit. Just thinking that there must be a better way to handle this SetConsole("HIDE") thingy.

Most folk just slap that statement in their scripts, without giving much thought to us old farts that like to run things from the command line [Wink] . What I usually do, when a see a script with a HIDE in it, is to manually go in and comment it out ... would be nice (in theory) if one didn't have to do that.

Having said that, maybe this suggestion for a new function and/or in combination with a best pratice could be devised for scripts that use the HIDE feature. Maybe just as simple as suggesting that the SetConsole("SHOW") be performed before exiting ... just not sure if thats advisible given the (potentially) unknown state of the console ...

[ 10. July 2003, 20:06: Message edited by: Shawn ]

Top
#81723 - 2003-07-10 08:12 PM Re: New GetConsoleState() function
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
perhaps @ColsoleState would be the way to go...

0= kix32 'hidden' and wkix
1= minimized
2= shown
3= max
4= always on top
etc...

which would return the current state of the console... Ruud has to have a handle on it as he sets an errorcode for setconsole.
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#81724 - 2003-07-10 08:12 PM Re: New GetConsoleState() function
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Now you are opening a can of worms... [Eek!]

While I think best practice would be to keep track of the console's status that may not always be possible. There may be other mitigating factors as well like WKiX32 run with the -I switch and RunLogonScriptSync not set. Given those possibilities, SetConsole() should also report them.

As for whether the Console should or should not be shown, to each his own. I find the console to be a tacky reminder of outdated OSes and would like to see the WKiX32 version at least be in a GUI window. I also don't like the fact that if you try to hide the console in WKiX32, it flashes it on the screen before hiding it.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#81725 - 2003-07-10 08:18 PM Re: New GetConsoleState() function
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Also, it would be nice if there was a "fullscreen" option for the console so that the SetFocus() SendKeys("~{ENTER}") kludge would not have to be resorted to.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#81726 - 2003-07-10 10:06 PM Re: New GetConsoleState() function
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
now now.
if you hide console in wkix and wonder why it flashes...
there is clear reason. wkix32 needs to create the console before it can hide it.
calling wkix with -i switch is kinda work around with this.

anyway, hidden console and consoless mode are 2 different things.
I always run my script with wkix32 nowadays.
that is also the reason why I haven't used setconsole for about last 2 years.

indeed, I know my scripts, and I know that they create console only when I want to.
and that is only on debug mode.

anyway, if setconsole is to be enchanged with returning the old state, i suggest that with wkix32 we could also destroy the console.
wkix32 environment it's just eating resources and even though usefull for something, the console should be totally dynamic.

oh...
that brings to mind...
wkix32 can handle only 1 console.
dunno what way ruud has used for it but it's real pain if you want to simultaneously run multiple commandline utils with console output

[ 10. July 2003, 22:06: Message edited by: Lonkero ]
_________________________
!

download KiXnet

Top
Page 1 of 1 1


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

Who's Online
0 registered and 302 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.063 seconds in which 0.025 seconds were spent on a total of 12 queries. Zlib compression enabled.

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