Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

LibCon - AutoHotkey Library For Console Support


  • Please log in to reply
27 replies to this topic
joedf
  • Members
  • 769 posts
  • Last active: Yesterday, 07:39 PM
  • Joined: 20 May 2012

 LibCon - AutoHotkey Library For Console Support 
The main goal of this library is to maintain simplicity, so that the common AutoHotkey user may use it and integrate it easily. wink.png
I know that this is probably considered far from complete, but just to get things started, here it is!
See the Documentation here. See some Examples here.

LibCon is proudly under the MIT License.


preview.png

Contact Me for Requests, Comments, Contributions, etc.

 
Get it from GitHub Here or Direct Download



gwarble
  • Members
  • 619 posts
  • Last active: Jul 10 2014 08:52 PM
  • Joined: 23 May 2009
Nice job...
I was just messing around with console apps... Here's a service i was messing around with you can improve my poor programming to get specific chars pressed:
http://gwarble.com/ahk/Console/Service

(clearly my logic needs to be put into a nice loop)
(the service only tested working on xp, but the command line stuff works on 7-64)

Bugz000
  • Members
  • 152 posts
  • Last active: May 07 2014 08:27 PM
  • Joined: 24 Feb 2011

This seems amazing! shocked.png ima have a play with it grin.png thanks! ill get back on what i think of it after some use

Edit: Just found my progress bar code in here! :D glad it's being put to good use :D



joedf
  • Members
  • 769 posts
  • Last active: Yesterday, 07:39 PM
  • Joined: 20 May 2012

@gwarble I'm working a function that will help you greatly, almost done ;) (i know the problem is ReadConsoleInput)

@Bugz000 I'm glad! I will be adding the credits soon, im working on the documentation, should be done soon!

 

EDIT: NEW UPDATE! - Library version is set to: 1.0.1.0

 

added function get​ch()

see example for usage...

Also i'm working on some minor bug fixes, cheers!



gwarble
  • Members
  • 619 posts
  • Last active: Jul 10 2014 08:52 PM
  • Joined: 23 May 2009
Cool, but its working fine for me (readconsoleinput that is, did you try my simple menu?)... you have to flush the buffer and check the key (because it triggers on mouse, etc)... I used old school numget but you can setup a struct for it properly

joedf
  • Members
  • 769 posts
  • Last active: Yesterday, 07:39 PM
  • Joined: 20 May 2012

EDIT: @gwarble have you tried casting the type return?

key := NumGet(INPUT_RECORD, 8, "UShort")

-----------

 

@gwarble You sure its working fine? it crashes if i press I,R, anyone that is listed, otherwises it doesnt crash.... but equals to

exit of the program: "press any other key"... So you are sure that you dont want to use getch() ??? because i made this especially for this and main console use, since

it doesnt trigger on mouse move or mouse click or whatever, only if the Keyboard has gotten input. And the code is perfectly

safe and works exactly like how it should be, in a console. Also, i have your function for 'ReadConsoleInput' in LibCon.ahk but its got some weird bug like said.. i think i can fix it, i believe i know what the problem is... will do that soon

 

cheers wink.png

 

EDIT: try the example script, it has a getch example usage



gwarble
  • Members
  • 619 posts
  • Last active: Jul 10 2014 08:52 PM
  • Joined: 23 May 2009
Oh dont get me wrong, i'm looking forward to a nice library, i've just been hacking away at it to play around and thought i'd share what i found
I didnt mean the "pause function (that was the first step) but in the main loop (after the conditional cases at the beginning) where that ugly goto is, its using ReadConsoleInput in a loop to check for KeyDown and that there is a real key char received...

I thought you meant you had problems with getch(), not that you had added it in the last update

Edit: scrolled through the getch code, nice handling of non char keys and stuff

I'd add a CLS type function next, fill the buffer and put cursor at the top

gwarble
  • Members
  • 619 posts
  • Last active: Jul 10 2014 08:52 PM
  • Joined: 23 May 2009

EDIT: @gwarble have you tried casting the type return?

key := NumGet(INPUT_RECORD, 8, "UShort")
-----------

@gwarble You sure its working fine?
I'll double check but i thought i left it in a working state

I feel dumb but i dont know what casting the type return means :)
Edit: i'd call that line "extracting the key byte from the input_record structure" in my layman terms... Is that what you mean? If so yeah its in there except i picked the vkey instead... again just me experimenting...

So did you run into problems with ReadConsoleInput in C also?

joedf
  • Members
  • 769 posts
  • Last active: Yesterday, 07:39 PM
  • Joined: 20 May 2012

@gwarble Oh no problemo! just added a simple ClearScreen() ( cls() or Clear() ) wink.png

i have checked some of your code, seems fine, but im Unable to compile it. I have found

that you are using 'ServiceTest.AHK.bin' to compile it? have not tried it yet, i cant test anything

if i cant compile it.... tongue.png

 

i see this 'chr(key)' it seems to work fine, but what is the problem? you want to check if it's a Char and not some special input like the mouse?

if so, i suggest checking if the values are between [48 to 57] + [97 to 122] like in this ASCII Table:

(since everything else requires a modifier key which triggers the function)

asciifull.gif

regards wink.png



joedf
  • Members
  • 769 posts
  • Last active: Yesterday, 07:39 PM
  • Joined: 20 May 2012

Update! Documentation is complete (sorta tongue.png)

https://github.com/j.../LibCon_docs.md



A v i
  • Members
  • 1282 posts
  • Last active: Yesterday, 01:47 PM
  • Joined: 30 Jan 2013

Thanks for this lib, joedf . Very cool.

 

Will you consider wrapping a class over it, just to disable those global variables (sType, Black, Yellow) . You can distribute it as an alternative version via Github.



gwarble
  • Members
  • 619 posts
  • Last active: Jul 10 2014 08:52 PM
  • Joined: 23 May 2009
Hmm, well i don't have a specific need, i was just playing around (i started by wanting to make a service, got sidetracked on console mode stuff, and some other distractions (play sound from fileInstall without extracting to disk)... i have plans for a couple console utilities i want and maybe a cdo/com emailer in ahk (for more "fair" comparison to blat/mailsend)

Anyway, i updated the link above to the folder so you can grab the other files

gwarble
  • Members
  • 619 posts
  • Last active: Jul 10 2014 08:52 PM
  • Joined: 23 May 2009
DllCall("FlushConsoleInputBuffer",uint,handle)

joedf
  • Members
  • 769 posts
  • Last active: Yesterday, 07:39 PM
  • Joined: 20 May 2012

@Avi maybe in the future, but it seems unnecessary at the moment wink.png

@gwarble i missed your message, but ive added the stuff already, so it's all good grin.png see my devlog below

 

News! Added new stuff, unreleased yet, still adding stuff, testing stability and Documenting...

Here is my DevLog:

Spoiler

 

cheers! wink.png



tmplinshi
  • Members
  • 239 posts
  • Last active: Jun 22 2014 04:29 AM
  • Joined: 06 Apr 2012
How about replace pause() to:
pause(show=1) {
	show ? puts("Press any key to continue . . .") : ""
	_getch()
}
hmmm... Maybe you have thought about this, and you choose to have local language.

Edited by tmplinshi, 05 September 2013 - 08:16 AM.