netegg 发表于 2013-3-29 11:32:52

说的是shell吧,用api

Qokelate 发表于 2013-3-31 00:04:04

回复 3# mbdnmt


    要使这种环境得到继续就必须得是CMD第一次调用的子进程或同一个CMD进程,因此可以考虑 StdinWrite 方法,把第二个命令"写入"到命令行

lpxx 发表于 2013-4-1 11:30:09

我收集的,看看对你有没有参考


#include <GuiButton.au3>
#include <GuiImageList.au3>
#include <Constants.au3>
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <GUIEdit.au3>
#include <Misc.au3>
#include <ScrollBarConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Opt("CaretCoordMode", 0)
Global $aPalette = [0xFFFFFF, 0x000000, 0xC0C0C0, 0x808080, _
                0xFF0000, 0x800000, 0xFFFF00, 0x808000, _
                0x00FF00, 0x008000, 0x00FFFF, 0x008080, _
                0x0000FF, 0x000080, 0xFF00FF, 0x800080, _
                0xC0DCC0, 0xA6CAF0, 0xFFFBF0, 0xA0A0A4, 0xABCDEF]

Global Const $hFullScreen = WinGetHandle("")
Global Const $aFullScreen = WinGetPos($hFullScreen)

_GDIPlus_Startup()
Global Const $iW = 736, $iH = 369, $sFont = "Fixedsys"
Global $iFGColor = 0xC0C0C0, $iBGColor = 0x000000, $__Enum
Global Const $hGUI = GUICreate("DOS回显", 736, 450, -1, -1, -1, $WS_EX_CONTEXTHELP + $WS_EX_ACCEPTFILES)
Global Const $idEdit = GUICtrlCreateEdit($hGUI, 0, 0, $iW, $iH, BitOR($ES_AUTOVSCROLL, $WS_HSCROLL, $WS_VSCROLL, $ES_MULTILINE, $ES_WANTRETURN))
Global Const $hEdit = GUICtrlGetHandle($idEdit)
Global $sCMDLine = @HomeDrive & @HomePath
Global $sPrefix = StringStripWS(StringStripCR(ExecuteCMD("ver")), 3)
Global $iPrefixLen = StringLen($sCMDLine & ">")
Global Const $iColorTxt = $iFGColor
GUICtrlSetData($idEdit, $sPrefix & @CRLF & _
                "Copyright (c) 2009 Microsoft Corporation.All rights reserved." & @CRLF & @CRLF)
GUICtrlSetFont($idEdit, 12, 400, 0, $sFont, 5)
GUICtrlSetColor($idEdit, $iColorTxt)
GUICtrlSetBkColor($idEdit, $iBGColor)
_GUICtrlEdit_SetLimitText($hEdit, -1)

Global Const $iStartx = 30, $iBtnWidth = 80, $iStarty = 390
Global Const $idButton_Dir = GUICtrlCreateButton("Dir", $iStartx, $iStarty, $iBtnWidth, 40)
Global Const $hButton_Dir = GUICtrlGetHandle($idButton_Dir)
Global Const $sButton_DirNN = _WinAPI_GetClassName($hButton_Dir) & _GetNN($hButton_Dir)

Global Const $idButton_IPC = GUICtrlCreateButton("IPConfig", 2 * $iStartx + 1 * $iBtnWidth, $iStarty, $iBtnWidth, 40)
Global Const $hButton_IPC = GUICtrlGetHandle($idButton_IPC)
Global Const $sButton_IPCNN = _WinAPI_GetClassName($hButton_IPC) & _GetNN($hButton_IPC)

Global Const $idButton_Ping = GUICtrlCreateButton("Ping", 3 * $iStartx + 2 * $iBtnWidth, $iStarty, $iBtnWidth, 40)
Global Const $hButton_Ping = GUICtrlGetHandle($idButton_Ping)
Global Const $sButton_PingNN = _WinAPI_GetClassName($hButton_Ping) & _GetNN($hButton_Ping)

