jerome Posted December 9, 2006 Share Posted December 9, 2006 (edited) *Updated June 13th 2007 * Hello, Here is a Console Window library. Functions are: ; *new* Create a console inside an existing AutoIt gui ConsoleCreate($gui, $x, $y, $width, $height, $Text, $CreateProgress, $BgColor, $FgColor, $LogFile) ; Create a console window, with or without a progress bar *New*: Log file added ConsoleWinCreate($x, $y, $width, $height, $Title, $Text, $CreateProgress, $BgColor, $FgColor, $Transparency, $LogFile) ; Change title of console ConsoleWinChangeTitle($ConsoleID, $Title) ; Write some text to the console and update the progress bar *New*: bug corrected when 32kb size reached. ConsoleWinWrite($ConsoleID, $Text, $Progress, $NoCRLF, $Replace) ; *new* Set progress bar of console (if option choosen during creation) ConsoleSetProgress($ConsoleID, $value, $min, $max) ; *new* Flash the console window ConsoleFlash($ConsoleID) ; Ask to the user something ConsoleWinInput($ConsoleID, $Text, $Progress) ; Clear the console history ConsoleWinClear($ConsoleID) ; Save the Console history content to a file ConsoleWinSave($ConsoleID, $FileName) Enjoy... JD expandcollapse popup;------------------------------------------------------------------------------------------------------ ;- C O N S O L E L I B R A R Y ;------------------------------------------------------------------------------------------------------ ;=============================================================================== ; Description: Create a Window console to display status text information with history ; Parameter(s): $x - x position of the window ; $y - y position of the window ; $width - Optional - Window width ; $height - Optional - Window height ; $Title - Optional - Console Window title ; $text - Optional - Initial text to display. ; $CreateProgress - Optional - Create Progress (True/False) ; $BgColor - Optional - background color ; $FgColor - Optional - Foreground color ; $Transparency - Optional - Transparency (0=Invisible, 255=Visible) ; $LogFile - Optional - File to log all console text ; Requirement(s): None ; Return Value(s): The Console ID ; Author(s): Jerome DERN (jerome "at" dern "dot" fr) ; Note(s): None ;=============================================================================== Func ConsoleWinCreate($x, $y, $width=638, $height=126, $Title="Console", $Text="", $CreateProgress=False, $BgColor=0xFFFFFF, $FgColor=0xFF0000, $Transparency=255, $LogFile="") Dim $Console[4] If $Text <> "" Then $Text=$Text & @CRLF $Console[0] = GuiCreate($Title, $width, $height, $x, $y, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) GUISetOnEvent($GUI_EVENT_CLOSE, "ConsoleWinExitEvent") If $CreateProgress Then $height -= 20 $Console[1] = GuiCtrlCreateEdit($Text, 0, 0, $width-1, $height-1, BitOR($ES_MULTILINE, $ES_READONLY, $ES_AUTOVSCROLL,$WS_HSCROLL,$WS_VSCROLL)) GUICtrlSetBkColor($Console[1], $BgColor) GUICtrlSetColor($Console[1], $FgColor) GUICtrlSetResizing($Console[1], $GUI_DOCKBORDERS) GUICtrlSetFont($Console[1], 8, 400, 0, "Courrier New") $Console[2] =0 If $CreateProgress Then $Console[2] = GUICtrlCreateProgress(0, $height+5, $width-1, 12) if $Transparency<255 Then WinSetTrans($Console[0], "", $Transparency) DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Console[0], "int", 300, "long", 0x00080000) GuiSetState(@SW_SHOW, $Console[0]) $Console[3] = $LogFile Sleep(50) Return $Console EndFunc ;=============================================================================== ; Description: Create a Widget console to display status text information with history ; Parameter(s): $gui - Gui window to include widget ; $x - x position of the Widget ; $y - y position of the Widget ; $width - Optional - Widget width ; $height - Optional - Widget height ; $Title - Optional - Console Window title ; $text - Optional - Initial text to display. ; $CreateProgress - Optional - Create Progress (True/False) ; $BgColor - Optional - background color ; $FgColor - Optional - Foreground color ; $LogFile - Optional - File to log all console text ; Requirement(s): None ; Return Value(s): The Console ID ; Author(s): Jerome DERN (jerome "at" dern "dot" fr) ; Note(s): None ;=============================================================================== Func ConsoleCreate($gui, $x, $y, $width=638, $height=126, $Text="", $CreateProgress=False, $BgColor=0xFFFFFF, $FgColor=0xFF0000, $LogFile="") Dim $Console[4] If $Text <> "" Then $Text=$Text & @CRLF $Console[0] = $gui If $CreateProgress Then $height -= 20 $Console[1] = GuiCtrlCreateEdit($Text, $x, $y, $width-1, $height-1, BitOR($ES_MULTILINE, $ES_READONLY, $ES_AUTOVSCROLL,$WS_HSCROLL,$WS_VSCROLL)) GUICtrlSetBkColor($Console[1], $BgColor) GUICtrlSetColor($Console[1], $FgColor) GUICtrlSetResizing($Console[1], $GUI_DOCKBORDERS) GUICtrlSetFont($Console[1], 8, 400, 0, "Courrier New") $Console[2] =0 If $CreateProgress Then $Console[2] = GUICtrlCreateProgress($x, $y+$height+5, $width-1, 12) $Console[3] = $LogFile Return $Console EndFunc Func ConsoleWinExitEvent() GUIDelete(@GUI_WinHandle) EndFunc ;=============================================================================== ; Description: Close the Console ; Parameter(s): $ConsoleID - The console ID ; Requirement(s): None ; Return Value(s): None ; Author(s): Jerome DERN (jerome "at" dern "dot" fr) ; Note(s): None ;=============================================================================== Func ConsoleWinClose($ConsoleID) GUIDelete($ConsoleID[0]) DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $ConsoleID[0], "int", 400, "long", 0x00090000) $ConsoleID[0] = 0 $ConsoleID[1] = 0 $ConsoleID[2] = 0 EndFunc ;=============================================================================== ; Description: Change the title of Console ; Parameter(s): $ConsoleID - The console ID ; $Title - The new title ; Requirement(s): None ; Return Value(s): None ; Author(s): Jerome DERN (jerome "at" dern "dot" fr) ; Note(s): None ;=============================================================================== Func ConsoleWinChangeTitle($ConsoleID, $Title) WinSetTitle($ConsoleID[0], "", $Title) EndFunc ;=============================================================================== ; Description: Write a message to the console ; Parameter(s): $ConsoleID - Console ID returned by ConsoleWinCreate ; $text - Text to display. ; $Progress - Optional - Progress value (0-100) ; $NoCRLF - Optional - Don't add CRLF and the end of text ; $Replace - Optional - Replace last line ; Requirement(s): ConsoleWinCreate called first ; Return Value(s): None ; Author(s): Jerome DERN (jerome "at" dern "dot" fr) ; Note(s): None ;=============================================================================== Func ConsoleWinWrite($ConsoleID, $Text, $Progress=-1, $NoCRLF=False, $Replace=False) If $Replace Then $string = GUICtrlRead($ConsoleID[1]) $pos = StringInStr($string, @CRLF, 0, -1) If $pos > 0 Then $pos += 1 $end = StringLen($string) _GUICtrlEditSetSel($ConsoleID[1], $pos, $end) Else $pos = StringLen(GUICtrlRead($ConsoleID[1])) _GUICtrlEditSetSel($ConsoleID[1], $pos, $pos) EndIf If StringLen(GUICtrlRead($ConsoleID[1]))>28000 Then $string = StringRight(GUICtrlRead($ConsoleID[1]), 20000) GUICtrlSetData ($ConsoleID[1], $string) EndIf If $NoCRLF = False Then $Text = $Text & @CRLF GUICtrlSetData ($ConsoleID[1], $Text, 1) If $ConsoleID[2] >0 And $Progress>=0 Then GUICtrlSetData($ConsoleID[2], $Progress) If $ConsoleID[3] <> "" Then FileWrite($ConsoleID[3], $Text) Return $ConsoleID EndFunc ;=============================================================================== ; Description: Ask for the user to input something ; Parameter(s): $ConsoleID - Console ID returned by ConsoleWinCreate ; $text - Text to display, the question. ; $Progress - Optional - Progress value (0-100) ; Requirement(s): ConsoleWinCreate called first ; Return Value(s): What user have typed. ; Author(s): Jerome DERN (jerome "at" dern "dot" fr) ; Note(s): $text could be an empty string ;=============================================================================== Func ConsoleWinInput($ConsoleID, $Text, $Progress=-1) WinSetOnTop($ConsoleID[0], "", 1) WinFlash($ConsoleID[0], "", 5, 100) WinActivate($ConsoleID[0]) $string = GUICtrlRead($ConsoleID[1]) $pos = StringLen($string) _GUICtrlEditSetSel($ConsoleID[1], $pos, $pos) GUICtrlSetData ($ConsoleID[1], $Text, 1) GUICtrlSetStyle($ConsoleID[1], BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_HSCROLL, $WS_VSCROLL, $ES_WANTRETURN)) GUICtrlSetState($ConsoleID[1], $GUI_FOCUS) If $Text <> "" Then ; Wait for the user to input something While 1 Sleep(100) $String=GUICtrlRead($ConsoleID[1]) If StringRight($string, 2) = @CRLF Then ExitLoop ; Ensure that everything is typed at the end of edit control $pos = StringLen($String) _GUICtrlEditSetSel($ConsoleID[1], $pos, $pos) WEnd $pos = StringInStr($string, $Text, 0, -1) If $pos >0 Then $pos += StringLen($Text) Else $str = $string ; Wait for the user to input something While 1 Sleep(100) $String=GUICtrlRead($ConsoleID[1]) If StringRight($string, 2) = @CRLF And $string <> $str Then ExitLoop ; Ensure that everything is typed at the end of edit control $pos = StringLen($String) _GUICtrlEditSetSel($ConsoleID[1], $pos, $pos) WEnd $pos = StringInStr(StringLeft($string, StringLen($string)-2), @CRLF, 0, -1) If $pos > 0 Then $pos += 1 EndIf $string = StringMid($string, $pos) $string = StringLeft($string, StringLen($string)-2) GUICtrlSetStyle($ConsoleID[1], BitOR($ES_MULTILINE, $ES_READONLY, $ES_AUTOVSCROLL,$WS_HSCROLL,$WS_VSCROLL)) If $ConsoleID[2] >0 And $Progress>=0 Then GUICtrlSetData($ConsoleID[2], $Progress) WinSetOnTop($ConsoleID[0], "", 0) Return $string EndFunc ;=============================================================================== ; Description: Set progress value of the console ; Parameter(s): $ConsoleID - The console ID ; $Value - The new value to set ; $min - Optional - The minimum value possible ; $max - Optional - The maximum value possible ; Requirement(s): None ; Return Value(s): None ; Author(s): Jerome DERN (jerome "at" dern "dot" fr) ; Note(s): None ;=============================================================================== Func ConsoleSetProgress($ConsoleID, $value, $min=0, $max=100) $percent = ($value-$min)*100 If $percent <0 Then $percent = 0 $percent /= ($max-$min) If $ConsoleID[2] >0 Then GUICtrlSetData($ConsoleID[2], $percent) EndFunc ;=============================================================================== ; Description: Clear the console ; Parameter(s): $ConsoleID - The console ID ; Requirement(s): None ; Return Value(s): None ; Author(s): Jerome DERN (jerome "at" dern "dot" fr) ; Note(s): None ;=============================================================================== Func ConsoleWinClear($ConsoleID) GUICtrlSetData ($ConsoleID[1], "") If $ConsoleID[2] >0 Then GUICtrlSetData($ConsoleID[2], 0) If $ConsoleID[3] <> "" Then FileDelete($ConsoleID[3]) EndFunc ;=============================================================================== ; Description: Flash the console ; Parameter(s): $ConsoleID - The console ID ; Requirement(s): None ; Return Value(s): None ; Author(s): Jerome DERN (jerome "at" dern "dot" fr) ; Note(s): None ;=============================================================================== Func ConsoleFlash($ConsoleID) WinFlash($ConsoleID[0], "", 5, 100) EndFunc ;=============================================================================== ; Description: Save the content of the console to a file ; Parameter(s): $ConsoleID - The console ID ; $FileName - The filename used to save ; Requirement(s): None ; Return Value(s): Write status, same as FileWrite ; Author(s): Jerome DERN (jerome "at" dern "dot" fr) ; Note(s): None ;=============================================================================== Func ConsoleWinSave($ConsoleID, $FileName) $string = GUICtrlRead($ConsoleID[1]) Return FileWrite($FileName, $string) EndFunc Edited June 13, 2007 by jerome Link to comment Share on other sites More sharing options...
JOHNe Posted December 10, 2006 Share Posted December 10, 2006 (edited) Nice one!! Just what Ive been looking 4 THanks Edited December 10, 2006 by JOHNe "Our deepest fear is not that we are inadequate.Our deepest fear is that we are powerful beyond measure.It is our light, not our darkness that most frightens us." Link to comment Share on other sites More sharing options...
Gyatso Posted December 10, 2006 Share Posted December 10, 2006 Hi, I love it, i was just programming this in autoit myself, but yours is better, Thanks and keep it up! Arjan How can someone use Windows without using AutoIt?That one would properly don't know how to handle a computer!My scripts:Send files over internetKind of RSS reader3Draw ProUDF: convert a character string to a binary one and back Link to comment Share on other sites More sharing options...
jerome Posted December 10, 2006 Author Share Posted December 10, 2006 Hi,I love it, i was just programming this in autoit myself, but yours is better, Thanks and keep it up!ArjanThanks all for your positive comments... I was built for a personnal project in 5 hours. Link to comment Share on other sites More sharing options...
FuryCell Posted December 10, 2006 Share Posted December 10, 2006 Nice job. This should provide a nice alternative interface for scripting. HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code. Link to comment Share on other sites More sharing options...
NELyon Posted December 10, 2006 Share Posted December 10, 2006 This could be a good base for Text-based games. Nice script Link to comment Share on other sites More sharing options...
Valuater Posted December 10, 2006 Share Posted December 10, 2006 (edited) Pretty Neat!!! how about a verify function ;=============================================================================== ; Description: Ask for the user to verify input something ; Parameter(s): $ConsoleID - Console ID returned by ConsoleWinCreate ; $VAns - info to verify ; $Text - Text to display, the question. ; $VNum - Optional - to verify an Intreger ; $VMin - Optional - Minimum length of string ; $VMax - Otional - Maximum length of string ; Requirement(s): ConsoleWinCreate available and ConsoleWinInput called first ; Return Value(s): What user has typed. ; Author(s): Jerome DERN (jdern "at" free "dot" fr) ; Co - Author Valuater ; Note(s): $Text may not be an empty string ;=============================================================================== Func ConsoleWinVerify($ConsoleID, $VAns, $Text, $VNum = False, $VMin = 1, $VMax = 1000) While 1 ConsoleWinWrite($ConsoleID, "You have answered: " & $VAns) $VLen = StringLen($VAns) If $VNum And Int($VAns) > 0 And $VLen >= $VMin And $VLen <= $VMax Then If ConsoleWinInput($ConsoleID, 'Is this Correct? "Y" or "N" ') = "y" Then Return $VAns ElseIf Not $VNum And $VLen >= $VMin And $VLen <= $VMax Then If ConsoleWinInput($ConsoleID, 'Is this Correct? "Y" or "N" ') = "y" Then Return $VAns EndIf $VAns = ConsoleWinInput($ConsoleID, $Text) Sleep(10) WEnd EndFunc 8) Edited December 10, 2006 by Valuater Link to comment Share on other sites More sharing options...
Valuater Posted December 10, 2006 Share Posted December 10, 2006 added speach too!!! expandcollapse popup#include <GuiConstants.au3> #Include <GuiEdit.au3> #include <date.au3> opt("GUIOnEventMode", 1) Demo() ;------------------------------------------------------------------------------------------------------ ;- C O N S O L E D E M O ;------------------------------------------------------------------------------------------------------ Func Demo() Global $ConsoleID=0 $ConsoleID = ConsoleWinCreate(-1, -1, 638, 326, "Age Demo...", "Starting demo..." & @CRLF, True) $answer1 = ConsoleWinInput($ConsoleID, "Please input your Year of Birth (example.. 1985) ?", 15, 1 ) $Vanswer1 =ConsoleWinVerify($ConsoleID, $answer1, "Please input your Year of Birth (example.. 1985) ?", True, 4, 4) ConsoleWinWrite($ConsoleID, "OK.. " & @CRLF, 30, 1) $answer2 = ConsoleWinInput($ConsoleID, "Please input your Month of Birth (example.. 3 = March) ?", 45, 1 ) $Vanswer2 =ConsoleWinVerify($ConsoleID, $answer2, "Please input your Month of Birth (example.. 3 = March) ?", True, 1, 2) ConsoleWinWrite($ConsoleID, "Good.. " & @CRLF, 60, 1) $answer3 = ConsoleWinInput($ConsoleID, "Please input your Day of Birth (ex.. 22) ?" , 75, 1 ) $Vanswer3 =ConsoleWinVerify($ConsoleID, $answer3, "Please input your Month of Birth (example.. 22) ?", True, 1, 2) ConsoleWinWrite($ConsoleID, "Great!.. Please wait while i calculate your age..." & @CRLF, 90, 1) Sleep(1000) ConsoleWinWrite($ConsoleID, " You have been alive " & _DateDiff( 'd',$Vanswer1 &"/"& $Vanswer2 &"/"& $Vanswer3,_NowCalc()) & " days!" & @CRLF, 100, 1) Sleep(5000) ConsoleWinWrite($ConsoleID, "Example: Clearing console in five seconds...Thanks Valuater 8) ") Sleep(5000) ConsoleWinClear($ConsoleID) ConsoleWinWrite($ConsoleID, "Demo finished! Exiting in five seconds...") Sleep(5000) Exit EndFunc ;------------------------------------------------------------------------------------------------------ ;- C O N S O L E L I B R A R Y ;------------------------------------------------------------------------------------------------------ ;=============================================================================== ; Description: Create a Window console to display status text information with history ; Parameter(s): $x - x position of the window ; $y - y position of the window ; $width - Optional - Window width ; $height - Optional - Window height ; $Title - Optional - Console Window title ; $text - Optional - Initial text to display. ; $CreateProgress - Optional - Create Progress (True/False) ; $BgColor - Optional - background color ; $FgColor - Optional - Foreground color ; $Transparency - Optional - Transparency (0=Invisible, 255=Visible) ; Requirement(s): None ; Return Value(s): The Console ID ; Author(s): Jerome DERN (jdern "at" free "dot" fr) ; Note(s): None ;=============================================================================== Func ConsoleWinCreate($x, $y, $width=638, $height=126, $Title="Console", $Text="", $CreateProgress=False, $BgColor=0xFFFFFF, $FgColor=0xFF0000, $Transparency=255) Dim $Console[3] $Console[0] = GuiCreate($Title, $width, $height, $x, $y, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS), $WS_EX_TOOLWINDOW) GUISetOnEvent($GUI_EVENT_CLOSE, "ConsoleWinExitEvent") If $CreateProgress Then $height -= 20 $Console[1] = GuiCtrlCreateEdit($Text & @CRLF, 0, 0, $width-1, $height-1, BitOR($ES_MULTILINE, $ES_READONLY, $ES_AUTOVSCROLL,$WS_HSCROLL,$WS_VSCROLL)) GUICtrlSetBkColor($Console[1], $BgColor) GUICtrlSetColor($Console[1], $FgColor) GUICtrlSetResizing($Console[1], $GUI_DOCKBORDERS) GUICtrlSetFont($Console[1], 12, 400, 0, "Courrier New") $Console[2] =0 If $CreateProgress Then $Console[2] = GUICtrlCreateProgress(0, $height+5, $width-1, 12) WinSetTrans($Console[0], "", $Transparency) GuiSetState() Return $Console EndFunc Func ConsoleWinExitEvent() GUIDelete(@GUI_WinHandle) Exit EndFunc ;=============================================================================== ; Description: Write a message to the console ; Parameter(s): $ConsoleID - Console ID returned by ConsoleWinCreate ; $text - Text to display. ; $Progress - Optional - Progress value (0-100) ; $NoCRLF - Optional - Don't add CRLF and the end of text ; $Replace - Optional - Replace last line ; Requirement(s): ConsoleWinCreate called first ; Return Value(s): None ; Author(s): Jerome DERN (jdern "at" free "dot" fr) ; Note(s): None ;=============================================================================== Func ConsoleWinWrite($ConsoleID, $Text, $Progress=-1, $Speak=False, $NoCRLF=False, $Replace=False) If $Replace Then $string = GUICtrlRead($ConsoleID[1]) $pos = StringInStr($string, @CRLF, 0, -1) If $pos > 0 Then $pos += 1 $end = StringLen($string) _GUICtrlEditSetSel($ConsoleID[1], $pos, $end) Else $pos = StringLen(GUICtrlRead($ConsoleID[1])) _GUICtrlEditSetSel($ConsoleID[1], $pos, $pos) EndIf If $NoCRLF = False Then $Text = $Text & @CRLF GUICtrlSetData ($ConsoleID[1], $Text, 1) If $Speak Then ConsoleSpeak($Text) If $ConsoleID[2] >0 And $Progress>=0 Then GUICtrlSetData($ConsoleID[2], $Progress) EndFunc ;=============================================================================== ; Description: Ask for the user to input something ; Parameter(s): $ConsoleID - Console ID returned by ConsoleWinCreate ; $text - Text to display, the question. ; $Progress - Optional - Progress value (0-100) ; Requirement(s): ConsoleWinCreate called first ; Return Value(s): What user have typed. ; Author(s): Jerome DERN (jdern "at" free "dot" fr) ; Note(s): $text could be an empty string ;=============================================================================== Func ConsoleWinInput($ConsoleID, $Text, $Progress=-1, $Speak = 0) WinSetOnTop($ConsoleID[0], "", 1) WinActivate($ConsoleID[0]) $string = GUICtrlRead($ConsoleID[1]) $pos = StringLen($string) _GUICtrlEditSetSel($ConsoleID[1], $pos, $pos) GUICtrlSetData ($ConsoleID[1], $Text, 1) GUICtrlSetStyle($ConsoleID[1], BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_HSCROLL, $WS_VSCROLL, $ES_WANTRETURN)) If $Speak Then ConsoleSpeak($Text) If $Text <> "" Then ; Wait for the user to input something While 1 Sleep(100) $String=GUICtrlRead($ConsoleID[1]) If StringRight($string, 2) = @CRLF Then ExitLoop ; Ensure that everything is typed at the end of edit control $pos = StringLen($String) _GUICtrlEditSetSel($ConsoleID[1], $pos, $pos) WEnd $pos = StringInStr($string, $Text, 0, -1) If $pos >0 Then $pos += StringLen($Text) Else $str = $string ; Wait for the user to input something While 1 Sleep(100) $String=GUICtrlRead($ConsoleID[1]) If StringRight($string, 2) = @CRLF And $string <> $str Then ExitLoop ; Ensure that everything is typed at the end of edit control $pos = StringLen($String) _GUICtrlEditSetSel($ConsoleID[1], $pos, $pos) WEnd $pos = StringInStr(StringLeft($string, StringLen($string)-2), @CRLF, 0, -1) If $pos > 0 Then $pos += 1 EndIf $string = StringMid($string, $pos) $string = StringLeft($string, StringLen($string)-2) GUICtrlSetStyle($ConsoleID[1], BitOR($ES_MULTILINE, $ES_READONLY, $ES_AUTOVSCROLL,$WS_HSCROLL,$WS_VSCROLL)) If $ConsoleID[2] >0 And $Progress>=0 Then GUICtrlSetData($ConsoleID[2], $Progress) Return $string WinSetOnTop($ConsoleID[0], "", 0) EndFunc ;=============================================================================== ; Description: Clear the console ; Parameter(s): $ConsoleID - The console ID ; Requirement(s): None ; Return Value(s): None ; Author(s): Jerome DERN (jdern "at" free "dot" fr) ; Note(s): None ;=============================================================================== Func ConsoleWinClear($ConsoleID) GUICtrlSetData ($ConsoleID[1], "") If $ConsoleID[2] >0 Then GUICtrlSetData($ConsoleID[2], 0) EndFunc ;=============================================================================== ; Description: Save the content of the console to a file ; Parameter(s): $ConsoleID - The console ID ; $FileName - The filename used to save ; Requirement(s): None ; Return Value(s): Write status, same as FileWrite ; Author(s): Jerome DERN (jdern "at" free "dot" fr) ; Note(s): None ;=============================================================================== Func ConsoleWinSave($ConsoleID, $FileName) $string = GUICtrlRead($ConsoleID[1]) Return FileWrite($FileName, $string) EndFunc ;=============================================================================== ; Description: Ask for the user to verify input something ; Parameter(s): $ConsoleID - Console ID returned by ConsoleWinCreate ; $VAns - info to verify ; $Text - Text to display, the question. ; $VNum - Optional - to verify an Intreger ; $VMin - Optional - Minimum length of string ; $VMax - Otional - Maximum length of string ; Requirement(s): ConsoleWinCreate available and ConsoleWinInput called first ; Return Value(s): What user has typed. ; Author(s): Jerome DERN (jdern "at" free "dot" fr) ; Co - Author Valuater ; Note(s): $Text may not be an empty string ;=============================================================================== Func ConsoleWinVerify($ConsoleID, $VAns, $Text, $VNum = False, $VMin = 1, $VMax = 1000) While 1 ConsoleWinWrite($ConsoleID, "You have answered: " & $VAns) $VLen = StringLen($VAns) If $VNum And Int($VAns) > 0 And $VLen >= $VMin And $VLen <= $VMax Then If ConsoleWinInput($ConsoleID, 'Is this Correct? "Y" or "N" ') = "y" Then Return $VAns ElseIf Not $VNum And $VLen >= $VMin And $VLen <= $VMax Then If ConsoleWinInput($ConsoleID, 'Is this Correct? "Y" or "N" ') = "y" Then Return $VAns EndIf $VAns = ConsoleWinInput($ConsoleID, $Text) Sleep(10) WEnd EndFunc Func ConsoleSpeak($S_text) Local $oi_speech = ObjCreate("SAPI.SpVoice") $oi_speech.Speak ($S_text) $oi_speech = "" EndFunc 8) Link to comment Share on other sites More sharing options...
Xenobiologist Posted December 10, 2006 Share Posted December 10, 2006 (edited) Hi, thats nice, but why is it flickering so much? So long, Mega Edited December 10, 2006 by th.meger Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
jerome Posted December 10, 2006 Author Share Posted December 10, 2006 Hi, I read all these comments and interrest it's nice ! Thanks for those that have worked on it to add functions ! Any other idea? Thanks JD Link to comment Share on other sites More sharing options...
Valuater Posted December 11, 2006 Share Posted December 11, 2006 XSkin it!! 8) Link to comment Share on other sites More sharing options...
theguy0000 Posted December 11, 2006 Share Posted December 11, 2006 new ConsoleWinCreate: expandcollapse popup;=============================================================================== ; Description: Create a Window console to display status text information with history ; Parameter(s): $x - x position of the window ; $y - y position of the window ; $width - Optional - Window width ; $height - Optional - Window height ; $Title - Optional - Console Window title ; $text - Optional - Initial text to display. ; $CreateProgress - Optional - Create Progress (True/False) ; $BgColor - Optional - background color ; $FgColor - Optional - Foreground color ; $Transparency - Optional - Transparency (0=Invisible, 255=Visible) ; $exitOnClose - Optional - Exit script when window is closed? (True/False) ; Requirement(s): None ; Return Value(s): The Console ID ; Author(s): Jerome DERN (jdern "at" free "dot" fr) ; Note(s): None ;=============================================================================== Func ConsoleWinCreate($x, $y, $width=638, $height=126, $Title="Console", $Text="", $CreateProgress=False, $BgColor=0xFFFFFF, $FgColor=0xFF0000, $Transparency=255, $exitOnClose=False) Dim $Console[3] $Console[0] = GuiCreate($Title, $width, $height, $x, $y, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS), $WS_EX_TOOLWINDOW) $exitEvent = "ConsoleWinExitEvent" If $exitOnClose Then $exitEvent &= "Exit" GUISetOnEvent($GUI_EVENT_CLOSE, $exitEvent) If $CreateProgress Then $height -= 20 $Console[1] = GuiCtrlCreateEdit($Text & @CRLF, 0, 0, $width-1, $height-1, BitOR($ES_MULTILINE, $ES_READONLY, $ES_AUTOVSCROLL,$WS_HSCROLL,$WS_VSCROLL)) GUICtrlSetBkColor($Console[1], $BgColor) GUICtrlSetColor($Console[1], $FgColor) GUICtrlSetResizing($Console[1], $GUI_DOCKBORDERS) GUICtrlSetFont($Console[1], 12, 400, 0, "Courrier New") $Console[2] =0 If $CreateProgress Then $Console[2] = GUICtrlCreateProgress(0, $height+5, $width-1, 12) WinSetTrans($Console[0], "", $Transparency) GuiSetState() Return $Console EndFuncoÝ÷ Ù©Ýi×m+ºÚ"µÍ[ÈÛÛÛÛUÚ[^]][^] BÕRQ[]JÕRWÕÚ[[JBQ^][[ Then, you can set the last parameter of ConsoleWinCreate to True and the script will exit when the console is closed. The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN Link to comment Share on other sites More sharing options...
Valuater Posted December 11, 2006 Share Posted December 11, 2006 I just added the last part... and mine exited correctly Func ConsoleWinExitEventExit() GUIDelete(@GUI_WinHandle) Exit EndFunc 8) Link to comment Share on other sites More sharing options...
theguy0000 Posted December 11, 2006 Share Posted December 11, 2006 I just added the last part... and mine exited correctly Func ConsoleWinExitEventExit() GUIDelete(@GUI_WinHandle) Exit EndFunc 8)but you didn't change ConsoleWinCreate at all? that's odd..... The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN Link to comment Share on other sites More sharing options...
Valuater Posted December 11, 2006 Share Posted December 11, 2006 nope... i didn't change it 8) Link to comment Share on other sites More sharing options...
theguy0000 Posted December 11, 2006 Share Posted December 11, 2006 nope... i didn't change it 8)umm oh wait did you add a new function ConsoleWinExitEventExit or just add the Exit command to ConsoleWinExitEvent? there should be two functions Func ConsoleWinExitEvent() GUIDelete(@GUI_WinHandle) EndFunc Func ConsoleWinExitEventExit() GUIDelete(@GUI_WinHandle) Exit EndFunc The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN Link to comment Share on other sites More sharing options...
Valuater Posted December 11, 2006 Share Posted December 11, 2006 he had this in the function GUISetOnEvent($GUI_EVENT_CLOSE, "ConsoleWinExitEvent") however the actual function Func ConsoleWinExitEvent() GUIDelete(@GUI_WinHandle) EndFunc removed the GUI... but, i was stuck with a running and invisible program so, i just added "Exit" to that function 8) Link to comment Share on other sites More sharing options...
theguy0000 Posted December 11, 2006 Share Posted December 11, 2006 he had this in the functionGUISetOnEvent($GUI_EVENT_CLOSE, "ConsoleWinExitEvent")however the actual functionFunc ConsoleWinExitEvent() GUIDelete(@GUI_WinHandle)EndFuncremoved the GUI... but, i was stuck with a running and invisible programso, i just added "Exit" to that function8)yes, but then you don't get the option whether or not to Exit the program when the gui is closed, which is why I added what I did The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN Link to comment Share on other sites More sharing options...
Devjunk Posted April 24, 2007 Share Posted April 24, 2007 Hi i like that UDFs, really handy. But it's lacking of an function similiar to ConsoleWinInput() where the user can type in a password and it'll show *asteriks* or whatever. Greetings Link to comment Share on other sites More sharing options...
Wodden Posted May 8, 2007 Share Posted May 8, 2007 Hi, I want to say this is great! I will use it in my next Programm.Bye Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now