Jump to content

Recommended Posts

Posted

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.

 

 

 

Posted

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.

Posted

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.

Posted

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

  • 3 weeks later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...