jerome Posted June 13, 2007 Author Share Posted June 13, 2007 Updated June 13th, new functions and bug corrected. See first post of this topic for listing. Link to comment Share on other sites More sharing options...
boomingranny Posted July 11, 2007 Share Posted July 11, 2007 not a major, but you spelt courier new wrong in the font Link to comment Share on other sites More sharing options...
James Posted July 11, 2007 Share Posted July 11, 2007 Very nice UDF here. Anything else you can add? Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
WeMartiansAreFriendly Posted August 14, 2008 Share Posted August 14, 2008 Awesome! I updated it for latest AutoIt (some minor tweaks), I suggest a little error checking. expandcollapse popup#include <windowsconstants.au3> #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) $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) $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) $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) ; $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 Func ConsoleWinQuit() Exit 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, $nAnimate = False) If UBound($ConsoleID) < 4 Then Return SetError(1) GUIDelete($ConsoleID[0]) If $nAnimate Then DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $ConsoleID[0], "int", 400, "long", 0x00090000) EndIf $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) If UBound($ConsoleID) < 4 Then Return SetError(1) 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 UBound($ConsoleID) < 4 Then Return SetError(1) If $Replace Then $string = GUICtrlRead($ConsoleID[1]) $pos = StringInStr($string, @CRLF, 0, -1) If $pos > 0 Then $pos += 1 $end = StringLen($string) _GUICtrlEdit_SetSel($ConsoleID[1], $pos, $end) Else $pos = StringLen(GUICtrlRead($ConsoleID[1])) _GUICtrlEdit_SetSel($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) If UBound($ConsoleID) < 4 Then Return SetError(1) WinSetOnTop($ConsoleID[0], "", 1) WinFlash($ConsoleID[0], "", 5, 100) WinActivate($ConsoleID[0]) $string = GUICtrlRead($ConsoleID[1]) $pos = StringLen($string) _GUICtrlEdit_SetSel($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) _GUICtrlEdit_SetSel($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) _GUICtrlEdit_SetSel($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) If UBound($ConsoleID) < 4 Then Return SetError(1) $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) If UBound($ConsoleID) < 4 Then Return SetError(1) 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) If UBound($ConsoleID) < 4 Then Return SetError(1) 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) If UBound($ConsoleID) < 4 Then Return SetError(1) $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 mLipok 1 Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet() Link to comment Share on other sites More sharing options...
the123punch Posted September 17, 2008 Share Posted September 17, 2008 Hi, I tried using the demo but I think there is some includes missing and it is not compiling. Can you tell me if there is anything missing at the top? It gives me errors of undeclared variables. the123punch Link to comment Share on other sites More sharing options...
jerome Posted September 17, 2008 Author Share Posted September 17, 2008 Updated version: expandcollapse popup#include <GuiConstants.au3> #Include <GuiEdit.au3> ;------------------------------------------------------------------------------------------------------ ;- C O N S O L E D E M O ;------------------------------------------------------------------------------------------------------ #comments-start Func ConsoleWinDemo() Global $ConsoleID=0 Dim $Tab[8]=["|", "/", "--", "\", "|", "/", "--", "\"] $ConsoleID = ConsoleWinCreate(-1, -1, 638, 326, "Console Demo...", "Starting demo...", True) ConsoleWinWrite($ConsoleID, "Example: writting to the console a line") ConsoleWinWrite($ConsoleID, "Example: writting a string without line feed") For $i=0 To 7 ConsoleWinWrite($ConsoleID, ".", $i*5, True) Sleep(500) Next ConsoleWinWrite($ConsoleID, "") ConsoleWinWrite($ConsoleID, "Example: rewritting the last string") For $i=0 To 7 ConsoleWinWrite($ConsoleID, $Tab[$i], 50+$i*5, True, True) Sleep(500) Next ConsoleWinWrite($ConsoleID, "") ConsoleWinWrite($ConsoleID, "Example: input from console.") $answer = ConsoleWinInput($ConsoleID, "What is your age?") ConsoleWinWrite($ConsoleID, "You have answered: " & $answer) ConsoleWinWrite($ConsoleID, "Example: input from console on another line. What is your age?") $answer = ConsoleWinInput($ConsoleID, "") ConsoleWinWrite($ConsoleID, "You have answered: " & $answer) ConsoleWinWrite($ConsoleID, "Example: Clearing console in five seconds...") Sleep(5000) ConsoleWinClear($ConsoleID) ConsoleWinWrite($ConsoleID, "Demo finished! Exiting in five seconds...") Sleep(5000) Exit EndFunc #comments-end ;------------------------------------------------------------------------------------------------------ ;- 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], 9, 400, 0, "Courrier New") GUICtrlSetLimit($Console[1], 500000) $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], 10, 400, 0, "Courrier New") GUICtrlSetLimit($Console[1], 500000) $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) If Not IsArray($ConsoleID) Then Return 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) If Not IsArray($ConsoleID) Then Return 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) Local $string, $pos, $end If Not IsArray($ConsoleID) Then Return If $Replace Then $string = GUICtrlRead($ConsoleID[1]) $pos = StringInStr($string, @CRLF, 0, -1) If $pos > 0 Then $pos += 1 $end = StringLen($string) _GUICtrlEdit_SetSel($ConsoleID[1], $pos, $end) Else $pos = StringLen(GUICtrlRead($ConsoleID[1])) _GUICtrlEdit_SetSel($ConsoleID[1], $pos, $pos) EndIf If StringLen(GUICtrlRead($ConsoleID[1]))>499000 Then $string = StringRight(GUICtrlRead($ConsoleID[1]), 499000) 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) Local $string, $pos, $str If Not IsArray($ConsoleID) Then $string = InputBox("Question", $Text) Else WinSetOnTop($ConsoleID[0], "", 1) WinFlash($ConsoleID[0], "", 5, 100) WinActivate($ConsoleID[0]) $string = GUICtrlRead($ConsoleID[1]) $pos = StringLen($string) _GUICtrlEdit_SetSel($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) _GUICtrlEdit_SetSel($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) _GUICtrlEdit_SetSel($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) EndIf 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) Local $percent If Not IsArray($ConsoleID) Then Return $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) If Not IsArray($ConsoleID) Then Return 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) If Not IsArray($ConsoleID) Then Return 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) Local $string If Not IsArray($ConsoleID) Then Return $string = GUICtrlRead($ConsoleID[1]) Return FileWrite($FileName, $string) EndFunc <script src="http://shots.snap.com//client/inject.js?site_name=0" type="text/javascript"> Link to comment Share on other sites More sharing options...
Ahmad Posted September 18, 2008 Share Posted September 18, 2008 But it's still buggy, I Can Delete Previous lines when he console asks for input, u should set the Question to read-only. [center]I want to change the world ...., but I don't have the source code xD[/center] Link to comment Share on other sites More sharing options...
martin Posted September 18, 2008 Share Posted September 18, 2008 Updated version:No it's not very up to date. You need #include <windowsconstants.au3>#Include <GuiConstantsEx.au3>#Include <GuiEdit.au3>instead of#include <GuiConstants.au3>#Include <GuiEdit.au3> 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 More sharing options...
Valuater Posted September 18, 2008 Share Posted September 18, 2008 No it's not very up to date. You need #include <windowsconstants.au3>#Include <GuiConstantsEx.au3>#Include <GuiEdit.au3>instead of#include <GuiConstants.au3>#Include <GuiEdit.au3>.... and re-place it in the original post on page #1you could use versions and dates to show the latest code8) Link to comment Share on other sites More sharing options...
Krypton88 Posted December 20, 2008 Share Posted December 20, 2008 I LOVE YOU! lol thanks exactly what i was looking for!!!!!!! Projects-Krypton's WoW Auto-Caster-V1.0-Lite Link to comment Share on other sites More sharing options...
jerome Posted December 20, 2008 Author Share Posted December 20, 2008 I LOVE YOU! lol thanks exactly what i was looking for!!!!!!!Thank you! Link to comment Share on other sites More sharing options...
StrategicX Posted February 13, 2009 Share Posted February 13, 2009 Thanks so much for this library! I took this idea/AWESOME UDF! and made an embedded console for my TeleBot for wow! as soon as I can ill post some pics in the example scripts section thanks again mate! This helped alot and added a professional look to my application ^^ *WoW Dev Projects: AFK Tele Bot development journalSimple Player Pointer Scanner + Z-Teleport*My Projects: coming soon.Check out my WoW Dev wiki for patch 3.0.9!http://www.wowdev.wikidot.com 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