Jump to content

is there a command shell in autoit - (Moved)


Recommended Posts

hi ,

I don't know exact word for it but say we run 'python' then we get a prompt in which we can run commands line by line.

Similioarly , before writing a script in autoit , i want to try out commands then i will make a script which contains command relevant to my requirement.

How is that possible ?

 

Thanks.

Link to post
Share on other sites
  • Moderators

Moved to the appropriate forum.

Moderation Team

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to post
Share on other sites

I have this script saved from a broken link (all credits for the author cited in code).

Seems related but don't execute commands

Perhaps can be adapted using AutoIt Execute Function

#cs ----------------------------------------------------------------------------
http://www.emesn.com/autoitforum/viewtopic.php?f=4&t=4063
Terminal Ejemplo
Dany, 2014
#ce ----------------------------------------------------------------------------

#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <GuiEdit.au3>
#include <Array.au3>
#include <File.au3>

;~ Declaraciones
#Region
Global $hEdit, $hGUI, $hLB_Active, $hLB_LastCout, $hLB_Total, $hLB_Date, $iENTER, $iMsg = 0
Global $sData = ">> "
Global $iReset = 0
Global Const $sFont = "Courier New"
Global Const $aMode[6] = ["Comando1", "Comando2", "Comando3", "Comando4", "Salir", "Ayuda"]; Entre otros
Global Enum $eCom1, $eCom2, $eCom3, $eCom4, $eSalir, $eAyuda
Global $iState_Mode = $eCom1
Global Const $sTC = ">> Dany Terminal" & @CRLF & ">> "
Global $iGoblal_Total = 0
Global $sDate = @MDAY & "/" & @MON & "/" & @YEAR
Global $fSave = False
Global $sfIndex = 0
#EndRegion

;~ Interface
#Region
$hGUI = GUICreate("Dany Terminal", 400, 350, -1, -1)
GUISetBkColor(0x191919);Gris
$hEdit = GUICtrlCreateEdit($sTC, 10, 5, 380, 290, $ES_MULTILINE)
GUICtrlSetFont(-1, 9, 400, 0, $sFont)
GUICtrlSetBkColor(-1, 0x000000) ; Black
GUICtrlSetColor(-1, 0x00ff00) ;Green

$hLB_Active = GUICtrlCreateLabel("Activo: ", 10, 300, 200, 20)
GUICtrlSetFont(-1, 9, 400, 0, $sFont)
GUICtrlSetBkColor(-1, 0x191919) ;Gris
GUICtrlSetColor(-1, 0x00ff00) ;Green

$hLB_Date = GUICtrlCreateLabel($sDate, 300, 300, 200, 20)
GUICtrlSetFont(-1, 9, 400, 0, $sFont)
GUICtrlSetBkColor(-1, 0x191919) ;Gris
GUICtrlSetColor(-1, 0x00ff00) ;Green

$iENTER = GUICtrlCreateDummy()
$iBS = GUICtrlCreateDummy()


Global $AccelKeys[2][3] = [["{ENTER}", $iENTER],["{BS}", $iBS]]; Set accelerators
GUISetAccelerators($AccelKeys)
#EndRegion



GUISetState()

ControlClick($hGUI, "", $hEdit);Quitar Selected

;~ Main Loop
While $iMsg <> $GUI_EVENT_CLOSE
   $iMsg = GUIGetMsg()
   Select
      Case $iMsg = $iENTER
         Enter()

      Case $iMsg = $iBS
         Bs()
   EndSelect
WEnd



