Otacon Posted March 8, 2012 Share Posted March 8, 2012 Hi everybody, i'm pretty new to autoit (just discovered it this Monday) and i have banging my head on to following problem. Everything i talk about is running on a remote Windows XP machine, which is only accessed using Remote Desktop. I got a cmd window open, that is running a server, and want to send some keystrokes to it. Right now i do this using the following code. If WinExists ('windowname') Then WinActivate ('windowname') Send ('Hello i am some text {ENTER}') EndIf Which works perfectly fine, at least as long as i am logged in with Remote Desktop. When i close Remote Desktop, the script is no longer working. I think it is because the window can't be active when there is no RDP connection (i don't log off, i just close it so everything keeps running) In theory, it needs be threated like a hidden window. But ControlSend is not working, as i found out today,, it is doesn't work for CMD Windows. Is there any way to still do what i want? Except leaving the RDP connection open. Otherwise i would have do run that command for the server by hand every 6 hours Link to comment Share on other sites More sharing options...
Xenobiologist Posted March 8, 2012 Share Posted March 8, 2012 Why not running an Autoit script as a service on that machnine. Then it could handle everything on its own (without dealing with windows) Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted March 8, 2012 Moderators Share Posted March 8, 2012 Hi, Otacon, welcome to the forum. Depending on what command you're trying to pass to the command window, you could also simply use AutoIt's Run or ShellExecute functions, and then use PSExec (found here) to run it from your remote machine. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Otacon Posted March 10, 2012 Author Share Posted March 10, 2012 (edited) Why not running an Autoit script as a service on that machnine. Then it could handle everything on its own (without dealing with windows)I have to send the command to the existing CMD window which runs a server.I don't want the server to run as a service, as its window is the only way to send commands to it.Hi, Otacon, welcome to the forum. Depending on what command you're trying to pass to the command window, you could also simply use AutoIt's Run or ShellExecute functions, and then use PSExec (found here) to run it from your remote machine.Its an already existing window to which i need to pass commands too for a Server. Things like "Stop {Enter}" or "Save {Enter}"It won't work if i just run a shell command, otherwise it would be quite easy Another thought of me.If i let AutoIt start the server inside a CMD window i opened with AutoIt, would it that change things to send commands to it?As i don't care if the server is started by a *.bat or AutoIt, because that shouldn't matter for the Server at all. Edited March 10, 2012 by Otacon Link to comment Share on other sites More sharing options...
Otacon Posted April 14, 2012 Author Share Posted April 14, 2012 Anybody else has some thoughts to this? I still couldn't manage getting this to work Link to comment Share on other sites More sharing options...
KaFu Posted April 14, 2012 Share Posted April 14, 2012 (edited) This works for me:$hWnd = WinGetHandle("[CLASS:ConsoleWindowClass]", "") ControlSend($hWnd,"","","dir c:" & @crlf)For more advanced stuff take a look at Mats Console.au3 UDF. Edited April 14, 2012 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
DeathRow Posted April 14, 2012 Share Posted April 14, 2012 Its a fucntion to run pure CMD commands via CMD, do u know ? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now