weszzer Posted January 12, 2015 Share Posted January 12, 2015 Hi I have a simple command in Autoit similar to the command below. Basically I'm sending a command to a cmd console. after running/opening the cmd window. My question is, how to hide the command that I send to cmd window. I would like to make the command invisible so the user cannot see the command being written in a cmd console. A blank cmd console is fine. Below sample is similar to bigger command I'm working on. Run("cmd.exe") Sleep(1000) Send ("cd\Testfolder") Send ("{Enter}") Send("myApps.exe") Send ("{Enter}") Thank you for the help Link to comment Share on other sites More sharing options...
JohnOne Posted January 12, 2015 Share Posted January 12, 2015 You cannot hide the text you type or send to a command prompt. Can you not just hide the cmd window? Why would you even want to do this, out of curiosity. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Cyber Posted January 12, 2015 Share Posted January 12, 2015 (edited) You can create a .bat file? like this: cd Testfolder myApps.exe save in 12345.bat and: ShellExecute("12345.bat","","","",@SW_HIDE) Edited January 12, 2015 by Cyber behdadsoft 1 Console Browse: Navigate on the WEB in a textual consoleMultiPing!: Show computer on the lan and/or show the local/remote task, ALL animated!KillaWin: Event executingCryptPage: Crypt your webpage and show only with key Link to comment Share on other sites More sharing options...
weszzer Posted January 12, 2015 Author Share Posted January 12, 2015 You cannot hide the text you type or send to a command prompt. Can you not just hide the cmd window? Why would you even want to do this, out of curiosity. Hi JohnOne, My script will send a date and time to command console and execute, then it will open a third party app (running on task manager). The problem is that if I hide the cmd window the text I send to a cmd console via autoit did not execute or not written to the cmd window, I think there something about the focus. Thanks Link to comment Share on other sites More sharing options...
weszzer Posted January 12, 2015 Author Share Posted January 12, 2015 You can create a .bat file? like this: cd Testfolder myApps.exe save in 12345.bat and: ShellExecute("12345.bat","","","",@SW_HIDE) Hi Cyber, sorry for my incomplete example, basically I have a long script that send a different date and other command to the cmd console. then open the myApps.exe that do other commands based on the date given (send using autoit). I would like to hide all the command sent by autoit to the cmd console. this is similar to the @Echo Off, but I don't know how to apply it in Autoit.. Thank you Link to comment Share on other sites More sharing options...
Gianni Posted January 12, 2015 Share Posted January 12, 2015 (edited) If you only want send commands to an hidden CMD prompt, and you do not need to get the otput of the commands sent, then you can simply run an hidden dos prompt with the input stream redirected to your script, and use the input redirected handle to send commands to the prompt. Something like this for example: #include <Constants.au3> $cmd_Pid = Run(@ComSpec & " /k", "", @SW_HIDE, $STDIN_CHILD) ; $STDIN_CHILD (0x1) = Provide a handle to the child's STDIN stream StdinWrite($cmd_Pid, "cd \Testfolder" & @CRLF) StdinWrite($cmd_Pid, "myApps.exe" & @CRLF) ; .... and so on the hidden dos promt will stay hidden and in standby for your commands till your script will end. In this way you can send commands time by time when you need. Edited January 12, 2015 by Chimp Mobius 1 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
JohnOne Posted January 12, 2015 Share Posted January 12, 2015 Try ControlSend. Or Look for console UDF in example scripts, see if that can help. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Gianni Posted January 12, 2015 Share Posted January 12, 2015 (edited) Try ControlSend. Or Look for console UDF in example scripts, see if that can help. I'm not sure, but afraid that ControlSend will not send to a cmd prompt, anyway SendKeepActive() can be used to keep the dos window active while using send() to have better luck to send to the proper destination.. Edited January 12, 2015 by Chimp Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
Exit Posted January 12, 2015 Share Posted January 12, 2015 Opt("SendKeyDelay", 0) Run("cmd.exe") Sleep(1000) Send("cd \Testfolder" & @CRLF) Send("myApps.exe" & @CRLF) Sleep(3000) ; delay to check output. Delete line to continue without delay Send("cls" & @CRLF) App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
Exit Posted January 12, 2015 Share Posted January 12, 2015 Or even better Opt("SendKeyDelay", 0) Run("cmd.exe") $handle = (WinWait("[REGEXPTITLE:cmd.exe]", "", 3) ? (WinActivate("[LAST]") ? WinWaitActive("[LAST]") : 0) : SetError(1, 0, 0)) ControlSend($handle, "", "", "cd \Testfolder" & @CRLF) ControlSend($handle, "", "", "myApps.exe" & @CRLF) Sleep(3000) ; delay to check output. Delete line to continue without delay ControlSend($handle, "", "", "cls" & @CRLF) Sleep(2000) ControlSend($handle, "", "", "exit" & @CRLF) App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
weszzer Posted January 13, 2015 Author Share Posted January 13, 2015 Or even better Opt("SendKeyDelay", 0) Run("cmd.exe") $handle = (WinWait("[REGEXPTITLE:cmd.exe]", "", 3) ? (WinActivate("[LAST]") ? WinWaitActive("[LAST]") : 0) : SetError(1, 0, 0)) ControlSend($handle, "", "", "cd \Testfolder" & @CRLF) ControlSend($handle, "", "", "myApps.exe" & @CRLF) Sleep(3000) ; delay to check output. Delete line to continue without delay ControlSend($handle, "", "", "cls" & @CRLF) Sleep(2000) ControlSend($handle, "", "", "exit" & @CRLF) Exit, thanks for the response. I tried the command but I got this error below $handle = (WinWait("[REGEXPTITLE:cmd.exe]", "", 3) ? (WinActivate("[LAST]") ? WinWaitActive("[LAST]") : 0) : SetError(1, 0, 0)) $handle = (WinWait("[REGEXPTITLE:cmd.exe]", "", 3) ^ ERROR Thanks Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 13, 2015 Moderators Share Posted January 13, 2015 What version of AutoIt are you using? Also, [REGEXPTITLE:cmd.exe], that's is kind of confusing since there's no regular expression there other than the [dot] could equal anything or cmd[any character]exe could be anywhere in the title. Should be [REGEXPTITLE:(?i)cmd.exe$] at the very least. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
weszzer Posted January 13, 2015 Author Share Posted January 13, 2015 What version of AutoIt are you using? Also, [REGEXPTITLE:cmd.exe], that's is kind of confusing since there's no regular expression there other than the [dot] could equal anything or cmd[any character]exe could be anywhere in the title. Should be [REGEXPTITLE:(?i)cmd.exe$] at the very least. SciTE4AutoIt3 Version 1.76 Jun 12 2008 09:52:15 Cheers Link to comment Share on other sites More sharing options...
BrewManNH Posted January 13, 2015 Share Posted January 13, 2015 That's not the AutoIt version, that is the SciTE version number (and it's OLD). If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 13, 2015 Moderators Share Posted January 13, 2015 Well, that says a lot ... considering I'm on a much higher SciTe version, but I asked about your AutoIt version. You probably need to do some updating, I imagine you're using a very old version. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
weszzer Posted January 13, 2015 Author Share Posted January 13, 2015 (edited) If you only want send commands to an hidden CMD prompt, and you do not need to get the otput of the commands sent, then you can simply run an hidden dos prompt with the input stream redirected to your script, and use the input redirected handle to send commands to the prompt. Something like this for example: #include <Constants.au3> $cmd_Pid = Run(@ComSpec & " /k", "", @SW_HIDE, $STDIN_CHILD) ; $STDIN_CHILD (0x1) = Provide a handle to the child's STDIN stream StdinWrite($cmd_Pid, "cd \Testfolder" & @CRLF) StdinWrite($cmd_Pid, "myApps.exe" & @CRLF) ; .... and so on the hidden dos promt will stay hidden and in standby for your commands till your script will end. In this way you can send commands time by time when you need. Hi chimp, thanks for the response. The command didn't showed-up. (because of the "@SW_hide" ?), I tried to change it using @SW_shownormal and @sw_show (just to see what is being written) but the cmd window disappear in flick of an eye. Cheers Edited January 13, 2015 by weszzer Link to comment Share on other sites More sharing options...
weszzer Posted January 13, 2015 Author Share Posted January 13, 2015 That's not the AutoIt version, that is the SciTE version number (and it's OLD). whoa! SciTE4AutoIt3 is the main Autoit application Link to comment Share on other sites More sharing options...
weszzer Posted January 13, 2015 Author Share Posted January 13, 2015 whoa! SciTE4AutoIt3 is the main Autoit application now downloaded and installed a new one. SciTE-Lite Version 3.4.1 Jun 1 2014 18:45:52 Link to comment Share on other sites More sharing options...
weszzer Posted January 13, 2015 Author Share Posted January 13, 2015 H guys, this is my code. basically the extract.exe will execute the command and the date. I would like to hide the " Send ("extract.exe -Date ....) displaying on the cmd window include <date.au3> Run("cmd.exe") Sleep(1000) Send ("{Enter}") Sleep (1000) Send ("cd\testfolder\") Sleep(1000) Send("{Enter}") Send("Extract.exe -Date " & @YEAR &"/" & @MON & "/" & @MDAY-1) ; command should not be visible at the cmd window Sleep(2000) Send("{Enter} Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 13, 2015 Moderators Share Posted January 13, 2015 You've been given solutions. You've not provided needed information... again, what version of AutoIt are you running. MsgBox(0, "Version", @AutoItVersion) Run that and tell us the output. If it's less than 3.3.12.0 then I'd suggest you go here and download the latest AutoIt https://www.autoitscript.com/site/autoit/downloads/ Then after that, download the latest "full version" of scite for autoit (the script editor). Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. 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