Sign in to follow this  
Followers 0
MetalSpongebob

how see dos messages

7 posts in this topic

Hi,I had an idea,write a program with GUI to manage the dos...a "frontend"

Is an good idea,I create the gui with buttons,each button with a function that works with _rundos("namefunction").

But I can only call the command with _rundos,to complete that program I need that informations of the dos commands are displayed in my gui program.How can display information (like the exaple)in the gui?

Example with dos command "Tree c:\" (once used displays the structure of directories)

post-27785-1196642867_thumb.jpg


Noob but ethical

Share this post


Link to post
Share on other sites



STDOutRead()

Share this post


Link to post
Share on other sites

sorry but I tryed

_rundos("tree c:\")

stdoutread("cmd")

and dont work...dont understand

Noob but ethical

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Don't know if it works with _RunDos. It certainly does with Run as per example from AutoIt help

#include <Constants.au3>
$foo = Run(@ComSpec & " /c tree c:\", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
$line = ""
While 1
    $line = StdoutRead($foo)
    If @error Then ExitLoop
    FileWrite("c:\test.txt", $line)
Wend
RunWait("notepad.exe c:\test.txt", "")
FileDelete("c:\test.txt")
Edited by picaxe

Share this post


Link to post
Share on other sites

Thak you for help,but your code doesn't work(script remain in execution,but without do nothing)

I need to display in a windows or other a command dos like "tree" regardless the method(see screenshot at begin of topic)


Noob but ethical

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

It works for me. If you have a lot of folders in c:\ it could take a long time.

This is faster

#include <Constants.au3>
$foo = Run(@ComSpec & " /c tree c:\", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
$line = ""
While 1
    $line &= StdoutRead($foo)
    If @error Then ExitLoop
Wend
ClipPut($line)  
Run("notepad.exe", "")
WinWaitActive("Untitled -", "")
Send("^v")
Edited by picaxe

Share this post


Link to post
Share on other sites

Hi,I had an idea,write a program with GUI to manage the dos...a "frontend"

Is an good idea,I create the gui with buttons,each button with a function that works with _rundos("namefunction").

But I can only call the command with _rundos,to complete that program I need that informations of the dos commands are displayed in my gui program.How can display information (like the exaple)in the gui?

Example with dos command "Tree c:\" (once used displays the structure of directories)

Try with this, it is a prototype but it works:

enter your dos command in the inputbox and then click on button1

to see the output in the editbox

Bye

CODE

#cs ----------------------------------------------------------------------------

AutoIt Version: 3.2.12.1

enter your dos command in the inputbox and then click on button1

to see the result in the editbox

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

#include <Constants.au3>

#include <GUIConstants.au3>

#include <WindowsConstants.au3>

#include <EditConstants.au3>

#include <StaticConstants.au3>

Opt("GUIOnEventMode", 1) ; Change to OnEvent mode

#Region ### START Koda GUI section ### Form=

$mainwindow = GUICreate("Form1", 583, 305, 207, 157)

GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSE_Clicked")

$Edit1 = GUICtrlCreateEdit("", 16, 40, 553, 249) ; Edit box (multiline)

GUICtrlSetFont(-1, 10, 400, 0, "Courier New") ; Font

GUICtrlSetColor(-1, 0x00FF00) ; Color of characters

GUICtrlSetBkColor(-1, 0x000000) ; Color of background

; GUICtrlSetData($Edit1, $line)

$Input1 = GUICtrlCreateInput("", 16, 8, 465, 21) ; InputBox (1 line)

$Button1 = GUICtrlCreateButton("Button1", 496, 8, 73, 25, 0) ; Button

GUICtrlSetOnEvent($Button1, "Button1_Click")

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

Local $prompt = Run(@ComSpec & " /K " , "c:\temp", @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD + $STDERR_MERGED)

While 1

Sleep(1000) ; Idle around (endless loop)

WEnd

; - - - - Functions zone - - - -

Func Button1_Click()

;Note: at this point @GUI_CTRLID would equal $okbutton

; MsgBox(0, "GUI Event", "You pressed Button!")

; StdinWrite($prompt, "dir c:\temp" & @CRLF)

StdinWrite($prompt, GUICtrlRead($Input1) & @CRLF & @CRLF)

Sleep(1000)

$line = StdoutRead($prompt)

GUICtrlSetData($Edit1,"")

GUICtrlSetData($Edit1, $line)

; lMsgBox(0, "STDOUT read:", $line)

EndFunc

Func CLOSE_Clicked()

;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE,

;@GUI_WINHANDLE will be either $mainwindow or $dummywindow

If @GUI_WINHANDLE = $mainwindow Then

; MsgBox(0, "GUI Event", "You clicked CLOSE in the main window! Exiting...")

Exit

EndIf

EndFunc


small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0