Bone09 Posted February 4, 2015 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
water Posted February 4, 2015 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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
jdelaney Posted February 4, 2015 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.
Bone09 Posted February 5, 2015 Author 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.
Bone09 Posted February 5, 2015 Author 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.
Bone09 Posted February 5, 2015 Author 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.
water Posted February 5, 2015 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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
water Posted February 5, 2015 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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Bone09 Posted February 6, 2015 Author 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
SadBunny Posted February 6, 2015 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.
Bone09 Posted February 6, 2015 Author 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
water Posted February 6, 2015 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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
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