CliSAK class - 2022/11/12 - beta.15

Post your working scripts, libraries and tools.
User avatar
TheArkive
Posts: 1030
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: CliSAK class - 2021/06/26 - a137

26 Jun 2021, 05:53

Update:2021/06/26
  • updated docs
  • enhanced mode "m" to properly use PowerShell
  • "adb" is no longer its own environment, since it runs on top of CMD or PowerShell
  • removed redundant code
  • CMD default params is now just "/K"
  • PowerShell default params is "-NoLogo -NoExit"
  • reworked code for AHK v1 compatibility
  • added AHK v1 wrappers for compatibility
  • moved regex shell detection to properties so those vars are set only once
  • did lots of testing in windows/ADB for both CMD and PowerShell
scatrmind
Posts: 8
Joined: 22 Mar 2021, 11:51

Re: CliSAK class - 2021/07/25 - beta.1

26 Feb 2022, 17:56

Great work here. I am shocked there are not more comments - CliSAK must be working well.

You mentioned using CliSAK with PuTTY/Plink. I am able to get it to work with Plink (essentially using CMD as env and opening an interactive Plink session via the initial command). How can I attach directly to a PuTTY session (PuTTY as env)? The reason I ask is because I am trying to control iOS games using an input device connected to a PC in my left hand and a mouse connected to the iDevice via Bluetooth in my right hand. If I send commands using Plink (via non-interactive comspec Plink command or via CliSAK), D-pad simulated touch events from my left hand get ignored as soon as I move the mouse in my right hand to aim (same thing happens when I perform an actual touch to aim). However, if I have my macro send the same simulated touch commands to a PuTTY window, my simulated D-pad is NOT ignored when a mouse is used or when actual touch events occur. I am sending the commands via ControlSend, but I'd prefer to send them using CliSAK. Thank you.
User avatar
TheArkive
Posts: 1030
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: CliSAK class - 2021/07/25 - beta.1

27 Feb 2022, 04:44

@scatrmind

Since PuTTY is not a cli environment then no it is not possible I'm afraid. But you can use CliSAK as an interactive background session with plink.

If you post your script I may be able to help you figure out what needs to change. But to be honest, I would not expect this script to function well in regards to game input, then again it really depends on how this idea is coded.

If you were to setup an interactive console, then you would basically be using cli_obj.Write(cmd "`r`n") to send your commands. The promptCallback() func would be your signal that a command was completed successfully and then the next command would then be sent (you would determine if/how/when to send this command in the promptCallback()).

I find this idea a bit fascinating to contemplate, but honestly, I think you are better off using Putty and ControlSend. I think it would be capable of faster response. But if you want to try this "back end" approach, post your script and we'll see what we can do.
scatrmind
Posts: 8
Joined: 22 Mar 2021, 11:51

Re: CliSAK class - 2021/07/25 - beta.1

28 Feb 2022, 17:01

Thank you for the quick response!

As I said, I am able to get Plink to work using cmd.exe as env ("plink.exe" is merely part of the initial session-login command sent). Is there a different way to use Plink with CliSAK? Can "plink" be specified as the env variable?

Using ControlSend alone is pretty slow (even if I change SetKeyDelay) because each character is "typed" to the PuTTY window. So, I am doing the following...

Code: Select all

Clipboard:=""	;Empty the Clipboard or ClipWait does nothing
Clipboard:="autotouch touchDown " . Finger . " " . xi . " " . yi . " `; sleep 0.05 `; autotouch touchUp " . Finger . " " . xi . " " . yi	;Command to be sent to PuTTY
ClipWait, 0.5	;Wait up to 0.5 Seconds for the Clipboard to be populated (will populate nearly instantly)
ControlClick ,, %PuTTY%,,RIGHT	;Paste the command to PuTTY using a Right-Click
ControlSend ,,{Enter}, %PuTTY%	;Press Enter to send command
This method rapidly tosses commands into PuTTY. This works well for unattended iDevice control, but the commands take too long to process for real-time control of a game - I realize the same will be true with CliSAK, too, regardless of the CLI env I choose. I am just exploring various communication options. I'll probably use socket communication via Python for real-time iDevice control, but I'll stick with PuTTY for unattended iDevice control.
User avatar
TheArkive
Posts: 1030
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: CliSAK class - 2021/07/25 - beta.1

01 Mar 2022, 04:45

@scatrmind

