Update:2021/06/26
* Please check the change log on the AHK v2 version here. The AHK v1 and v2 versions are now aligned again.
* This might be the last update for the v1 version. We'll see...
Update:2020/11/12
* Fixed improper placement of CRLF when re-attaching the prompt.
Update:2020/10/23
Very minor update: Previous changes required the user to start command line commands with "cmd ...". This is no longer required. While limiting, it was easier to ensure success when running commands. Now that this limitation is removed the user must ensure care is taken to execute commands in a way that will succeed and must know what happens when running a particular program without the CMD shell.
Update:2020/09/28
Improved consistency of operation across modes, optimized code
Added QuitStringCallback() for user defined quit string.
Fixed handling of ADB environment. Prompt consistently shown after command execution.
Finished documentation comments (top of the script).
Added ConsoleSend() method for proper usage of StdIn using mode "m" (thanks @lexikos!)
Added GetLastLine(str) method for usage in callbacks to filter output.
Update:2020/07/31
Uploaded changes for AHK v2-a119
moved v2 version to v2 forum
Update:2020/05/26
added CLI object as parameters to callback functions
.output has been renamed to .stdout
.error has been renamed to .stderr
now when using stdout / stderr callback functions .stdout and .stderr will continue to accumulate so you can check or clear these values as needed
examples have been updated to reflect the changes
OP updated to show current list of prompts / shells supported with cliPromptCallback() function
Update: 2020/05/24
add mode f to filter control codes from SSH prompt
added prompt detection for SSH prompt
Update: 2020/05/20
moved to GitHub
cleaned up help comments in library
finally released AHKv2 version!
Update: 2020/02/06
Improved mode "m" to allow batch commands.
Fixed mode "m" handling of FreeConsole and AttachConsole when sending CTRL signals
(myObj.CtrlC() would kill the script in some cases)
Improved batch command handling in mode "b" and "m"
StdOutCallback() function recieves "__Batch Finished__" when complete
Details of their contributions are in the comments of the CLI class library. They have done a LOT. Without their contributions, I would not have gained the knowledge or the means to make this.
I'm happy to hear any commets/critiques to make this library more useful, fast, and memory-efficient.
Last edited by TheArkive on 26 Jun 2021, 05:56, edited 56 times in total.
@burque505, glad this worked out for ya ... I was wondering if anyone would get any usage out of this. Saw your post in MsgBox2 as well. I'll be posting an AHK v2 version of those soon.
TheArkive Thank you for this wonderful Class. I am considering using it for a medium-sized work.
I did several amateur tests. Not everything can be done in a single line, this is a bit difficult, but there are many good features for the future.
I was curious to do something.
Is it possible to see the whole stream without hiding the console? Yes, I want to get Stdout, but I want everything to appear on the console as well. And when the process is over, the console will not shut down and it will be on standby.
@hasantr
shouldn't be a problem, but you might need to know how big the output is going to be ahead of time.
I'll look into adding an option to detect the output size and to use all the output for the stream. That should also be possible.
EDIT: just took a look at the code... Not sure if it will be possible without predetermining the size. This feature, mode "m", basically reads from the console buffer, not from StdOut. When you resize a console window, of course it can change the display of the streaming output. So the size of the console is the most important factor. If you don't know the dimensions of your output, then you'll just have to use a larger output, but of course the larger the grid specified, the more of a performance hit you risk.
This is not meant for scrolling output, like you would get from StdOut. It sounds like you want to capture StdOut and get the streaming output? I didn't code this class with that feature in mind, but sounds like it should be possible. Though that would be complex. How do you plan on using it?
I thought it would be very normal. Normally the console is not as it works. It works in the background. I learned this. Then I must stop asking for it. I realized that there was an irrelevant request especially for this class.
I want to make an application that will send commands to Android phones with ADB. I wanted the user to be able to see which command went and what he returned, via cmd.
I thought it would be very normal. Normally the console is not as it works. It works in the background. I learned this. Then I must stop asking for it. I realized that there was an irrelevant request especially for this class.
I want to make an application that will send commands to Android phones with ADB. I wanted the user to be able to see which command went and what he returned, via cmd.
I thought it would be very normal. Normally the console is not as it works. It works in the background. I learned this. Then I must stop asking for it. I realized that there was an irrelevant request especially for this class.
I want to make an application that will send commands to Android phones with ADB. I wanted the user to be able to see which command went and what he returned, via cmd.
@hasantr, take a look at GuiCmd.ahk which is unfinished but might work for you if you fix it up.
Regards,
burque505
I wish I had so much knowledge.
Thanks a lot anyway.
I will use the Clisak library for my work. I may need some forward-looking features. Can TheArkive explain the nomenclature to us? What does Clisak mean?
Thanks again to everyone. If some of the statements I wrote strange to you, this is the fault of google translate.
What is the problem you have with the output? If you give me specifics of what kind of behavior you want then maybe I can improve CLISAK. Are you trying to collect StdOut and streaming animations at the same time?
I actually have made my own app that communicates with android phones over ADB, and this class is a core part of it.
Just let me know what you are trying to do man
Show me what ADB commands you are trying to send, and explain what kind of info you are trying to collect. Maybe I can help this way.
@TheArkive was so kind as to answer a question (in remarkable detail) that I've questioned at another thread ...
So just for the records ... and whom it may concern:
"I've seen your class, but haven't seen (while I'm sure it's there) the explicitly requested option (...) to switch off the stealth-mode for debugging? Would you mind pointing out where to find that, or provide a sample command line with its parameter to show how to accomplish that? Thx a lot "
Well, to see his answers regarding my question just click here
Thx for sharing your knowledge with us. Much appreciated
Remember to use [code]CODE[/code]-tags for your multi-line scripts. Stay safe, stay inside, and remember washing your hands for 20 sec !
@BNOLI thanks ... and of course I'm glad to be able to help
I added an edit to my last post in that thread, to explain why my script creates a console window that won't show anything. It's for receiving "Control Signals", ie. CTRL+Break and CTRL+C. Need to have a window for that.