CiaronJohn Posted December 10, 2019 Posted December 10, 2019 I tried using the code in the past thread: I edited the demo part. #include <WinAPI.au3> #include "ex.au3" Local $cmdtext ;~ $pCmd = Run( "cmd.exe" ) ;~ $pCmd = ProcessExists( "mintty.exe" ) $pCmd = ProcessExists( "cmd.exe" ) Sleep(1000) $hCmd = _CmdGetWindow($pCmd) $hCon = _CmdAttachConsole( $pCmd ) ;~ If _CmdWaitFor( $hCmd, $hCon, "Microsoft Corp", 100 ) Then ;~ If _CmdWaitFor( $hCmd, $hCon, "$ ", 100 ) Then $cmdtext = _CmdGetText( $hCon, True ) I can get the cmd prompt even though it is already running, but cygwin I cannot. Whats the difference maybe? thanks.
junkew Posted December 10, 2019 Posted December 10, 2019 (edited) How do you start cygwin? What can you see with processlist and winlist command? What are spy tools giving for information about the cygwin window. Cygwin can pipe output to /dev/clipboard so with clipget you can get it back in autoit Edited December 10, 2019 by junkew FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
CiaronJohn Posted December 11, 2019 Author Posted December 11, 2019 Hi @junkew, Thanks! I manually start cygwin. I tried editing this function. Func _CmdGetStdHandle($nHandle) ;~ Local $aRet = DllCall("kernel32.dll", "hwnd", "GetStdHandle", "dword", $nHandle) Local $aRet = DllCall("C:\cygwin\bin\cygwin1.dll", "hwnd", "_get_osfhandle", "dword", $nHandle) If @error Then Return SetError(@error, @extended, $INVALID_HANDLE_VALUE) Return $aRet[0] EndFunc ; _CmdGetStdHandle() But i don't know its equivalent to cygwin. there are also constant outputs declared in the past thread posted above. Global Const $STD_INPUT_HANDLE = -10 Global Const $STD_OUTPUT_HANDLE = -11 Global Const $STD_ERROR_HANDLE = -12 i also do not know how to get it.
ViciousXUSMC Posted December 11, 2019 Posted December 11, 2019 Just a FYI related to the thread but not an answer to the question. If you use Windows 10, it has native Linux support now right thru the Windows CMD terminal after you enable the features needed. I am not sure your actual goal, if you just are doing this for fun or trying to use it for some kind of purpose. But if the later this might be a good solution for you.
junkew Posted December 11, 2019 Posted December 11, 2019 Pipe the output to stdout and stderr to a file and just read the file Yourcommand.exe > file.txt 2>&1 FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
CiaronJohn Posted December 11, 2019 Author Posted December 11, 2019 Hi @junkew, and @ViciousXUSMC Thanks! The purpose of reading the cygwin is to check if cleaning the software is done, see screenshot below.
CiaronJohn Posted December 16, 2019 Author Posted December 16, 2019 Thanks @junkew, i created function to check output File. This solved my problem. Func _JAE_Check_OutPutFile($sOutputFile) Local $iRetOutputFile, _ $iFileSize $iRetOutputFile = 0 While (1) ; Sleep for 2 seconds Sleep(2000) $iFileSize = FileGetSize($sOutputFile) ; FileSize will be >0 if done writing If $iFileSize > 0 Then $iRetOutputFile = 1 ExitLoop EndIf WEnd Return $iRetOutputFile EndFunc ; ==>_JAE_Check_OutPutFile
junkew Posted December 17, 2019 Posted December 17, 2019 Be aware you should check for filesize is not growing for nn seconds. Checking for not 0 will probably not work properly when files will be growing bigger. FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
CiaronJohn Posted January 6, 2020 Author Posted January 6, 2020 In my cygwin, file will only have a filesize once the command is finish, if it is not yet done, it is still in 0 byte.
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