Jump to content

terminal command problem


Recommended Posts

hi,

I have problem,If I Type "say string", it will return "string" but if I type "saystring",It will return "tring",How to make script work so that only "say" is command and if i type "saystring" then it returns "is not a valid command Or bad file path".?

here is my script

#include <GUIConstants.au3>
#include <GUIEdit.au3>
#include <misc.au3>
HotKeySet("^{NUMPADADD}", "IncreaseFont")
HotKeySet("^{NUMPADSUB}", "DecreaseFont")
HotKeySet("{f11}", "fullscreen")
HotKeySet("{enter}", "read_func")
HotKeySet("{up}", "lastcmd")
Global $cmd = ""
Global $newlinestart = @UserName & "@" & @ComputerName & "~#"

;~ HotKeySet ("^{mousewheelup}", "IncreaseFont")
;~ HotKeySet ("^{Mousewheeldown}", "DecreaseFont")
$line = 1
$FontSize = 12
$Form1 = GUICreate("Terminal - "&@WorkingDir, 655, 305, 201, 116, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX))
$fsize = 10
$CommandInput = GUICtrlCreateEdit("", 0, 0, 654, 304, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN, $WS_VSCROLL, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX))
GUICtrlSetData(-1,"Welcome to CMD 7.10" & @CRLF & "To see avaible commands Type: commands" & @CRLF & @UserName & "@" & @ComputerName & "~#")
GUICtrlSetFont(-1, $fsize, 500, 0, "Trebuchet MS")
GUICtrlSetBkColor(-1, 0x000000)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlCreateTabItem("")
GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd


Func read_func()
    $line = _GUICtrlEdit_GetLineCount($CommandInput) - 1
    $Input = _GUICtrlEdit_GetLine($CommandInput, $line)
    Global $inputgetcount = StringLen(@UserName & "@" & @ComputerName & "~#")
    $command = StringTrimLeft($Input, $inputgetcount)
    $Say = StringInStr($command, "say")
    $Exit = StringInStr($command, "exit")
    $cmd = $command
    If $Say Then
        HotKeySet("{enter}")
        $string = StringTrimLeft($Input, $inputgetcount + 4)
        $readfromgui = GUICtrlRead($CommandInput)
        GUICtrlSetData($CommandInput, $readfromgui & @CRLF & $string & @CRLF & $newlinestart)
        $line = $line + 4
        Sleep(100)
        HotKeySet("{enter}", "read_func")
    Else
        If $Exit Then
            Exit
        Else
            HotKeySet("{enter}")
            $readfromgui = GUICtrlRead($CommandInput)
            if FileExists ($command) Then
                Run ($command)
            endif   
            GUICtrlSetData($CommandInput, $readfromgui & @CRLF & "'" & $command & "'" & "is not a valid command Or bad file path" & @CRLF & $newlinestart)
            $line = $line + 4
            Sleep(100)
            HotKeySet("{enter}", "read_func")
        EndIf
    EndIf
EndFunc   ;==>read_func



Func IncreaseFont()
    $FontSize += 1
    GUICtrlSetFont($CommandInput, $FontSize)
EndFunc   ;==>IncreaseFont
Func DecreaseFont()
    $FontSize -= 1
    GUICtrlSetFont($CommandInput, $FontSize)
EndFunc   ;==>DecreaseFont

Func fullscreen()
    $width = @DesktopWidth
    $height = @DesktopHeight
    WinMove("Terminal", "", 0, 0, $width, $height)
EndFunc   ;==>fullscreen

Func lastcmd()
    Send($cmd)
;~ exit
EndFunc   ;==>lastcmd
Link to comment
Share on other sites

Maybe if you add a space after "say"

$Say = StringInStr($command, "say ")

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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...