-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCommandRun.au3
84 lines (72 loc) · 2.41 KB
/
CommandRun.au3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#Region Configuración
#pragma compile(Icon, Icons\au3.ico)
#pragma compile(Out, EjecutarComando.exe)
#NoTrayIcon
Opt('ExpandEnvStrings', 1)
Opt('ExpandVarStrings', 1)
Opt("GUIOnEventMode", 1)
#EndRegion
#Region Includes
#include <AutoItConstants.au3>
#EndRegion
#Region Variables globales
Global $idDir, $idCmd, $idOutput
#EndRegion
#Region Manejadores de eventos
Func _GUI_EVENT_CLOSE()
GUIDelete()
Exit
EndFunc
Func _idDummyActivated()
GUICtrlSetData($idOutput, '')
Local $sDir = GUICtrlRead($idDir)
If ($sDir == '') Then _
$sDir = @ScriptDir
GUICtrlSetTip($idDir, $sDir)
If (FileExists($sDir)) Then
Local $sCmd = GUICtrlRead($idCmd)
Local $pid = Run($sCmd, $sDir, @SW_HIDE, $STDOUT_CHILD)
GUICtrlSetData($idOutput, 'Ejecutando...')
ProcessWaitClose($pid)
$sOutput = StringAddCR(StdoutRead($pid))
If (StringInStr($sOutput, @CRLF)) Then
StringReplace($sOutput, @CRLF, @CRLF)
Local Const $iOutputCtrlSize = 15 * @extended
GUICtrlSetPos($idOutput, Default, Default, Default, $iOutputCtrlSize)
WinMove($hGUI, '', Default, Default, Default, $iOutputCtrlSize + 100)
EndIf
GUICtrlSetData($idOutput, $sOutput)
Else
GUICtrlSetData($idOutput, 'El directorio [$sDir$] no existe.')
EndIf
EndFunc
#EndRegion
#Region Interfaz gráfica
$hGUI = GUICreate('Ejecución de comandos', 650, 154)
GUISetFont(10, Default, Default, 'Liberation Mono')
GUICtrlCreateLabel('Carpeta: ', 5, 5, 64, 17)
GUICtrlSetResizing(-1, 32 + 128 + 512)
$sDir = IniRead('CommandRun.ini', 'main', 'dir', '')
$idDir = GUICtrlCreateInput($sDir, 74, 5, 571, 17)
GUICtrlSetResizing(-1, 32 + 128 + 512)
GUICtrlSetTip($idDir, $sDir)
GUICtrlCreateLabel('Comando: ', 5, 27, 64, 17)
GUICtrlSetResizing(-1, 32 + 128 + 512)
$idCmd = GUICtrlCreateInput(IniRead('CommandRun.ini', 'main', 'cmd', ''), 74, 27, 571, 17)
GUICtrlSetResizing(-1, 32 + 128 + 512)
$idOutput = GUICtrlCreateEdit('', 5, 49, 640, 100, (0x0800 + 0x00200000))
GUICtrlSetResizing(-1, 32)
; 0x0800: $ES_READONLY
; 0x00200000: $WS_VSCROLL
GUICtrlSetBkColor($idOutput, 0x000090)
GUICtrlSetColor($idOutput, 0xF0F4F9)
$idDummy = GUICtrlCreateDummy()
Local $aAccelKeys[1][2] = [['{enter}', $idDummy]]
GUISetAccelerators($aAccelKeys)
GUICtrlSetOnEvent($idDummy, _idDummyActivated)
GUISetOnEvent(-3, _GUI_EVENT_CLOSE)
GUISetState(@SW_SHOW)
While 1
Sleep(100)
WEnd
#EndRegion