Hallo^^,
ich habe mal eine kleine UDF gebastelt da AutoIt wenig möglichkeiten bietet eine Console schön zu gestalten
Das ist erst meine 2te UDF also erwartet nicht zuviel *gg*
UDF
Global $sBatPath, $sTitle
#cs=====================CUI UDF===============================================
Credits: Christopher Kaster <Kasoki> : kasoki.de | [email='kasoki@arcor.de'][/email]
[/autoit] [autoit][/autoit] [autoit]This is an UDF to use a better CUI System.
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]ToDo:
- I must work on a Read Command
- More Comming soon.
-------------------------------------------------------------------
[/autoit] [autoit][/autoit] [autoit]Copyright by Kasoki 2009. All Rights Reserved.
#ce============================================================================
;==============================================================================
;
; Function: _CUI_Create($title)
; Parameters: $title - The title of our Console.
; Description: Creates a CUI with a title
;
; AutoIt Ver: 3.3 or higher
; Last Updatet: 20.06.09 - 16:54
;
; Author: Christopher Kaster <kasoki>
;
;==============================================================================
Func _CUI_Create($title)
$sBatPath = @TempDir & "/tmpCUI_" & $title & ".bat"
FileDelete($sBatPath)
Global $fFile = FileOpen($sBatPath,1)
FileWrite($fFile, "@echo off" & @CRLF & "TITLE " & $title & @CRLF)
FileClose($fFile)
$sTitle = $title
EndFunc ;==>
;==============================================================================
;
; Function: _CUI_Write($sText)
; Parameters: $sText - The text which will write into the Console
; Description: Write a Text into the Console
;
; AutoIt Ver: 3.3 or higher
; Last Updatet: 20.06.09 - 16:54
;
; Author: Christopher Kaster <kasoki>
;
;==============================================================================
Func _CUI_Write($sText)
$hWrite = FileOpen($sBatPath,1)
FileWrite($hWrite, "echo " & $sText & @CRLF)
FileClose($hWrite)
EndFunc ;==>
;==============================================================================
;
; Function: _CUI_Command($sCommand)
; Parameters: $sCommand - With this Command you can use the CMD Commands.
; Description: Use a CMD Command (Example: CD (Choose Directionary))
;
; AutoIt Ver: 3.3 or higher
; Last Updatet: 20.06.09 - 16:54
;
; Author: Christopher Kaster <kasoki>
;
;==============================================================================
Func _CUI_Command($sCommand)
$fCommand = FileOpen($sBatPath,1)
FileWrite($fCommand, $sCommand & @CRLF)
FileClose($fCommand)
EndFunc ;==>
;==============================================================================
;
; Function: _CUI_SetColor($cBackground, $cTextcolor)
; Parameters: $cBackground - Change the Backgroundcolor (Example: black)
; $cTextcolor - Change the Textcolor (Example: white)
; Description: Change the Color of Text and Background.
;
; AutoIt Ver: 3.3 or higher
; Last Updatet: 20.06.09 - 16:54
;
; Author: Christopher Kaster <kasoki>
;
;==============================================================================
Func _CUI_SetColor($cBackground, $cTextcolor)
Switch $cBackground
Case "black"
$bgcolor = 0
Case "darkblue"
$bgcolor = 1
Case "darkgreen"
$bgcolor = 2
Case "bluegreen"
$bgcolor = 3
Case "darkred"
$bgcolor = 4
Case "purple"
$bgcolor = 5
Case "ocher"
$bgcolor = 6
Case "lightgray"
$bgcolor = 7
Case "darkgray"
$bgcolor = 8
Case "blue"
$bgcolor = 9
Case "green"
$bgcolor = "A"
Case "cyan"
$bgcolor = "B"
Case "red"
$bgcolor = "C"
Case "magenta"
$bgcolor = "D"
Case "yellow"
$bgcolor = "E"
case "white"
$bgcolor = "F"
EndSwitch
Switch $cTextcolor
Case "black"
$fgcolor = 0
Case "darkblue"
$fgcolor = 1
Case "darkgreen"
$fgcolor = 2
Case "bluegreen"
$fgcolor = 3
Case "darkred"
$fgcolor = 4
Case "purple"
$fgcolor = 5
Case "ocher"
$fgcolor = 6
Case "lightgray"
$fgcolor = 7
Case "darkgray"
$fgcolor = 8
Case "blue"
$fgcolor = 9
Case "green"
$fgcolor = "A"
Case "cyan"
$fgcolor = "B"
Case "red"
$fgcolor = "C"
Case "magenta"
$fgcolor = "D"
Case "yellow"
$fgcolor = "E"
case "white"
$fgcolor = "F"
EndSwitch
$color = FileOpen($sBatPath,1)
FileWrite($color, "COLOR " & $bgcolor & $fgcolor & @CRLF)
FileClose($color)
EndFunc ;==>
;==============================================================================
;
; Function: _CUI_ChangeTitle($sNewTitle)
; Parameters: $sNewTitle - The new Title of our Console.
; Description: Change the title from our CUI
;
; AutoIt Ver: 3.3 or higher
; Last Updatet: 20.06.09 - 16:54
;
; Author: Christopher Kaster <kasoki>
;
;==============================================================================
Func _CUI_ChangeTitle($sNewTitle)
$sTitle2 = FileOpen($sBatPath,1)
FileWrite($sTitle2, "TITLE " & $sNewTitle & @CRLF)
FileClose($sTitle)
$sTitle = $sNewTitle
EndFunc ;==>
;==============================================================================
;
; Function: _CUI_Run($iDelay)
; Parameters: $iDelay - The Sleep Delay (How long must i wait before i start the console
; Description: Start our Console.
;
; AutoIt Ver: 3.3 or higher
; Last Updatet: 20.06.09 - 16:54
;
; Author: Christopher Kaster <kasoki>
;
;==============================================================================
Func _CUI_Run($iDelay)
Sleep($iDelay)
$fLoop = FileOpen($sBatPath,1)
FileWrite($fLoop, ":Loop" & @CRLF & "goto :Loop" & @CRLF)
FileClose($fLoop)
Run($sBatPath)
WinWaitClose($sTitle)
EndFunc ;==>
;===============================================================================
Example
#include "CUI.au3"
[/autoit] [autoit][/autoit] [autoit]_CUI_Create("Kasokis CUI UDF Example") ;Console Title
_CUI_SetColor("black","darkgreen") ;Background Color: black and Textcolor: darkgreen
_CUI_Write('#### _CUI_WRITE("TEXT") ####') ;Write a Text
_CUI_Command("ECHO MIT _CUI_COMMAND('ECHO Könnt ihr CMD Commands nutzen')"); Use the Command ECHO (Write)
_CUI_Run(5) ;Run after 5ms
Lg
Kasoki