[Class] Console - Standardized Console GUI with Methods

Post your working scripts, libraries and tools
User avatar
AfterLemon
Posts: 83
Joined: 30 Sep 2013, 14:27
Location: Arizona, USA

[Class] Console - Standardized Console GUI with Methods

13 Feb 2014, 15:29

Class: Console - Standardized Console GUI with Methods
by: tidbit, AfterLemon
Version 1.8 | Tue March 11, 2014
[Downloads][Screenshot]
Thank you for your interest! Good ol' tidbit and I worked on this with ease of use, seamless handling, and robust ability in mind. We hope you like it.
As always, we're both here, and on the IRC channel (irc.freenode.net #ahk & #ahkscript) to help.

Now on to the details:

This class is meant to simplify debugging for scripts from simple text handling, to outputting and logging data & arrays.
There's a lot here, so jump in and test it out using our demo scripts below, or write your own setup and tell us what you think we need to add!

Thanks again!

Without further adieu....

Description

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



Documentation
Spoiler


Demos
- removed - Please see the Download link at the top (Github has the demos).
Attachments
2014-03-06_13-33-06.png
Last edited by AfterLemon on 14 Mar 2014, 14:54, edited 3 times in total.
User avatar
tidbit
Posts: 847
Joined: 29 Sep 2013, 17:15
Location: USA

Re: Class: Console - Standardized Console GUI with Methods

14 Feb 2014, 10:31

Great release :D I would also like to thank Lexikos as the PrintArray function is based on his ExploreObj() (but pretty much unnoticeable now).
rawr. fear me.
*poke*
Is it December 21, 2012 yet?
User avatar
MasterFocus
Posts: 146
Joined: 01 Oct 2013, 09:47
GitHub: MasterFocus
Location: Rio de Janeiro - RJ - Brasil
Contact:

Re: Class: Console - Standardized Console GUI with Methods

14 Feb 2014, 22:29

Looks promising! I'll definitely keep an eye on this. Thanks guys!
Antonio França - git.io | github.com | ahk4.net | sites.google.com
Member of the AHK community since 08/Apr/2009. Moderator since mid-2012.
Need help? Please post on the forum before sending me a PM.
User avatar
tidbit
Posts: 847
Joined: 29 Sep 2013, 17:15
Location: USA

Re: Class: Console - Standardized Console GUI with Methods

15 Feb 2014, 11:20

You're welcome :D
small update 1.1
when using console.log(OBJECT or ARRAY), any keys with strings are now quoted.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



Edit: I see an issue with this. arr[33,2,3] = 2 should be arr[33,3] = 2
rawr. fear me.
*poke*
Is it December 21, 2012 yet?
User avatar
tidbit
Posts: 847
Joined: 29 Sep 2013, 17:15
Location: USA

Re: Class: Console - Standardized Console GUI with Methods

16 Feb 2014, 12:22

fixed the above bug

Code: [Select all] [Download] GeSHi © Codebox Plus

a:= new console("a",32,232,400,452,0)
a.show()
o:={"deer":"animal",33:[11,{"q":1,"w":2,"e":3,1:4},2],"apple":"car"}
a.log(o)
a.log()
o:=[1,2,[11,22,[111,222,333,[1111,2222]],33],3,4]
a.log(o)
return

esc::exitApp

I used this class to debug this class :D
rawr. fear me.
*poke*
Is it December 21, 2012 yet?
User avatar
TLM
Posts: 1074
Joined: 01 Oct 2013, 07:52

Re: Class: Console - Standardized Console GUI with Methods

22 Feb 2014, 14:48

excellent work guys!

AfterLemon, just moving this 'feature request' item here (stdout > var),
Its from tidbit's dropbox (verbatim):
Spoiler

The endless API function calls I had to make back in vanilla to return the consoles stdout buffer to a var,
now reduced to a few lines, as I said to tidbit, its almost not fair, but amazing that it can be done this way.

If you could add a method for this it would be greatly appreciated.
Image
User avatar
AfterLemon
Posts: 83
Joined: 30 Sep 2013, 14:27
Location: Arizona, USA

Re: Class: Console - Standardized Console GUI with Methods

22 Feb 2014, 18:15

Minor Update

STDout to the console is now available.