Firstly, what version of AHK are you using? Your code looks like v1, and this is the v2 version.

Why not post your partially working plink version? Maybe I can help with that. I'm still not sure why it only "partially works".

scatrmind wrote:
28 Feb 2022, 17:01
Is there a different way to use Plink with CliSAK? Can "plink" be specified as the env variable?

Technically yes, but ... If you directly execute plink.exe with CreateProcess, you will still get a cmd-like environment but without the console, which isn't entirely helpful. It's better to launch in the context of cmd so that you have a consistent framework, like sending "control codes" that are defined per program. Ultimately I've coded this script so that what you are asking for isn't actually possible, but even if it was, I don't think this will work the way you think.

If you need to be able to send keys to the console window, you can do so with cli_obj.KeySequence() method. This is not the same as writing to stdin. This is mostly for sending control codes, such as CTRL+C or whatever is defined for the program you are running.

If you need to send commands to stdin then you use cli_obj.Write() which will return immediately.

So is this a shell within a shell? Are prompts returned during execution?

If you can show me your partially working plink implementation maybe I can help make it work better.
scatrmind
Posts: 8
Joined: 22 Mar 2021, 11:51

Re: CliSAK class - 2021/07/25 - beta.3

01 Mar 2022, 16:27

@TheArkive
My bad. I am using AHK v1, and I am indeed using the version of CliSAK intended for AHK v1. I am sorry that I did not initially notice your link to the v1 forum thread in your first post.

Plink IS fully working with CliSAK. I "thought" there was a difference between sending commands via Plink & CliSAK vs. PuTTY & ControlClick/Send, but I was mistaken - my initial tests were flawed. Below is what works for me. I don't need feedback from the console. Even if a command does not execute properly, the macro will adapt future commands based on what it sees via image recognition (FindText.ahk). Should I be using different options?

Code: Select all

PlinkCmd = plink root@127.0.0.1 -P 22 -pw %RootPword%`r`n
c := new cli(PlinkCmd,"mode:f") ;I don't know if I even really need to use mode f
<do stuff>
PlinkCmd = <insert command here>
c.write(PlinkCmd)
So is this a shell within a shell? Are prompts returned during execution?
I am not entirely sure I understand the first question. Basically, by using the code above, it simulates opening cmd and executing the following command (replacing %RootPword% with the actual password):
plink root@127.0.0.1 -P 22 -pw %RootPword%

Yes; prompts are returned.

Previously, you stated...
...I think you are better off using Putty and ControlSend.
Why would writing to stdin be slower than ControlClick/ControlSend?
Albireo
Posts: 1778
Joined: 16 Oct 2013, 13:53

Re: CliSAK class - 2022/11/12 - beta.15

20 May 2024, 07:56

Could this feature be a solution for me?
One wish is to create an automatic login to an FTP server. This can certainly be solved in several ways.
An example of a command structure
Is this possibly with the CliSAK?
How?
User avatar
TheArkive
Posts: 1030
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: CliSAK class - 2022/11/12 - beta.15

20 May 2024, 12:38

In your case it sounds like you need a cli FTP client. If you have such a program, and if you know how to use it manually, then this library should work for you.
Albireo
Posts: 1778
Joined: 16 Oct 2013, 13:53

Re: CliSAK class - 2022/11/12 - beta.15

20 May 2024, 13:38

TheArkive wrote:
20 May 2024, 12:38
.. it sounds like you need a cli FTP client ..
Any suggestions?
Tried to find MOVEit ® Freely, but failed.
I have tested the program Mtee and it works,
but only manages to create a result file with information from the FTP-server.
My desire would have been to get the response from the FTP server directly into a variable.
User avatar
TheArkive
Posts: 1030
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: CliSAK class - 2022/11/12 - beta.15

22 May 2024, 06:22

I actually don't know of any command line FTP Clients. I'm sure they exist, with varied degrees of useful features. But it sounds like you might want a socket script with FTP protocol. I don't lnow of any FTP protocol scripts off hand. If they exist they are probably written in aHK v1.

Reading a file into a variable over a network connection would most likely not be possible with a cli FTP client. And, using sockets to do this would be also quite complicated, but not impossible.

Edit:

In my signature, under AHK v2 scripts, you can find a basic socket script for AHK v2. Bit you will have to write the FTP protocol yourself.

Return to “Scripts and Functions (v2)”

Who is online

Users browsing this forum: vmech and 41 guests