Global Const $idButton_RunBatch = GUICtrlCreateButton("运行批处理", 4 * $iStartx + 3 * $iBtnWidth, $iStarty, $iBtnWidth, 40, $BS_DEFPUSHBUTTON)
GUICtrlSetBkColor(-1, 0xE0FFE0)
Global Const $hButton_RunBatch = GUICtrlGetHandle($idButton_RunBatch)
Global Const $sButton_RunBatchNN = _WinAPI_GetClassName($hButton_RunBatch) & _GetNN($hButton_RunBatch)

Global Const $idButton_Exit = GUICtrlCreateButton("退出", $iW - $iBtnWidth - $iStartx, $iStarty, $iBtnWidth, 40)
Global Const $hButton_Exit = GUICtrlGetHandle($idButton_Exit)
Global Const $sButton_ExitNN = _WinAPI_GetClassName($hButton_Exit) & _GetNN($hButton_Exit)

Global Const $idLable_ChgBGColor = GUICtrlCreateLabel("更改背景色", 5 * $iStartx + 4 * $iBtnWidth, $iStarty - 10)
Global Const $idLable_ChgFGColor = GUICtrlCreateLabel("更改字体颜色", 5 * $iStartx + 4 * $iBtnWidth, $iStarty + 14)
Global Const $idLable_ChgFont = GUICtrlCreateLabel("更改字体", 5 * $iStartx + 4 * $iBtnWidth, $iStarty + 36)
Global $iStyle = $BS_SPLITBUTTON + $BCSS_NOSPLIT
If @OSBuild < 6000 Then $iStyle = Default
Global Const $idButton_ChgBGColor = GUICtrlCreateButton("", 5 * $iStartx + 4 * $iBtnWidth + 92, $iStarty - 12, 40, 18, $iStyle)
Global Const $hButton_ChgBGColor = GUICtrlGetHandle($idButton_ChgBGColor)
Global Const $sButton_ChgBGColorNN = _WinAPI_GetClassName($hButton_ChgBGColor) & _GetNN($hButton_ChgBGColor)
_GUICtrlButton_SetSplitInfo($hButton_ChgBGColor, -1, $BCSS_NOSPLIT)

Global Const $idButton_ChgFGColor = GUICtrlCreateButton("", 5 * $iStartx + 4 * $iBtnWidth + 92, $iStarty + 12, 40, 18, $iStyle)
Global Const $hButton_ChgFGColor = GUICtrlGetHandle($idButton_ChgFGColor)
Global Const $sButton_ChgFGColorNN = _WinAPI_GetClassName($hButton_ChgFGColor) & _GetNN($hButton_ChgFGColor)
_GUICtrlButton_SetSplitInfo($hButton_ChgFGColor, -1, $BCSS_NOSPLIT)

Global Const $idButton_ChgFont = GUICtrlCreateButton("...", 5 * $iStartx + 4 * $iBtnWidth + 92, $iStarty + 34, 40, 18, $BS_TOP)
Global Const $hButton_ChgFont = GUICtrlGetHandle($idButton_ChgFont)
Global Const $sButton_ChgFontNN = _WinAPI_GetClassName($hButton_ChgFont) & _GetNN($hButton_ChgFont)

Global $hImage_BG = _GUIImageList_Create(14, 10, 5, 3)
Global $hBmp_BG = _WinAPI_CreateSolidBitmap($hButton_ChgBGColor, $iBGColor, 14, 10)
_GUIImageList_Add($hImage_BG, $hBmp_BG)
_GUICtrlButton_SetImageList($hButton_ChgBGColor, $hImage_BG, 1)

Global $hImage_FG = _GUIImageList_Create(14, 10, 5, 3)
_GUIImageList_Add($hImage_FG, _WinAPI_CreateSolidBitmap($hButton_ChgFGColor, $iFGColor, 14, 10))
_GUICtrlButton_SetImageList($hButton_ChgFGColor, $hImage_FG, 1)

