Jump to content

Noob needs help-cmd


Recommended Posts

Hello people im new here i love autoit and i need your help...

I want to make a gui/console to run cmd commands........

and to have a list of ready commands to open instantly in the same window...

for example a button for ipconfig and a button for netsh etc..

but to open in the same console/window..

I hope you understand what i mean I am sorry for my bad english..

thanks in advance

i tried with bat files but opens commands in different windows

@echo off
title Command Prompt - ipconfig
ver
echo (C) Copyright Microsoft Corp.
echo.
:cmd
cmd /k ipconfig
%cmd%
echo.
goto cmd

[font="verdana, geneva, sans-serif"] [/font]

Link to comment
Share on other sites

Are you looking for something along this line?

#include <Constants.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)

Global  $MAIN, $CMD_WINDOW
Global  $IP_CONFIG, $OTHER, $BUTT_CLOSE

#Region ### START Koda GUI section ### Form=
$MAIN = GUICreate("CMD FUNCTIONS", 623, 449, 192, 114)
$CMD_WINDOW = GUICtrlCreateEdit("", 10, 10, 600, 289, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_READONLY,$WS_VSCROLL))
    GUICtrlSetFont($CMD_WINDOW, 12, 800, 0, "Times New Roman")
    GUICtrlSetColor($CMD_WINDOW, 0xFFFFFF)
    GUICtrlSetBkColor($CMD_WINDOW, 0x000000)
$IP_CONFIG = GUICtrlCreateButton("IP_CONFIG", 10, 310, 75, 25)
    GUICtrlSetOnEvent($IP_CONFIG, "_IP_CONFIGClick")
$OTHER = GUICtrlCreateButton("OTHER", 95, 310, 75, 25)
    GUICtrlSetOnEvent($OTHER, "_OTHERClick")
$BUTT_CLOSE = GUICtrlCreateButton("EXIT", 535, 310, 75, 25)
    GUICtrlSetOnEvent($BUTT_CLOSE, "_ExitNow")


GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    Sleep(100)
WEnd

Func _ExitNow()
    Exit
EndFunc

Func _IP_CONFIGClick()
    Local $foo = Run(@ComSpec & " /c " & "IPCONFIG /ALL",@SystemDir,@SW_HIDE,$STDOUT_CHILD)
    Local $line
    While 1
        $line = StdoutRead($foo)
        If @error Then ExitLoop
        If Not $line = "" Then GUICtrlSetData($CMD_WINDOW,$line)
    WEnd
EndFunc

Func _OTHERClick()
    GUICtrlSetData($CMD_WINDOW,"Create a CMD Function to be ran here")

EndFunc

If you try to fail and succeed which have you done?AutoIt Forum Search

Link to comment
Share on other sites

Are you looking for something along this line?

#include 
#include 
#include 

Opt("GUIOnEventMode", 1)

Global  $MAIN, $CMD_WINDOW
Global  $IP_CONFIG, $OTHER, $BUTT_CLOSE

#Region ### START Koda GUI section ### Form=
$MAIN = GUICreate("CMD FUNCTIONS", 623, 449, 192, 114)
$CMD_WINDOW = GUICtrlCreateEdit("", 10, 10, 600, 289, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_READONLY,$WS_VSCROLL))
    GUICtrlSetFont($CMD_WINDOW, 12, 800, 0, "Times New Roman")
    GUICtrlSetColor($CMD_WINDOW, 0xFFFFFF)
    GUICtrlSetBkColor($CMD_WINDOW, 0x000000)
$IP_CONFIG = GUICtrlCreateButton("IP_CONFIG", 10, 310, 75, 25)
    GUICtrlSetOnEvent($IP_CONFIG, "_IP_CONFIGClick")
$OTHER = GUICtrlCreateButton("OTHER", 95, 310, 75, 25)
    GUICtrlSetOnEvent($OTHER, "_OTHERClick")
$BUTT_CLOSE = GUICtrlCreateButton("EXIT", 535, 310, 75, 25)
    GUICtrlSetOnEvent($BUTT_CLOSE, "_ExitNow")


GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    Sleep(100)
WEnd

Func _ExitNow()
    Exit
EndFunc

Func _IP_CONFIGClick()
    Local $foo = Run(@ComSpec & " /c " & "IPCONFIG /ALL",@SystemDir,@SW_HIDE,$STDOUT_CHILD)
    Local $line
    While 1
        $line = StdoutRead($foo)
        If @error Then ExitLoop
        If Not $line = "" Then GUICtrlSetData($CMD_WINDOW,$line)
    WEnd
EndFunc

Func _OTHERClick()
    GUICtrlSetData($CMD_WINDOW,"Create a CMD Function to be ran here")

EndFunc

Country73 you are a legend, this is exactly what i want....i know i have to read a bit to achieve things by my own but if you could let me know how i could make the window sizeable and how i could make possible to type some commands in the window, I will be your slave for a life... :oops:

But anyway this is the base that i was searching for..Thank you again

Edited by armoros

[font="verdana, geneva, sans-serif"] [/font]

Link to comment
Share on other sites

check the GUICreate() function (edit: this for resizing the 'main' window, not the 'black' box) which is used in the above code to created the GUI (Graphical User Interface)

...

By default the dialog box is non sizable and non maximizable. So WS_SIZEBOX or WS_MAXIMIZEBOX can be used in the style parameter.

As defining only one style just set this style don't forget to combine it with default ones, i.e. just defining WS_SIZEBOX will not set WS_MINIMIZEBOX, WS_CAPTION, WS_POPUP, WS_SYSMENU. So the best method to define a resizeable window is to use WS_OVERLAPPEDwindow.

When using $WS_EX_MDICHILD the position is relative to client area of the parent window. With $WS_EX_LAYERED it is possible to have a transparent pic on a background pic defined in the parent window.

Adding $WS_CLIPCHILDREN style can avoid some flickering when resizing GUI containing Edit control for example.

You can enable window draging for GUI without $WS_CAPTION by using $WS_EX_CONTROLPARENT in the exStyle parameter.

...

Edited by Rutger83
Link to comment
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
 Share

  • Recently Browsing   0 members

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