Bone09 Posted February 4, 2015 Share Posted February 4, 2015 (edited) Hello everyone, I created a script that sends a series of commands on CMD through the use of 'ControlSend()' function together with 'Sleep()' after every command to ensure that the commands were sent. But when my computer somewhat slowed down, some commands were skipped out. I wonder if there is a function (other than increasing the value of sleep) that waits or detects when it is already time to type in the CMD. Or maybe if there is a function that waits for the 'i-beam' to inform the program that it is already the time to send the commands. Thanks! ; I created a function that sends the commands directly to the cmd regardless whether the window is active or not Func Command($text) $hWnd = WinWait("[CLASS:ConsoleWindowClass]", "", 10) Sleep(500) ControlSend($hWnd, "", "", $text) EndFunc ; This is the main code Run("cmd.exe") Command("This is my first command") Sleep(500) ;for the delay Command("This is my second command") Sleep(50) ;delay again . . . Edited February 4, 2015 by bonsantiago Link to comment Share on other sites More sharing options...
water Posted February 4, 2015 Share Posted February 4, 2015 Most of the time you use StdinWrite and StdoutRead to communicate with CMD. How do you start CMD? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
jdelaney Posted February 4, 2015 Share Posted February 4, 2015 Or just do a Run()...no need to interact with a console. IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
Bone09 Posted February 5, 2015 Author Share Posted February 5, 2015 Most of the time you use StdinWrite and StdoutRead to communicate with CMD. How do you start CMD? I start cmd through Run(cmd.exe) Then followed by the series of commands that I want to send. Link to comment Share on other sites More sharing options...
Bone09 Posted February 5, 2015 Author Share Posted February 5, 2015 Or just do a Run()...no need to interact with a console. I have a series of commands, so i need to interact with the console. Link to comment Share on other sites More sharing options...
pcjunki Posted February 5, 2015 Share Posted February 5, 2015 what are the commands? Link to comment Share on other sites More sharing options...
Bone09 Posted February 5, 2015 Author Share Posted February 5, 2015 what are the commands? For example, Send(GUICtrlRead($UsernameInput) & "{ENTER}") Sleep(500) Send(GUICtrlRead($PasswordInput) & "{ENTER}") Sleep(500) Send("cd /files0/ & "{ENTER}") The Send + Sleep function is not stable and this is why I'm looking for other ways of sending keys in the putty console. Link to comment Share on other sites More sharing options...
water Posted February 5, 2015 Share Posted February 5, 2015 I start cmd through Run(cmd.exe) Then followed by the series of commands that I want to send. Then please have a look at StdinWrite. The example shows how to send commands. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
water Posted February 5, 2015 Share Posted February 5, 2015 Another question. Are you sure the commands you want to run can't be translated to pure AutoIt? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Bone09 Posted February 6, 2015 Author Share Posted February 6, 2015 (edited) Then please have a look at StdinWrite. The example shows how to send commands. Hi, thank you for the response but I cannot use StdinWrite as this function constantly needs a directory path. I'm actually running cmd for the purpose of executing a 3rd party application (for example a java app) through console (access the directory of the 3rd party app ONCE) and run the jar file along with the series of commands Edited February 6, 2015 by Bone09 Link to comment Share on other sites More sharing options...
SadBunny Posted February 6, 2015 Share Posted February 6, 2015 (edited) I cannot use StdinWrite as this function constantly needs a directory path. Can you clarify this statement? What do you mean by a function constantly needing a directory path? There's bound to be better ways to approach this. Also, I still don't see how you need to manually steer cmd.exe to access a directory through keypresses and start a java application? Edited February 6, 2015 by SadBunny Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
Bone09 Posted February 6, 2015 Author Share Posted February 6, 2015 Can you clarify this statement? What do you mean by a function constantly needing a directory path? There's bound to be better ways to approach this. Also, I still don't see how you need to manually steer cmd.exe to access a directory through keypresses and start a java application? The java application is not gui-based. I need to use the console to execute the commands to communicate with the program Link to comment Share on other sites More sharing options...
water Posted February 6, 2015 Share Posted February 6, 2015 That is exactly what the STDxxx functions are being made for. You can send commands to the application, read the displayed data, then send another command etc. Just give them a try. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki 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