Global $hBitmap = CreateCaretBitmap()
Global $aBlinkTime = DllCall('user32.dll', 'int', 'GetCaretBlinkTime')
Global $iBlinkTime_save = $aBlinkTime
Global $iBlinkTime = Int($aBlinkTime * 0.9)
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

GUISetState()

_GUICtrlEdit_AppendText($hEdit, $sCMDLine & ">")
GUISetIcon(@SystemDir & "\cmd.exe", 0, $hGUI)
;~ ControlClick("", "", $idEdit)
Global $aCaretPos, $sFile, $aFont
Global $hEditWndProc = DllCallbackRegister("EditWndProc", "lresult", "hwnd;uint;wparam;lparam")
Global $hOldEditProc = _WinAPI_SetWindowLong($hEdit, $GWL_WNDPROC, DllCallbackGetPtr($hEditWndProc))

$aCaretPos = GetCaretPos()

Global Const $WM_DROPFILES = 0x0233
;~ DllCall('user32.dll', 'int', 'SetCaretPos', 'int', $aCaretPos + 100, 'int', $aCaretPos)
GUIRegisterMsg($WM_DROPFILES, "WM_DROPFILES")

Do
        Switch GUIGetMsg()
                Case $GUI_EVENT_CLOSE, $idButton_Exit
                        GUIRegisterMsg($WM_DROPFILES, "")
                        GUIRegisterMsg($WM_COMMAND, "")
                        _WinAPI_DeleteObject($hBmp_BG)
                        _GUIImageList_Destroy($hImage_BG)
                        _GUIImageList_Destroy($hImage_FG)
                        _WinAPI_DeleteObject($hBitmap)
                        _WinAPI_SetWindowLong($hEdit, $GWL_WNDPROC, $hOldEditProc)
                        DllCallbackFree($hEditWndProc)
                        DllCall('user32.dll', 'int', 'SetCaretBlinkTime', 'uint', $iBlinkTime_save)
                        _GDIPlus_Shutdown()
                        GUIDelete()
                        Exit
                Case $idButton_Dir
                        If ControlGetFocus($hGUI) <> $sButton_DirNN Then ContinueCase
                        SendCommand2CMD("dir")
                Case $idButton_IPC
                        If ControlGetFocus($hGUI) <> $sButton_IPCNN Then ContinueCase
                        SendCommand2CMD("ipconfig")
                Case $idButton_Ping
                        If ControlGetFocus($hGUI) <> $sButton_PingNN Then ContinueCase
                        SendCommand2CMD("ping www.autoitx.com -n 10")
                Case $idButton_RunBatch
                        If ControlGetFocus($hGUI) <> $sButton_RunBatchNN Then ContinueCase
                        $sFile = FileOpenDialog("选择你想执行的批处理文件", "", "Bat文件(*.cmd; *.bat)", 3, "", $hGUI)
                        If @error Then
                                MsgBox(64, "信息", "已终止", 5, $hGUI)
                                ContinueCase
                        EndIf
                        SendCommand2CMD($sFile)
                Case $idButton_ChgBGColor
                        If ControlGetFocus($hGUI) <> $sButton_ChgBGColorNN Then ContinueCase
                        ChooseColorBG($hGUI, $hButton_ChgBGColor, $aPalette, $hImage_BG, "BG")
                Case $idButton_ChgFGColor
                        If ControlGetFocus($hGUI) <> $sButton_ChgFGColorNN Then ContinueCase
                        ChooseColorBG($hGUI, $hButton_ChgFGColor, $aPalette, $hImage_FG, "FG")
                Case $idButton_ChgFont
                        If ControlGetFocus($hGUI) <> $sButton_ChgFontNN Then ContinueCase
                        $aFont = _ChooseFont($sFont, 10, 0, 600, False, False, False, $hGUI)
                        If @error Then ContinueLoop
                        GUICtrlSetFont($idEdit, $aFont, $aFont, $aFont, $aFont, 5)
                        ControlFocus($hGUI, "", $idEdit)
        EndSwitch
Until False