TWO new methods now support STDout:
StdOutFull -- Wait until CMD stdout is finished and append it all to the console
StdOutStream -- Stream the CMD stdout appended to the console

An Example:

Code: [Select all] [Download] (STDout Console Demo.ahk)GeSHi © Codebox Plus

a:=new console("a",100,100,400,435)
a.show()
a.StdOutFull("ipconfig.exe")
Sleep,3000
a.clear()
Sleep,3000
a.StdOutFull()
return


This can also be done manually once the object has been created by either of the 2 methods above:

Code: [Select all] [Download] (Manual Demo.ahk)GeSHi © Codebox Plus

objExec:=a.objShell.Exec("ipconfig.exe")
While !objExec.StdOut.AtEndOfStream
a.append(objExec.StdOut.ReadLine())
User avatar
TLM
Posts: 1074
Joined: 01 Oct 2013, 07:52

Re: Class: Console - Standardized Console GUI with Methods

22 Feb 2014, 21:09

awesome :D

tidbit and I ( mostly tidbit ;) ) tried to figure out how to get the cmd to exec() without the window.
He ended up using the `shell hook event` approach to hide it, it still flashes but seems to work ok.

Still beats a million dllcalls()
Image
User avatar
tidbit
Posts: 847
Joined: 29 Sep 2013, 17:15
Location: USA

Re: Class: Console - Standardized Console GUI with Methods

23 Feb 2014, 10:19

aww man. you guys released it before me! I was going to fix some bugs you made before releasing, afterlemon :P
Mine also has a Break feature. I'll show it to you over irc before merging.
I also added a new function and redid the docs/description page a little.
rawr. fear me.
*poke*
Is it December 21, 2012 yet?
hd0202
Posts: 60
Joined: 04 Oct 2013, 03:07
Location: Germany near Cologne

Re: Class: Console - Standardized Console GUI with Methods

24 Feb 2014, 01:27

I think here is a problem in class source lines 9 and 13:
TimeFormat should be FormatTime

Hubert
User avatar
tidbit
Posts: 847
Joined: 29 Sep 2013, 17:15
Location: USA

Re: Class: Console - Standardized Console GUI with Methods

24 Feb 2014, 10:20

hd0202:
that is the bug i fixed mentioned above :)
there were also 2 or 3 other bugs related to timestamps. I have fixed those. Just waiting for afterlemon to show his face on irc. If he doesn't today I'll just post my fixes and additions.


edit:
Update to 1.3

3 new functions:
cmd()
cmdWait()
timeSinceLastCall()

Bug fixes:
timestamp issues
issues with displaying arrays properly (st_printarr())

misc:
generated console names (if the name was left blank) now uses A_Now instead of a random number.
updated the docs a bit.
rawr. fear me.
*poke*
Is it December 21, 2012 yet?
ahk7
Posts: 84
Joined: 06 Nov 2013, 16:35

Re: Class: Console - Standardized Console GUI with Methods

26 Feb 2014, 16:12

Nice class. But I prefer mine with a splash of color - I'm just messing around with it a bit by replacing the edit control with a listview, this makes it possible to use "line numbers" and color text for certain types of data using https://github.com/AHK-just-me/Class_LV_Colors

You can see very early demo here https://github.com/hi5/Class_Console/tree/dev run Demo_LV1.ahk to see a green "array"

Not sure of LVs are the way to go, a scintilla control might do it OR a simple html control which would allow tables, bullet lists, colors ...

One thing I'd also like to see is a resizable window but haven't worked on that yet.
User avatar
AfterLemon
Posts: 83
Joined: 30 Sep 2013, 14:27
Location: Arizona, USA

Re: Class: Console - Standardized Console GUI with Methods

26 Feb 2014, 16:36

I like the idea of having it handle in a way that looks a little bit nicer, but the sacrifices you're making are too much in my opinion.

Take a look at the overall size of the project. Nearly 600 lines, and many of the methods must still be extended. As well things like Console.Pull() will fail and or cause unreliability due to their slow looping data dump.

LOVE the idea, that's for sure.
User avatar
tidbit
Posts: 847
Joined: 29 Sep 2013, 17:15
Location: USA

Re: [Class] Console - Standardized Console GUI with Methods

01 Mar 2014, 14:43

