Jump to content
Sign in to follow this  
Der_Andi

A cmd-line tool made for Auto It

Recommended Posts

Der_Andi

Hi,

just a little gimmick :P

Enter non-UDF Autoit-commands into the input and see for yourself.

A variable already exists, so enter only that part of line, that would be behind the equals sign.

Example:

Enter: Asc("a")

Output: 97

It's only basic. Feel free to improve it.

Special control commands:

#exit --> ... :D

#cls --> clear screen

#include <GuiConstants.au3>
#include <Process.au3>
#include <GuiEdit.au3>
Opt("GuiOnEventMode", 1)

GuiCreate("AutoIt CMD", 760, 460, -1, -1, -1, $WS_EX_TOOLWINDOW)
GUISetOnEvent($GUI_EVENT_CLOSE, "_quit")
GUISetBkColor(0x020060)
GUISetFont(9, 400, 0, "Tahoma")
$edit = GuiCtrlCreateEdit("AutoIt CMDbox" & @crlf & @CRLF, 10, 10, 740, 410, $ES_MULTILINE + $ES_READONLY + $ES_AUTOVSCROLL + $WS_VSCROLL)
GUICtrlSetBkColor(-1, 0x020060)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlCreateLabel("=", 10, 430, 10, 20, $SS_CENTERIMAGE)
GUICtrlSetColor(-1, 0xFFFFFF)
$input = GuiCtrlCreateInput("", 20, 430, 730, 20)
GUICtrlSetBkColor(-1, 0x020060)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetState(-1, $gui_focus)
$button = GUICtrlCreateButton("", 1, 1, 1, 1, $bs_defpushbutton)
GUICtrlSetState(-1, $gui_hide)
GUICtrlSetOnEvent(-1, "_cmd")

WinSetTrans("AutoIt CMDbox", "", 230)
GuiSetState()
While 1
    Sleep(1000)
WEnd

Func _cmd()
    $line = GUICtrlRead($input)
    If StringLen($line) > 0 Then
        If $line = "#exit" Then Exit
        If $line = "#cls" Then GUICtrlSetData($edit, "")
                
        GUICtrlSetData($edit, GUICtrlRead($edit) & GUICtrlRead($input))
        GUICtrlSetData($input, "")
        $file = FileOpen(@TempDir & "\autoit_cmd_temp.txt", 2)
        FileWriteLine($file, "#NoTrayIcon")
        FileWriteLine($file, '$log = FileOpen(@tempdir & "\autoit_cmd_log.txt", 2)')
        FileWriteLine($file, "$ret = " & $line)
        FileWriteLine($file, "If @error = 0 Then FileWriteLine($log, $ret)")
        FileWriteLine($file, "FileClose($log)")
        FileClose($file)
        FileMove(@TempDir & "\autoit_cmd_temp.txt", @TempDir & "\autoit_cmd_temp.au3", 1)
        _RunDOS(@TempDir & "\autoit_cmd_temp.au3")
        $result = FileReadLine(@tempdir & "\autoit_cmd_log.txt", 1)
        GUICtrlSetData($edit, GUICtrlRead($edit) & @CRLF & "--> " & $result & @CRLF & @CRLF)
        _GUICtrlEditLineScroll($edit, 0, _GUICtrlEditGetLineCount($edit))
    EndIf
EndFunc

Func _quit()
    Exit
EndFunc

Share this post


Link to post
Share on other sites
NELyon

This shows promise, but instead of RunDOS(), look at the command /Au3ExecuteLine because this automatically assumes that the default option for using au3 files is "Run" and not "Edit"

Share this post


Link to post
Share on other sites
RazerM

This shows promise, but instead of RunDOS(), look at the command /Au3ExecuteLine because this automatically assumes that the default option for using au3 files is "Run" and not "Edit"

I had the same problem, replace the _cmd func with this:

Func _cmd()
 $line = GUICtrlRead($input)
 If StringLen($line) > 0 Then
  If $line = "#exit" Then Exit
  If $line = "#cls" Then GUICtrlSetData($edit, "")

  GUICtrlSetData($edit, GUICtrlRead($edit) & GUICtrlRead($input))
  GUICtrlSetData($input, "")
  $file = FileOpen(@TempDir & "\autoit_cmd_temp.txt", 2)
  FileWriteLine($file, "#NoTrayIcon")
  FileWriteLine($file, '$log = FileOpen(@tempdir & "\autoit_cmd_log.txt", 2)')
  FileWriteLine($file, "$ret = " & $line)
  FileWriteLine($file, "If @error = 0 Then FileWriteLine($log, $ret)")
  FileWriteLine($file, "FileClose($log)")
  FileClose($file)
  FileMove(@TempDir & "\autoit_cmd_temp.txt", @TempDir & "\autoit_cmd_temp.au3", 1)
  $InstallDir = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt", "InstallDir")
  RunWait($InstallDir & '\AutoIt3.exe "' & @TempDir & '\autoit_cmd_temp.au3"')
  $result = FileReadLine(@TempDir & "\autoit_cmd_log.txt", 1)
  GUICtrlSetData($edit, GUICtrlRead($edit) & @CRLF & "--> " & $result & @CRLF & @CRLF)
  _GUICtrlEditLineScroll($edit, 0, _GUICtrlEditGetLineCount($edit))
 EndIf
EndFunc   ;==>_cmd
Edited by RazerM

My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.