Func ChooseColorBG($hGUI, $hControl, ByRef $aPalette, $hImageList, $xG)
        GUISetState(@SW_DISABLE, $hGUI)
        Local $aCtrlPos = MouseGetPos()
        Local Const $iUB = UBound($aPalette) - 1, $iWX = 4, $iWY = 5
        Local Const $dx = 4, $dy = 4, $iSizeW = 24, $iSizeH = 24
        Local $iW = $iWX * ($iSizeW + $dx) - $dx, $iH = $iWY * ($iSizeH + $dy) - $dy + 45
        Local $iX = $aCtrlPos - $dx, $iY = $aCtrlPos - $dy
        If ($iX + $iW) > $aFullScreen Then $iX -= $iW - $dx * 2
        If ($iY + $iH) > $aFullScreen Then $iY -= $iH - $dy * 2
        Local Const $hGUI_Color = GUICreate("", $iW, $iH, $iX, $iY, $WS_POPUP, $WS_EX_DLGMODALFRAME, $hGUI)
        Local Const $idButton_CC = GUICtrlCreateButton("更多", $iW / 2 - 30, $iWY * ($iSizeH + $dy) + 5, 60, 30)
        Local $x, $y, $z
        Local $aCLabels[$iUB]
        While $z < $iUB
                $aCLabels[$z] = GUICtrlCreateLabel("", $x * ($iSizeW + $dx), $y * ($iSizeH + $dy), $iSizeW, $iSizeH, $SS_SUNKEN)
                GUICtrlSetBkColor($aCLabels[$z], $aPalette[$z])
                $x = Mod($x + 1, $iWX)
                If Not $x Then $y += 1
                $z += 1
        WEnd
        Local Const $min = $aCLabels, $max = $aCLabels + UBound($aCLabels) - 1
        GUISetState(@SW_SHOW, $hGUI_Color)
        Local $aInfo, $c
        Do
                Switch GUIGetMsg()
                        Case $GUI_EVENT_CLOSE
                                ExitLoop
                        Case $idButton_CC
                                $c = _ChooseColor(2, 0, 2, $hGUI_Color)
                                If @error Then ContinueLoop
                                $aPalette[$iUB] = "0x" & Hex($c, 6)
                                ChangeColor($max + 1, $min, $hControl, $hImageList, $xG)
                                ExitLoop
                EndSwitch
                $aInfo = GUIGetCursorInfo($hGUI_Color)
                Switch $aInfo
                        Case 1
                                If $aInfo >= $min And $aInfo <= $max Then
                                        ChangeColor($aInfo, $min, $hControl, $hImageList, $xG)
                                        ExitLoop
                                EndIf
                EndSwitch
        Until False
        GUISetState(@SW_ENABLE, $hGUI)
        GUIDelete($hGUI_Color)
        ControlFocus($hGUI, "", $idEdit)
EndFunc   ;==>ChooseColorBG

Func ChangeColor($iID, $min, $hControl, $hImageList, $xG)
        _GUIImageList_Remove($hImageList)
        _WinAPI_DeleteObject($hBmp_BG)
        Local Const $iColor = $aPalette[$iID - $min]
        $hBmp_BG = _WinAPI_CreateSolidBitmap($hControl, $iColor, 14, 10)
        _GUIImageList_Add($hImageList, $hBmp_BG)
        _GUICtrlButton_SetImageList($hControl, $hImageList, 1)
        If $xG = "BG" Then
                GUICtrlSetBkColor($idEdit, $iColor)
        Else
                GUICtrlSetColor($idEdit, $iColor)
                _WinAPI_DeleteObject($hBitmap)
                $hBitmap = CreateCaretBitmap(9, 14, "0xFF" & Hex($iColor, 6))
        EndIf
EndFunc   ;==>ChangeColor

Func SendCommand2CMD($sCommand)
        ControlFocus($hGUI, "", $idEdit)
        ControlSend($hGUI, "", $idEdit, $sCommand & @LF)
EndFunc   ;==>SendCommand2CMD

