Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

Noob needs help-cmd


  • Please log in to reply
4 replies to this topic

#1 armoros

armoros

  • Active Members
  • PipPipPipPipPipPip
  • 503 posts

Posted 03 April 2012 - 12:10 PM

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 © Copyright Microsoft Corp. echo. :cmd cmd /k ipconfig %cmd% echo. goto cmd








#2 Country73

Country73

    Adventurer

  • Active Members
  • PipPip
  • 145 posts

Posted 03 April 2012 - 01:13 PM

Are you looking for something along this line?

AutoIt         
#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

#3 armoros

armoros

  • Active Members
  • PipPipPipPipPipPip
  • 503 posts

Posted 03 April 2012 - 04:28 PM

Are you looking for something along this line?

AutoIt         
#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, 03 April 2012 - 04:29 PM.


#4 Rutger83

Rutger83

    Wayfarer

  • Active Members
  • Pip
  • 50 posts

Posted 03 April 2012 - 04:34 PM

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, 03 April 2012 - 04:41 PM.


#5 armoros

armoros

  • Active Members
  • PipPipPipPipPipPip
  • 503 posts

Posted 03 April 2012 - 04:40 PM

check the GUICreate() function which is used in the above code to created the GUI (Graphical User Interface)


Thank you for the info mr rutger83 i will read it asap..




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users