;~funcion Modo
Func Mode($sString)
   Local $sMode = ""
   $sMode = StringStripWS(StringRight($sString, StringLen($sString) - 3), 8)

   If ($sMode) = "" Then
      $iReset = 1
      Return
   EndIf


   Select
      Case $sMode = $aMode[$eCom1]
         GUICtrlSetData($hLB_Active, "Activo:" & $aMode[$eCom1])
         ConsoleWrite("Mode: " & $aMode[$eCom1] & @CRLF)
         $iState_Mode = $eCom1
         _Comando1()
         $iReset = 0
         Return 0
      Case $sMode = $aMode[$eCom2]
         GUICtrlSetData($hLB_Active, "Activo:" & $aMode[$eCom2])
         ConsoleWrite("Mode: " & $aMode[$eCom2] & @CRLF)
         $iState_Mode = $eCom2
         $iReset = 0

         Return 0
      Case $sMode = $aMode[$eCom3]
         GUICtrlSetData($hLB_Active, "Activo:" & $aMode[$eCom3])
         ConsoleWrite("Mode: " & $aMode[$eCom3] & @CRLF)
         $iState_Mode = $eCom3
         $iReset = 0
         Return 0
      Case $sMode = $aMode[$eCom4]
         GUICtrlSetData($hLB_Active, "Activo:" & $aMode[$eCom4])
         ConsoleWrite("Mode: " & $aMode[$eCom4] & @CRLF)
         $iState_Mode = $eCom4
         $iReset = 0

         Return 0
      Case $sMode = $aMode[$eSalir]
         GUICtrlSetData($hLB_Active, "Activo:" & $aMode[$eSalir])
         ConsoleWrite("Mode: " & $aMode[$eSalir] & @CRLF)
         $iState_Mode = $eSalir
         $iReset = 0
         _Exit()
         Return 0

      Case $sMode = $aMode[$eAyuda]
         GUICtrlSetData($hLB_Active, "Activo:" & $aMode[$eAyuda])
         ConsoleWrite("Mode: " & $aMode[$eAyuda] & @CRLF)
         $iState_Mode = $eAyuda
         $iReset = 0
         _Ayuda()
         Return 0

      Case Else
;~          GUICtrlSetData($hLB_Active,"Activo :" & $sMode)
         ConsoleWrite("Mode: " & "Caso Else: " & $sMode & @CRLF)
         $iReset = 0
         Return 0

   EndSelect

EndFunc   ;==>Mode


;~ Ayuda
Func _Ayuda()
   For $i = 0 To UBound($aMode) - 1
      $sData &= @CRLF & ">> " & $aMode[$i]
   Next
   GUICtrlSetData($hEdit, $sData & @CRLF)
   $sfIndex = 0
   $iReset = 1
EndFunc   ;==>_Ayuda


;~ Salir
Func _Exit()
   GUICtrlSetData($hEdit, ">> Bye Bye :)...")
   Sleep(2000)
   Exit
EndFunc   ;==>_Exit

;~ Limpiar
Func Clean()
;~    $sData = ">> "
   $sData = $sTC
   GUICtrlSetData($hEdit, $sData)
   $sfIndex = 0
   $iReset = 0
EndFunc   ;==>Clean


;~ Funcion on Enter
Func Enter()
   $sData = GUICtrlRead($hEdit)
   Local $sCurrentLine = ""
   If _WinAPI_GetFocus() = GUICtrlGetHandle($hEdit) Then
      ConsoleWrite("Reset value: " & $iReset & @CRLF)
      If _GUICtrlEdit_GetLineCount($hEdit) = 18 Then $iReset = 1
      If $iReset = 1 Then
         Clean()
      Else
         $sCurrentLine = _GUICtrlEdit_GetLine($hEdit, _GUICtrlEdit_GetLineCount($hEdit) - 1)
         ConsoleWrite("[Enter] Fué Presionado!" & @CRLF)
         ConsoleWrite("Linea: " & _GUICtrlEdit_GetLine($hEdit, _GUICtrlEdit_GetLineCount($hEdit) - 1) & @CRLF)
         GUICtrlSetData($hEdit, $sData & @CRLF & ">> ")
         Mode($sCurrentLine)
      EndIf
   EndIf
EndFunc   ;==>Enter

;~ Funcion on BS
Func Bs()
   $sData = GUICtrlRead($hEdit)
   If _WinAPI_GetFocus() = GUICtrlGetHandle($hEdit) Then
      If (StringMid($sData, StringLen($sData) - 1) == "> ") Then
         ConsoleWrite("[BS] Fué Presionado!" & @CRLF)
         GUICtrlSetData($hEdit, StringMid($sData, 1, StringLen($sData) - 5))
      Else
         GUICtrlSetData($hEdit, StringMid($sData, 1, StringLen($sData) - 1))
      EndIf
   EndIf
EndFunc   ;==>Bs

;Ejemplo de comando
Func _Comando1()
   $sData &= @CRLF & ">> Se ejecuta el Comando 1 :)"
   GUICtrlSetData($hEdit, $sData)
   $sfIndex = 0
   $iReset = 1
EndFunc   ;==>_Comando1

 

Here another old reference:

Other references:

https://conemu.github.io/

https://stackoverflow.com/questions/12602411/use-custom-console-for-visual-studio-console-application-debugging

 

 

Edited by robertocm
Link to post
Share on other sites
  • 2 weeks later...

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...