Func EditWndProc($hWnd, $iMsg, $wParam, $lParam)
        Switch $iMsg
                Case $WM_KEYDOWN
                        Switch $wParam
                                Case 0x25
                                        $aCaretPos = GetCaretPos()
                                        If ($aCaretPos / 9) <= $iPrefixLen Then
                                                DllCall('user32.dll', 'int', 'SetCaretPos', 'int', $aCaretPos + 1, 'int', $aCaretPos)
                                                $aCaretPos = GetCaretPos()
                                                Return 1
                                        EndIf
                                Case 0x0D
                                        Local $sCMD = StringMid(_GUICtrlEdit_GetLine($hEdit, _GUICtrlEdit_LineFromChar($hEdit)), $iPrefixLen + 1)
                                        If $sCMD <> "" Then
                                                ExecuteCMDRT($sCMD)
                                                $sCMDLine = StringReplace(ExecuteCMD("cd"), @CRLF, "")
                                                ExecuteCMD("cd /d " & $sCMDLine)
                                        EndIf
                                        $iPrefixLen = StringLen($sCMDLine & ">")
                                        _GUICtrlEdit_AppendText($hEdit, $sCMDLine & ">")
                                        _GUICtrlEdit_SetSel($hEdit, -1, -1)
                                        _GUICtrlEdit_Scroll($hEdit, $SB_SCROLLCARET)
                                        $aCaretPos = GetCaretPos()
                                        Sleep(30)
                                        Return 1
                                Case 0x08, 0x24, 0x26, 0x28
                                        If _GUICtrlEdit_LineLength($hEdit) < $iPrefixLen Then
                                                _GUICtrlEdit_AppendText($hEdit, ">")
                                                $aCaretPos = GetCaretPos()
                                        EndIf
                                        Return 1
                        EndSwitch
                Case $WM_LBUTTONDOWN
                        DllCall('user32.dll', 'int', 'SetCaretPos', 'int', $aCaretPos, 'int', $aCaretPos)
                        Return 1
        EndSwitch
        Return _WinAPI_CallWindowProc($hOldEditProc, $hWnd, $iMsg, $wParam, $lParam)
EndFunc   ;==>EditWndProc

Func GetCaretPos() ;http://msdn.microsoft.com/en-us/library/ms648402(v=vs.85).aspx
        Local Const $Point = "LONG x;LONG y;"
        Local $sPoint = DllStructCreate($Point)
        DllCall("User32.dll", "int", "GetCaretPos", "ptr", DllStructGetPtr($sPoint))
        Local $aPos =
        Return $aPos
EndFunc   ;==>GetCaretPos

Func ExecuteCMDRT($sCommand)
        Local $iPID, $line
        If StringMid($sCommand, 2, 1) = ":" Then
                $iPID = Run(@ComSpec & ' /c "' & $sCommand & '"', StringRegExpReplace($sCommand, "(.+\\)(.*)", "$1"), @SW_HIDE, $STDERR_MERGED) ;set working dir to path of file
        Else
                $iPID = Run(@ComSpec & ' /c "' & $sCommand & '"', $sCMDLine, @SW_HIDE, $STDERR_MERGED)
        EndIf
        While 1
                $line = StdoutRead($iPID)
                If @error Then ExitLoop
                _GUICtrlEdit_AppendText($hEdit, Oem2Ansi($line))
        WEnd
        _GUICtrlEdit_AppendText($hEdit, @CRLF)
EndFunc   ;==>ExecuteCMDRT

Func ExecuteCMD($sCommand)
        Local $iPID = Run(@ComSpec & ' /c "' & $sCommand & '"', $sCMDLine, @SW_HIDE, $STDERR_MERGED)
        Local $line
        While 1
                $line &= StdoutRead($iPID)
                If @error Then ExitLoop
        WEnd
        Return Oem2Ansi($line)
EndFunc   ;==>ExecuteCMD

Func Oem2Ansi($Text)
        Local $aText = DllCall("user32.dll", "Int", "OemToChar", "str", $Text, "str", "")
        Return $aText
EndFunc   ;==>Oem2Ansi

