Jump to content
Sign in to follow this  
Morthawt

ControlSend is messing up textual casing Aa _- "2 in a telnet window

Recommended Posts

Morthawt

DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 1)
$hTelnet = Run('c:\windows\system32\telnet.exe 127.0.0.1 10011', '', @SW_SHOW)
DllCall("kernel32.dll", "int", "Wow64EnableWow64FsRedirection", "int", 1)
Sleep(2000)
ControlSend('Telnet 127.0.0.1', '', '', 'use port=9987' & @CRLF, 1)
Sleep(2000)
ControlSend('Telnet 127.0.0.1', '', '', 'clientupdate client_nickname="Tester' & Random(1, 1234567, 1) & '"' & @CRLF, 1)
Sleep(2000)
ControlSend('Telnet 127.0.0.1', '', '', 'whoami' & @CRLF, 1)
Sleep(3000)
ProcessClose($hTelnet)
Exit 

Updated at the bottom to reflect my more rounded down issue. It isn't that telnet is not sending more than 1 command it is sending all commands but messing up case, which is why the first command was fine because everything was lowercase.

Here is the background on what I am trying to do. If you download the free TeamSpeak 3  server and connect to it with a client you can make a bookmark to 127.0.0.1 and show query clients. Once connected  via the bookmark you can then telnet to port 10011 and type commands.

Once the initial telnet connection is established I set it to communicate with the correct virtualserver port which is 9987 by default. Then I try and do something simple such as change the name it appears as in the list when you are viewing query clients.

The problem? Running the compiled exe via a scheduled task, for some reason it only types the initial command to connect to the virtual server port running on 9987 but it will not type any further commands, as you would see if you did this test the username is your own local IP address rather than the name of "Tester 902"

The script works fine when executed manually yet only gets to perform 1 telnet command and then fails for all others?

Anyone have any ideas on this? I need it to be hidden yet still type the needed commands. I do not get into way over the top complicated things like manually doing network connections, sending and receiving network commands via autoit or convoluted winAPI things yet I don't want a simple "keep it on the screen, block inputs while I click and type" because then you have to stop what you are doing when it happens. Ideally I would like to use a tweaked/fixed version of this script. While I am open to other possibilities to perform these actions I only use something if I fully understand what ever it is in it's entirety. I never use external user defined functions if I do not understand parts of it because if it were to ever break down with a new version of autoit and the UDF was unsupported I couldn't fix it myself. So I am just trying to automate telnet since telnet does all the connection things that I need and so should be able to just automate that to get the job done via a scheduled task, hidden off screen. I tried to use STDIN for a command line alternative to telnet called Plink but I can never actually even manually type into the box once it connects, let alone automate typing in the box. So it seems standard Telnet is my best bet.

Additional information before submitting:

I have done some testing and updated the script. The issue is it seems focus of other windows while it is sending direct to the correct control is leading it to be missing the {SHIFT} aspects of the string to be sent to the control. I say "Tester" and it says 2tester2 or Something_Here and it sends instead something-here

Any ideas? I think this may be a legitimate bug since it is sending strings, it just many times due to lack of focus loses the uppercase characters and thus is sending lowercase whether letters or symbols. You know what I mean.

Edit:

I have tried compiling as both 86 and 64 format and it doesn't change the fact that running normally, manually and clicking off the window at varying levels of speed upon telnet loading causes the case to be lost, thus making incorrect symbols and text casing. Also the problem exists every time when running the compiled script as a scheduled task.

Edited by Morthawt

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Similar Content

    • Byte11
      By Byte11
      WinSetState ("[CLASS:OpusApp]", "", @SW_SHOWMAXIMIZED) and WinSetState ("[CLASS:OpusApp]", "", @SW_MAXIMIZE) don't maximize the window.  Using WinSetState("[CLASS:OpusApp]","",@SW_RESTORE) allows me to maximize it about 15% of the time. I've tried using  WinMove("[active]",0,0,@Desktopwidth,@Desktopheight), but that only makes it worse. I've also tried putting in a sleep and maximizing it again. Does anyone have a solution?
      Here's my code:
      The startup script is intentionally commented, because I'm not testing it right now. The other comment is just for debugging when I need it. 
       
      UPDATE: When I run two instances of the program, it works almost all the time, but if I copy the code inside the else statement twice it doesn't work at all (despite the fact that it's running the same code just in one program vs two). I also noticed that when I run two instances of it, about 50% of the time when it opens both the windows, it also hits the windows button and types the letter d into the search box. Neither of these actions are in my code. I'm not really sure what's going on. 
    • distancesprinter
      By distancesprinter
      _ArrayDisplay($aArray, "Window Title", "1:", 0, Default, "Column") ; Expected results are rows 1 to the end of the array, all columns. The result is rows 0-1, all columns. The API reference is here:
      https://www.autoitscript.com/autoit3/docs/libfunctions/_ArrayDisplay.htm
       
      Am I doing something wrong?
    • imitto
      By imitto
      Hi!
      I just playing around with _ArrayMin for my next project, but seems like it's not working. I think the code is OK, but I always get the value of $aArray[2][1], not col 2's lowest value (see attached image)

    • nss
      By nss
      Hi all.
       
      Because of me wondering if I could access the key/value pair arrays with the numbers as indexes, I have found out that the zeroth element for some reason doesn't return anything.
      Here's the example:
       
      local $r[2] $r["test1"]="hello" $r["test2"]="how are you" msgbox(64, $r[0], $r[1]) ; prints the ["test2"] but not ["test1"]. Is this even supposed to be a thing?  
       
      BTW, I haven't seen Autoit get updated since 2015; is it abandened or something?
      Any help/clarification appreciated.
    • TheDcoder
      By TheDcoder
      Hello everyone, I discovered a bug yesterday and I posted it at the bug tracker:
      I also made a simple script which can be used to reproduce the bug:
      CreateVariable() ConsoleWrite($sGlobalVariable & @CRLF) Func CreateVariable() Global $sGlobalVariable = "Foobar" EndFunc The bug was closed by @BrewManNH:
      While I partially agree with the above statement, My code was not practical enough... so @mLipok advised me to create a thread on the forums with practical code (Thanks!). That is the point of this thread, I am going to provide the code where I experience this bug/problem .
      I discovered this bug when I was working on one of my projects called "ProxAllium". When the main script finishes execution, Au3Check throws a nasty warning about "variable possibly used before declaration":

      As you can see, the variable is indeed being used after calling the function in which the variable is declared... The warning won't appear if I declare the function ABOVE the variable. As @BrewManNH said, Au3Check reads line by line... I think this should be changed, Au3Check should not throw warnings if the interpreter is able to run the code, at least most of the time anyway!
      So what do you guys think? Is this a valid bug?... and I request those who participate in the discussion not to discuss the code being "poor", that is another thing/thread in itself
      P.S I had already written this once but the forum editor decided to mess up and when I undid (Ctrl + Z) something... This is a poorly written version of that article, I was very frustrated while writing this!
×