Updated to 1.5! - Major release
-----
A new Command Bar has been added!
The TV parameter/effect has been removed.
many updates and bug fixes.
.Eval() (a simple, not a full featured eval)
many command bar commands.
other stuff.

Woohoo!
rawr. fear me.
*poke*
Is it December 21, 2012 yet?
User avatar
tidbit
Posts: 847
Joined: 29 Sep 2013, 17:15
Location: USA

Re: [Class] Console - Standardized Console GUI with Methods

06 Mar 2014, 18:05

1.7

now uses an html (mshtml) control
line numbers
colors
themeable (html/css)
catch
color
other stuff
bug fixes
more fixes

enjoy!
rawr. fear me.
*poke*
Is it December 21, 2012 yet?
User avatar
cyruz
Posts: 242
Joined: 30 Sep 2013, 13:31

Re: [Class] Console - Standardized Console GUI with Methods

06 Mar 2014, 18:40

Hi guys, thanks for the nice work. Just a request... This class, most probably, will be put in the Lib folder, so it would be nice to have description and documentation inside the class file itself. Of course anyone can do it by himself, so no real need...
ABCza on the old forum.
My GitHub.
User avatar
tidbit
Posts: 847
Joined: 29 Sep 2013, 17:15
Location: USA

Re: [Class] Console - Standardized Console GUI with Methods

06 Mar 2014, 19:38

I had that originally, but that adds another ~150 lines.
Until AHK has support for classes in the lib (or does it already? maybe it has a different name structure?), I don't see it being useful. Currently I just copy/paste it at the bottom of my script. since you can't name the file Console.ahk and AHK recognizes it like it does functions.

I guess there is always the use of #include, but that has issues. for some users (like me) simply doing "#include console.ahk" gives an error. I need an absolute path. I find it simpler to just copy/paste instead of fetch the full path every time.
rawr. fear me.
*poke*
Is it December 21, 2012 yet?
User avatar
joedf
Posts: 5328
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada, Quebec
Contact:

Re: [Class] Console - Standardized Console GUI with Methods

06 Mar 2014, 20:23

very interesting :)
User avatar
cyruz
Posts: 242
Joined: 30 Sep 2013, 13:31

Re: [Class] Console - Standardized Console GUI with Methods

07 Mar 2014, 10:08

tidbit wrote:I had that originally, but that adds another ~150 lines.
Until AHK has support for classes in the lib (or does it already? maybe it has a different name structure?), I don't see it being useful. Currently I just copy/paste it at the bottom of my script. since you can't name the file Console.ahk and AHK recognizes it like it does functions.

I guess there is always the use of #include, but that has issues. for some users (like me) simply doing "#include console.ahk" gives an error. I need an absolute path. I find it simpler to just copy/paste instead of fetch the full path every time.


I'm using the "#Include <Console>" approach, I find it very convenient.

Now that joedf is here and because I didn't dig deeper in the code, may I ask one of you what are the main differences between Console and LibCon?
ABCza on the old forum.
My GitHub.
User avatar
AfterLemon
Posts: 83
Joined: 30 Sep 2013, 14:27
Location: Arizona, USA

Re: [Class] Console - Standardized Console GUI with Methods

07 Mar 2014, 10:36

(Not much experience with LibCon, it fails to start due to VarSetCapacity not implemented)

From a not-so-extensive look-over of LibCon, I see that while it has many of the features you would expect a console to have, it is not necessarily built for debugging.

Class_Console is built with the debugging of issues in mind. .Catch() allows you to monitor execution automatically (this feature is something I've wanted since starting AHK 5 years ago), .Debug() allows you to view the script logs, and to the extent possible, everything is self-contained, as small and efficient as possible, and dedicated to finding and fixing the problems in your other scripts.

I'd like to see this as an #Include simply for the efficiency of fixing any script any time. We'll see what we can do.
HOME: Windows 7 x64 SP1 Ultimate | AMD FX 8350 8-Core @ 4.00GHZ | 16GB Ram
WORK: Windows 7 x64 SP1 Home Premium | AMD Athlon II X4 640 @ 3.00GHz | 8GB Ram
MOBILE: Samsung Galaxy Note 3 | 2012 Asus Nexus 7 | Zune 80Gb

Return to “Scripts and Functions”

Who is online

Users browsing this forum: No registered users and 17 guests