Func CreateCaretBitmap($iW = 9, $iH = 14, $iColor = 0xFFC0C0C0)
        Local Const $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iW, "int", $iH, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0)
        Local Const $hBitmap = $aResult
        Local Const $hCtx = _GDIPlus_ImageGetGraphicsContext($hBitmap)
        Local Const $hBrush = _GDIPlus_BrushCreateSolid($iColor)
        _GDIPlus_GraphicsFillRect($hCtx, 0, $iH - 3, $iW, $iH, $hBrush)
        _GDIPlus_BrushDispose($hBrush)
        _GDIPlus_GraphicsDispose($hCtx)
        Local $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
        _GDIPlus_BitmapDispose($hBitmap)
        Return $hHBitmap
EndFunc   ;==>CreateCaretBitmap

Func WM_DROPFILES($hWnd, $msg, $wParam, $lParam)
        Local $aRet = DllCall("shell32.dll", "int", "DragQueryFile", "int", $wParam, "int", -1, "ptr", 0, "int", 0)
        If @error Then Return SetError(1, 0, 0)
        Local $tBuffer = DllStructCreate("char")
        DllCall("shell32.dll", "int", "DragQueryFile", "int", $wParam, "int", 0, "ptr", DllStructGetPtr($tBuffer), "int", DllStructGetSize($tBuffer))
        Local Const $sDroppedFiles = DllStructGetData($tBuffer, 1)
        _GUICtrlEdit_AppendText($hEdit, $sDroppedFiles)
        $aCaretPos = GetCaretPos()
        DllCall("shell32.dll", "none", "DragFinish", "int", $wParam)
        $tBuffer = 0
        WinActivate($hWnd)
        Return "GUI_RUNDEFMSG"
EndFunc   ;==>WM_DROPFILES

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
        #forceref $hWnd, $iMsg
        Switch BitShift($wParam, 16)
                Case $EN_SETFOCUS
                        DllCall('user32.dll', 'int', 'CreateCaret', 'hwnd', $lParam, 'ptr', $hBitmap, 'int', 0, 'int', 0)
                        DllCall('user32.dll', 'int', 'ShowCaret', 'hwnd', $lParam)
                        DllCall('user32.dll', 'int', 'SetCaretBlinkTime', 'uint', $iBlinkTime)
                        $aBlinkTime = DllCall('user32.dll', 'int', 'GetCaretBlinkTime')
                        $iBlinkTime = $aBlinkTime
                Case $EN_KILLFOCUS
                        DllCall('user32.dll', 'int', 'HideCaret', 'hwnd', $lParam)
                        DllCall('user32.dll', 'int', 'DestroyCaret')
                        DllCall('user32.dll', 'int', 'SetCaretBlinkTime', 'uint', $aBlinkTime)
        EndSwitch
        Return "GUI_RUNDEFMSG"
EndFunc   ;==>WM_COMMAND

Func _GetNN($hWnd)
        Local $List, $Text, $ID = 0
        $Text = _WinAPI_GetClassName($hWnd)
        If Not $Text Then
                Return -1
        EndIf
        $List = _WinAPI_EnumChildWindows(_WinAPI_GetAncestor($hWnd, $GA_ROOT), 0)
        If @error Then
                Return -1
        EndIf
        For $i = 1 To $List
                If $List[$i] = $Text Then
                        $ID += 1
                EndIf
                If $List[$i] = $hWnd Then
                        ExitLoop
                EndIf
        Next
        If Not $ID Then
                Return -1
        EndIf
        Return $ID
EndFunc   ;==>_GetNN

Func _WinAPI_EnumChildWindows($hWnd, $fVisible = 1)
        If Not _WinAPI_GetWindow($hWnd, 5) Then
                Return SetError(1, 0, 0)
        EndIf
        Local $hEnumProc = DllCallbackRegister('__EnumWindowsProc', 'int', 'hwnd;lparam')
        Dim $__Enum = []
        DllCall('user32.dll', 'int', 'EnumChildWindows', 'hwnd', $hWnd, 'ptr', DllCallbackGetPtr($hEnumProc), 'lparam', $fVisible)
        If (@error) Or (Not $__Enum) Then
                $__Enum = 0
        EndIf
        DllCallbackFree($hEnumProc)
        If Not IsArray($__Enum) Then
                Return SetError(1, 0, 0)
        EndIf
        __Inc($__Enum, -1)
        Return $__Enum
