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
  • Administrators
  • 986 posts
  • AutoHotkey Foundation
  • Last active: Jul 18 2017 06:01 PM
  • Joined: 20 May 2012
@tmplinshi Yep, actually you are quite right my friend... Here was my thinking process:
1. I need a pause function
2. How?
3. I'm lazy, let's put runwait %comspec% pause.exe
4. Hmm maybe I should add an optional message...
5. Oh well first I'll add a show On/off msg..
6. (I forgot about the custom msg)
7. Later, well now since I have getch() maybe I should make pause with it...
8. Oh wait! The pause automatically translates the default message... So...

Finally, I said to myself, well I guess the show option is good enough, all you need to do is let the user put a puts or print before the invisible pause... Or the user can samply fork a custom pause function using getch and print if not satisfied :p

But if it didn't have the translation benefit, there's no reason Not to change it... Good question though! Maybe I'll come up with something and maybe replace it in the future... We'll see...

Cheers! Open to all suggestions and comments! Don't be shy...
Why ahkscript.org? - autohotkey.com is outdated

joedf
  • Administrators
  • 986 posts
  • AutoHotkey Foundation
  • Last active: Jul 18 2017 06:01 PM
  • Joined: 20 May 2012

Update Library v1.0.1.5

-

Note: The Docs still needs work, as do the comments as well... :p (will do)

-

added some comments for convenience
added functions: getConsoleHandle
		 flushInput
		 getFontSize
		 getFontWidth
		 getFontHeight
		 setConsoleSize
		 LibConError
		 getConsoleCursorPosition
		 SetConsoleCursorPosition
		 GetConsoleOriginalTitle
		 GetConsoleTitle
		 SetConsoleTitle
		 GetConsoleInputCP
		 SetConsoleInputCP
		 SetConsoleOutputCP
		 GetConsoleOutputCP
		 printW
		 printWf
		 putsW
		 putsWf
				 
added: Unicode Support (Output) + (Input soon)
added: Basic ErrorHandling: using LibConError()
added: ;Default settings
	   SetWinDelay, 0
	   SetBatchLines,-1
added: LONG to sType()

Regards


Why ahkscript.org? - autohotkey.com is outdated

joedf
  • Administrators
  • 986 posts
  • AutoHotkey Foundation
  • Last active: Jul 18 2017 06:01 PM
  • Joined: 20 May 2012

the Docs have been updated. ;)

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


Why ahkscript.org? - autohotkey.com is outdated

joedf
  • Administrators
  • 986 posts
  • AutoHotkey Foundation
  • Last active: Jul 18 2017 06:01 PM
  • Joined: 20 May 2012

Should Args be added?

 

Usage example:

if (args) {
	putsf("argc = %s",args[0])
	loop % args[0]
		putsf("%s: %s",A_Index,args[A_Index])
	putsf("args (CSV Format): %s",args.CSV)
	newline()
}

Execute: 

example.ahk argument1 arg2 "The third argument"

Output: 

argc = 3
1: argument1
2: arg2
3: The third argument
args (CSV Format): "argument1","arg2","The third argument" 

Suggestions?


Why ahkscript.org? - autohotkey.com is outdated

joedf
  • Administrators
  • 986 posts
  • AutoHotkey Foundation
  • Last active: Jul 18 2017 06:01 PM
  • Joined: 20 May 2012

"The Unicode Update" (v1.0.2.0)
View On GitHub Here

 

Also, use LibCon_Compiler.ahk to compile your console scripts :)
 
cheers! wink.png


Why ahkscript.org? - autohotkey.com is outdated

mmoole
  • Members
  • 8 posts
  • Last active: Jan 04 2019 07:52 PM
  • Joined: 19 Aug 2013

Many Thanks for this Lib!  Very very appreciated!!

 

When I run it as part of some other command line tools, I get an error message:

---------------------------
LibConError
---------------------------
print() Failure
Errorlevel: 0
A_LastError: 6

Will now Exit.
---------------------------
Abbrechen   Wiederholen   Ignorieren   
---------------------------
 

I am only using the print function (and initialize before) - so it works well when running manually from command line.

But when the script is executed by another tool, which is the use case, this error happens. It may be important to note that this other batch tool does not display a console window and can be run by another user account. However console output such as from xcopy is captured and will appear in a log afterwards.

The aim is that the autohotkey script also creates text output like xcopy so that this is recorded into the log.

 

greetings



joedf
  • Administrators
  • 986 posts
  • AutoHotkey Foundation
  • Last active: Jul 18 2017 06:01 PM
  • Joined: 20 May 2012
That is weird... Hmm
I will investigate further tonight,
According to the Windows Error codes,
Error "6" is Invalid Handle, I think I might know what the problem is.

By the way, what is your setup?
Windows XP? Win7?
Autohotkey v1.1.13.01? Unicode? 64bit?
I need to be able to reproduce this error if possible..
Any of this information would be useful..

Thanks, regards ;)
Why ahkscript.org? - autohotkey.com is outdated

mmoole
  • Members
  • 8 posts
  • Last active: Jan 04 2019 07:52 PM
  • Joined: 19 Aug 2013

Hi,

 

this is on windows XP 32bit, compiled with the included compiler to 32bit unicode (or ansi, same error), version 1.1.13.01 .

I think that the script is run by some processes, that originate from being run as a service, if that matters.

 

greetings



joedf
  • Administrators
  • 986 posts
  • AutoHotkey Foundation
  • Last active: Jul 18 2017 06:01 PM
  • Joined: 20 May 2012

Hmm, is it possible to have your code?
Don't worry I will not remember nor read nor copy anything. Once I have fixed the bug, I will delete everything.
Regards
 
EDIT: Hope this works?

Spoiler
EDIT 2: I have been able to reproduce the error, i am now trying to fix it ;)

 

EDIT 3: Hopefully fixed!? More info: https://github.com/j...c8310ac0423c32d


Why ahkscript.org? - autohotkey.com is outdated

mmoole
  • Members
  • 8 posts
  • Last active: Jan 04 2019 07:52 PM
  • Joined: 19 Aug 2013

Whow, this was fast!

 

So now with version 1.0.3.7 I dont get any errors now, very nice! B)

On the other side, it still seems that the output does not happen to get captured by the parent process... I tried unicode and Ansi compiled.

I will try to investigate on this,

 

greetings



joedf
  • Administrators
  • 986 posts
  • AutoHotkey Foundation
  • Last active: Jul 18 2017 06:01 PM
  • Joined: 20 May 2012
That's good news! :)
For the output problem,
Could you try this for me Instead?
Replace Your Print("message") calls with
FileAppend, message here, *
The asterisk '*' is very important ;)
Why ahkscript.org? - autohotkey.com is outdated

mmoole
  • Members
  • 8 posts
  • Last active: Jan 04 2019 07:52 PM
  • Joined: 19 Aug 2013

I tried the FileAppend thing first, which is also described in the documentation (using * for stdout), but it didnt work, that's why i researched for more solutions :)

The reason that I cannot get anything put out could also be on the side of the other proprietary tool that runs the script and records the log. I hope to get more info on that...



joedf
  • Administrators
  • 986 posts
  • AutoHotkey Foundation
  • Last active: Jul 18 2017 06:01 PM
  • Joined: 20 May 2012
Oh ok, thanks for your response,
If FileAppend doesn't work, well I cant really do
Anything more... It's possibly on the tool like you said ;)
Why ahkscript.org? - autohotkey.com is outdated