EndFunc   ;==>_WinAPI_EnumChildWindows

Func __EnumWindowsProc($hWnd, $fVisible)
        If ($fVisible) And (Not _WinAPI_IsWindowVisible($hWnd)) Then
                Return 1
        EndIf
        __Inc($__Enum)
        $__Enum[$__Enum] = $hWnd
        $__Enum[$__Enum] = _WinAPI_GetClassName($hWnd)
        Return 1
EndFunc   ;==>__EnumWindowsProc

Func __Inc(ByRef $aData, $iIncrement = 100)
        Select
                Case UBound($aData, 2)
                        If $iIncrement < 0 Then
                                ReDim $aData[$aData + 1]
                        Else
                                $aData += 1
                                If $aData > UBound($aData) - 1 Then
                                        ReDim $aData[$aData + $iIncrement]
                                EndIf
                        EndIf
                Case UBound($aData, 1)
                        If $iIncrement < 0 Then
                                ReDim $aData[$aData + 1]
                        Else
                                $aData += 1
                                If $aData > UBound($aData) - 1 Then
                                        ReDim $aData[$aData + $iIncrement]
                                EndIf
                        EndIf
                Case Else
                        Return 0
        EndSelect
        Return 1
EndFunc   ;==>__Inc

weeks5 发表于 2013-4-1 12:14:32

,感谢分享!,感谢分享!

mbdnmt 发表于 2013-4-1 23:13:25

回复 19# lpxx

不愧是金牌会员,虽然跟我想要的场景有差异,但是很有启发,也给大家带来很多信息!~

mbdnmt 发表于 2013-4-2 00:19:11

回复 19# lpxx

这个方案每条命令都是单独执行的,没有记忆效果,不会产生叠加效应

比如输入cd..命令,在cmd窗口和此方案的窗口返回值是不一样的。 所以这个方案只能解决单独运行一条或者连续运行一段命令行的情况。





要实现我描述的方案,目前最好的方案是用PostMessage的方案(见16楼),但有2个缺陷: 1.后台输入时Alt键会产生干扰造成输入错误; 2.还未解决返回值的问题。
1的规避方法,采用BlockInput来防止用户前台输入Alt键; 2在cmd窗体中写文件、写内存或者socket来传递给AutoIt

pk196371 发表于 2013-4-2 11:03:50

19楼的很好。。

lpxx 发表于 2013-4-2 13:34:18

回复lpxx

这个方案每条命令都是单独执行的,没有记忆效果,不会产生叠加效应

比如输入cd..命令,在 ...
mbdnmt 发表于 2013-4-2 00:19 http://www.autoitx.com/images/common/back.gif

回复lpxx

不愧是金牌会员,虽然跟我想要的场景有差异,但是很有启发,也给大家带来很多信息!~
mbdnmt 发表于 2013-4-1 23:13 http://www.autoitx.com/images/common/back.gif

别这么说,俺就一年过半百的半吊子,我知道的,尽量告诉你,太复杂的我也不清楚,你老再这样抬举我,我都不敢说话了。

mbdnmt 发表于 2013-4-2 22:44:16

回复 24# lpxx

呵呵,过谦了~

jasonny 发表于 2013-5-28 10:50:39

真強,收下學習了~~

ak47gglllk 发表于 2013-12-26 10:18:33

学些学习,学习。感谢。感谢

R8019 发表于 2014-3-27 19:18:30

学习了{:face (456):}

deaph 发表于 2014-4-23 21:23:14

感谢学习了{:face (356):}

au3x 发表于 2014-9-25 14:17:58

19F真的让我唉为观止!~
页: 1 [2]
查看完整版本: [已解决]如何使用AutoIt发送字符到cmd命令窗体?