Search the Community
Showing results for tags 'ascii art'.
-
This "cow" seems funny to me, At this link (https://dodona.ugent.be/en/activities/1605325419/#) a brief rough description of what this script can do (sorry for the laziness, but that description may be fine). You can use the _CowSayWin() function to display a message formatted in a comic along with an ascii art figure in a standalone window, or you can use _String_CowSay() function to format a plain string in a comic along with an ascii art figure and have it returned in a string for your own purposes, you will probably use it in Consolewrite () or whatever ... The script makes use of the _StringSize() function written by @Melba23 (thanks Melba) of the StringSize.au3 udf that you can extract from the zip file located at this link: https://www.autoitscript.com/forum/topic/114034-stringsize-m23-new-version-16-aug-11/. You have to save that udf file in the same directory along with this script. It also makes use of the _WinSetClientSize() function written by @KaFu. (thanks kafu) This function is already built into the main script. I hope you have fun #include <FontConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <WinAPISys.au3> #include <array.au3> #include <String.au3> #include "StringSize.au3" ; <-- https://www.autoitscript.com/forum/topic/114034-stringsize-m23-new-version-16-aug-11/ _Example() Func _Example() SRandom(@SEC) Local $hCowWin, $aMsg = 0 Local $sMessage, $iWidth, $iClipart, $iTextAlig Local $aMessages[] = ["Bottled water companies don’t produce water, they produce plastic bottles.", _ "The greatest glory in living lies not in never falling, but in rising every time we fall.", _ "Your time is limited, so don't waste it living someone else's life. " & _ "Don't be trapped by dogma which is living with the results of other people's thinking.", _ "Insanity is doing the same thing over and over again and expecting different results", _ "The way to get started is to quit talking and begin doing."] For $i = 1 To 6 $sMessage = $aMessages[Random(0, UBound($aMessages) - 1, 1)] $iWidth = Random(21, 90, 1) $iClipart = Random(0, 3, 1) $iTextAlign = 1 ; Random(0, 2, 1) Left and right alignments are a bit ugly. ; they are allowed however if you need them ; ; You can use the _CowSayWin() function to create the "cowsay" message in a window $hCowWin = _CowSayWin($sMessage, $iWidth, $iClipart, $iTextAlign) ; ; or you can use the _String_CowSay() function to get a string of the "cowsay ascii clipart" ; so that you can use it however you like, probably in a Consolewrite () for example ... ConsoleWrite(_String_CowSay($sMessage, $iWidth, $iClipart, $iTextAlign) & @CRLF) While 1 $aMsg = GUIGetMsg($GUI_EVENT_ARRAY) Switch $aMsg[1] Case $hCowWin Switch $aMsg[0] Case -3 ; $GUI_EVENT_CLOSE ExitLoop EndSwitch EndSwitch WEnd GUIDelete(HWnd($hCowWin)) Next EndFunc ;==>_Example ; #FUNCTION# ==================================================================================================================== ; Name ..........: _CowSayWin ; Description ...: Display a message in a standalone windows formatted in a balloon along with an ascii art figure ; Syntax ........: _CowSayWin($sMsg[, $iBoxLen = 21[, $iShape = 0[, $iAlign = 1]]]) ; Parameters ....: $sMsg - a string value. The message to display (in a single line without @cr and or @lf) ; $iBoxLen - [optional] an integer value. Default is 21. ; The wanted width of the Box contining the message ; $iShape - [optional] an integer value. Default is 0. ; The index of the ascii art figure to be displayed along with the message. ; Available values are: ; 0 -> a cow ; 1 -> a sandwich-man ; 2 -> the penguin Tux ; 3 -> a hanging monkey ; ..... to be continued (maybe) ; $iAlign - [optional] an integer value. Default is 1. ; How to justify the string within the frame, that is: ; 0 -> left justified ; 1 -> center justified (default) ; 2 -> right justified ; Return values .: The handle of the created window ; Author ........: Gianni Addiego (Chimp) ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _CowSayWin($sMsg, $iBoxLen = 21, $iShape = 0, $iAlign = 1) If $iBoxLen < 21 Then $iBoxLen = 21 Local $iSize = 12 Local $iWeight = $FW_NORMAL Local $iAttrib = $GUI_FONTNORMAL Local $sFont = "Courier new" Local $sSay = _String_CowSay($sMsg, $iBoxLen, $iShape, $iAlign) Local $aMsgReturn = _StringSize($sSay, $iSize, $iWeight, $iAttrib, $sFont) Local $iXpos = (@DesktopWidth - $aMsgReturn[2]) / 2 If $iXpos < 0 Then $iXpos = 0 Local $iYpos = (@DesktopHeight - $aMsgReturn[3]) / 2 If $iYpos < 0 Then $iYpos = 0 Local $hCow = GUICreate("Cowsay", -1, -1, $iXpos, $iYpos, -1, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) ;0x94C803C5, 0x00010101) ; , $WS_EX_DLGMODALFRAME) ;0x94C803C5, 0x00010101) ; Style & ExStyle same as msgbox GUISetFont($iSize, $FW_NORMAL, $GUI_FONTNORMAL, $sFont) _WinSetClientSize($hCow, $aMsgReturn[2], $aMsgReturn[3]) GUICtrlCreateLabel($sSay, 0, 0, $aMsgReturn[2], $aMsgReturn[3]) GUISetState(@SW_SHOW, $hCow) #cs While 1 Switch GUIGetMsg() Case -3 ; $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd #ce Return $hCow EndFunc ;==>_CowSayWin ; By kafu ; https://www.autoitscript.com/forum/topic/201524-guicreate-and-wingetclientsize-mismatch/?do=findComment&comment=1446141 Func _WinSetClientSize($hWnd, $iW, $iH) Local $aWinPos = WinGetPos($hWnd) Local $sRect = DllStructCreate("int;int;int;int;") DllStructSetData($sRect, 3, $iW) DllStructSetData($sRect, 4, $iH) _WinAPI_AdjustWindowRectEx($sRect, _WinAPI_GetWindowLong($hWnd, $GWL_STYLE), _WinAPI_GetWindowLong($hWnd, $GWL_EXSTYLE)) WinMove($hWnd, "", $aWinPos[0], $aWinPos[1], $aWinPos[2] + (DllStructGetData($sRect, 3) - $aWinPos[2]) - DllStructGetData($sRect, 1), $aWinPos[3] + (DllStructGetData($sRect, 4) - $aWinPos[3]) - DllStructGetData($sRect, 2)) EndFunc ;==>_WinSetClientSize ; #FUNCTION# ==================================================================================================================== ; Name ..........: _StringToColumn ; Description ...: passing a (long) string and a value, it returns that same string ; formatted in a column as wide as the value (string is split by @CRs). ; Whenever possible, it tries not to break the words but to split ; lines in between two words ; Syntax ........: _StringToColumn($sString[, $x = 21]) ; Parameters ....: $sString - a string value. The string to format ; $iColumnWidth - [optional] an integer value. Default is 21. ; The wanted width of the text column ; Return values .: The string formatted as required ; Author ........: Gianni Addiego (Chimp) ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _StringToColumn($sString, $iColumnWidth = 21) If $iColumnWidth < 1 Then $iColumnWidth = 1 Local $iPreviousSplit = 1 Local $i = $iColumnWidth While $i <= StringLen($sString) $iSplitPoint = StringInStr($sString, " ", 0, -1, $i + 1) If $iSplitPoint = 0 Or $iSplitPoint <= $iPreviousSplit Then $iSplitPoint = $i $sString = StringLeft($sString, $iSplitPoint) & @CR & StringMid($sString, $iSplitPoint + 1) $i = $iSplitPoint + 1 Else $sString = StringReplace($sString, $iSplitPoint, @CR) $i = $iSplitPoint EndIf $iPreviousSplit = $iSplitPoint $i += $iColumnWidth WEnd If StringRight($sString, 1) = @CR Then $sString = StringTrimRight($sString, 1) Return $sString EndFunc ;==>_StringToColumn ; #FUNCTION# ==================================================================================================================== ; Name ..........: _StringToFrame ; Description ...: places borders only to the left and to the right of the passed string block ; Syntax ........: _StringToFrame($sStr, $iFrameWidth[, $iAlign = 1[, $sV = "|"]]) ; Parameters ....: $sStr - The string to format; multiline string must be splitted by a @cr. ; $iFrameWidth - wanted Width of the frame ; If the desired width is less than the length of the string, the exceeding part is cut off ; If the desired width is wider than the length of the string, spaces are added ; $iAlign - [optional] an integer value. Default is 1. ; The string is justified within the frame based on the value of the $iAlign variable, that is: ; 0 -> left justified ; 1 -> center justified (default) ; 2 -> right justified ; $sV - [optional] a string value. Default is "|". ; This is the character used to draw the two vertical edges ; Return values .: The formatted string ; Author ........: Gianni Addiego (Chimp) ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _StringToFrame($sStr, $iFrameWidth, $iAlign = 1, $sV = "|") ; $iAlign: 0=Left; 1=Center; 2=Right If $iFrameWidth < 1 Then $iFrameWidth = 1 Local $a = StringSplit($sStr, @CR, 2) ; 2 = $STR_NOCOUNT For $i = 0 To UBound($a) - 1 Switch $iAlign Case 1 ; Center string $a[$i] = $sV & _StringSetLen(_StringCenter($a[$i], $iFrameWidth), $iFrameWidth) & $sV Case 2 ; Align to right $a[$i] = $sV & _StringSetLen($a[$i], $iFrameWidth * -1) & $sV Case Else ; otherwise Align to left $a[$i] = $sV & _StringSetLen($a[$i], $iFrameWidth) & $sV EndSwitch Next Return _ArrayToString($a, @CR) EndFunc ;==>_StringToFrame ; passing a string and a value it returns that string with a len as required ; By Gianni Addiego Func _StringSetLen($sString, $iWantedLen = 1, $sFillChr = " ") If $iWantedLen = 0 Then Return "" Local $iLen = StringLen($sString) Local $iKeepLeft = $iWantedLen > 0 ; else keep the right side of the string $iWantedLen = Abs($iWantedLen) If $iLen >= $iWantedLen Then ; reduce the string length If $iKeepLeft Then Return StringLeft($sString, $iWantedLen) Else Return StringRight($sString, $iWantedLen) EndIf Else ; add chars to the string to reach the wanted len If $iKeepLeft Then Return $sString & _StringRepeat($sFillChr, $iWantedLen - $iLen) Else Return _StringRepeat($sFillChr, $iWantedLen - $iLen) & $sString EndIf EndIf EndFunc ;==>_StringSetLen ; place a string in the middle of a given space ; By Gianni Addiego Func _StringCenter($sString, $iSpace) Local $iLen = StringLen($sString) $iHloc = Int($iSpace / 2) - Int($iLen / 2) If $iHloc < 0 Then Return StringMid($sString, Abs($iHloc) + 1, $iSpace) Else Return _StringRepeat(" ", $iHloc) & $sString EndIf EndFunc ;==>_StringCenter ; #FUNCTION# ==================================================================================================================== ; Name ..........: _String_CowSay ; Description ...: Formats a string in a balloon along with an ascii art figure ; Syntax ........: _String_CowSay($sMsg[, $iBoxLen = 21[, $iShape = 0[, $iAlign = 1]]]) ; Parameters ....: $sMsg - a string value. The String to format (in a single line without @cr and or @lf) ; $iBoxLen - [optional] an integer value. Default is 21. ; The wanted width of the Box contining the message ; $iShape - [optional] an integer value. Default is 0. ; The index of the ascii art figure to be displayed along with the message. ; Available values are: ; 0 -> a cow ; 1 -> a sandwich-man ; 2 -> the penguin Tux ; 3 -> a hanging monkey ; ..... to be continued (maybe) ; $iAlign - [optional] an integer value. Default is 1. ; How to justify the string within the frame, that is: ; 0 -> left justified ; 1 -> center justified (default) ; 2 -> right justified ; Return values .: The passed string formatted in the required format. ; Author ........: Gianni Addiego (Chimp) ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _String_CowSay($sMsg, $iBoxLen = 21, $iShape = 0, $iAlign = 1) ; minimum $iBoxLen is 21 If $iBoxLen / 2 = Int($iBoxLen / 2) Then $iBoxLen += 1 If $iBoxLen < 22 Then $x = 0 Else $x = Ceiling(($iBoxLen - 21) / 2) EndIf Local $sS = _StringRepeat(" ", $x), $sT = _StringRepeat("~", $x) Local $sHeader, $sFooter Switch $iShape Case 1 $sHeader = _ $sS & " \|||/" & @CRLF & _ $sS & " (o o)" & @CRLF & _ "," & $sT & "oo0~~~~~~(_)~~~~~~~~~" & $sT & "," & @CRLF ; header $sFooter = _ "'" & $sT & "~~~~~~~~~~~~~~~~~~oo0" & $sT & "'" & @CRLF & _ ; footer $sS & " |__|__|" & @CRLF & _ $sS & " || ||" & @CRLF & _ $sS & " oo0 0oo" Case 2 $sHeader = _ "," & $sT & "~~~~~~~~~~~~~~~~~~~~~" & $sT & "," & @CRLF ; header $sFooter = _ "'~~~~~~~~~~~~~~~~~~~~~" & $sT & $sT & "'" & @CRLF & _ " \ .--." & @CRLF & _ " \ |o_o |" & @CRLF & _ " |:_/ |" & @CRLF & _ " // \ \" & @CRLF & _ " (| | )" & @CRLF & _ " /'\_ _/`\" & @CRLF & _ " \___)=(___/" Case 3 $sHeader = _ "," & $sT & "~~~~~~~~~~~~~~~~~~~~~" & $sT & "," & @CRLF ; header $sFooter = _ "'" & $sT & "oo0~~~~~~~~~~~~~~~0oo" & $sT & "'" & @CRLF & _ ; footer $sS & " \\ //" & @CRLF & _ $sS & " > \ \\|||// / <" & @CRLF & _ $sS & " > \ _ _ / <" & @CRLF & _ $sS & " > \ / \ / \ / <" & @CRLF & _ $sS & " > \\_o_o_// <" & @CRLF & _ $sS & " > ( (_) ) <" & @CRLF & _ $sS & " >| |<" & @CRLF & _ $sS & " / |\___/| \" & @CRLF & _ $sS & " / (_____) \" & @CRLF & _ $sS & " / o \" & @CRLF & _ $sS & " ) ___ (" & @CRLF & _ $sS & " / / \ \" & @CRLF & _ $sS & " ( / \ )" & @CRLF & _ $sS & " >< ><" & @CRLF & _ $sS & " ///\ /\\\" & @CRLF & _ $sS & " ''' '''" Case Else $sHeader = _ "," & $sT & "~~~~~~~~~~~~~~~~~~~~~" & $sT & "," & @CRLF ; header $sFooter = _ "'~~~~~~~~~~~~~~~~~~~~~" & $sT & $sT & "'" & @CRLF & _ " \ ^__^" & @CRLF & _ " \ (oo)\_______" & @CRLF & _ " (__)\ )\/\" & @CRLF & _ " ||----w |" & @CRLF & _ " || ||" EndSwitch Return $sHeader & _StringToFrame(_StringToColumn($sMsg, $iBoxLen), $iBoxLen, $iAlign) & @CRLF & $sFooter EndFunc ;==>_String_CowSay
-
Happy holidays to all p.s. It looks best on a solid, homogeneous background. To move the tree click on the colored balls and drag. To "turn off" the tree click on it (to set the focus) and then press esc Have fun #include <GUIConstants.au3> #include <WinAPISys.au3> HotKeySet("{ESC}", "_TheEnd") Global $AlphaKey = 0x000000, $hLayer[6], $iWidth = 310, $iHeight = 290, $sBall = '♥' Global Const $aColors[6] = [0x00FF00, 0XFF0000, 0X0040FF, 0XFFFF00, 0X00FFFF, 0XFF00FF] ; 0xRRGGBB Global $a[] = ['.', '~', "'", $sBall, "'", '~', '.', '*', ' '], $tree = $a[8] & $a[7] & @CRLF, _ $hTreeGUI, $ndx, $sGotString, $sGetString, $ChristmasBalls, $sRandomBalls, $iNrOfBalls, $vDummy $hTreeGUI = GUICreate('', $iWidth, $iHeight, Default, Default, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST)) GUISetBkColor($AlphaKey, $hTreeGUI) _WinAPI_SetLayeredWindowAttributes($hTreeGUI, $AlphaKey, 0, $LWA_COLORKEY) GUISetState() For $i = 0 To 14 $tree &= StringRight($a[8], 15 - ($i + 1)) For $x = 0 To ($i + 1) * 2 $tree &= $a[Mod($ndx, 7)] $ndx += 1 Next $tree &= @CRLF If $i < 6 Then $hLayer[$i] = GUICtrlCreateLabel("", 0, 0, $iWidth, $iHeight, -1, $GUI_WS_EX_PARENTDRAG) $vDummy = GUICtrlSetFont(-1, 12, 800, 0, "Courier new") + GUICtrlSetColor(-1, $aColors[$i]) + GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) EndIf Next ; RegExp thanks to @seadoggie01 https://www.autoitscript.com/forum/topic/200770-how-to-clean-a-string-by-regexp/?do=findComment&comment=1440488 $ChristmasBalls = StringRegExpReplace($tree, "(*UCP)(?s)[^\Q" & $sBall & @CRLF & "\E]", " ") ; keep only balls StringReplace($ChristmasBalls, $sBall, $sBall) $iNrOfBalls = @extended GUICtrlSetData($hLayer[0], $tree) ; StringRegExpReplace($tree, "(*UCP)(?s)[\Q" & $a[7] & "\E]", " ")) While Sleep(2000) $sRandomBalls = $ChristmasBalls $RemainingBalls = $iNrOfBalls For $i = 1 To Random(5, $RemainingBalls - 5, 1) $sRandomBalls = StringReplace($sRandomBalls, StringInStr($sRandomBalls, $sBall, 0, Random(1, $RemainingBalls, 1)), " ") $RemainingBalls -= 1 Next For $i = 1 To 5 $sGetString = GUICtrlRead($hLayer[$i]) ; StringReplace(GUICtrlRead($hLayer[$i]), $a[7], " ") $sGotString = $sGetString For $ii = 1 To $RemainingBalls If StringMid($sGetString, StringInStr($sRandomBalls, $sBall, 0, $ii), 1) = $sBall Then $sGetString = StringReplace($sGetString, StringInStr($sRandomBalls, $sBall, 0, $ii), " ") EndIf Next If $sGotString <> $sGetString Then GUICtrlSetData($hLayer[$i], $sGetString) Next GUICtrlSetData($hLayer[Random(1, 5, 1)], $sRandomBalls) WEnd Func _TheEnd() If WinActive("[ACTIVE]") = $hTreeGUI Then Exit GUIDelete($hTreeGUI) EndFunc ;==>_TheEnd
-
A simple endless kaleidoscope made on a RichEdit control (hit esc to exit) Idea is from this link: http://www.calormen.com/jsbasic/ select the "Rod's Color Pattern" demo and run it on the Apple 2 emulator on that web page to see the original Apple II version. ; Idea from this link: http://www.calormen.com/jsbasic/ ; get the "Rod's Color Pattern" from the "Select a sample..." combo and run it ; #include <GuiRichEdit.au3> #include <GUIConstants.au3> HotKeySet("{ESC}", "_TheEnd") ; Global $iHwidth = 40, $iVheight = 40; width and height of screen Global $sBuffer = _StringReplay(_StringReplay(" ", $iHwidth + 1) & @CRLF, $iVheight) ;to fill the RichEdit Global $sChar = " " Global Const $aApplesoft_color[16] = [ _ ; LoRes colors in Applesoft basic 0x000000, _ ; 0x0 = 00 = Black 0XFF00FF, _ ; 0x1 = 01 = Magenta 0X0000A0, _ ; 0x2 = 02 = Dark Blue 0X800080, _ ; 0x3 = 03 = Purple 0X006400, _ ; 0x4 = 04 = Dark Green 0X808080, _ ; 0x5 = 05 = Grey 0X0000CD, _ ; 0x6 = 06 = Medium Blue 0XADD8E6, _ ; 0x7 = 07 = Light Blue 0XA52A2A, _ ; 0x8 = 08 = Brown 0XFFA500, _ ; 0x9 = 09 = Orange 0XD3D3D3, _ ; 0xA = 10 = Light Grey 0XFFC0CB, _ ; 0xB = 11 = Pink 0X008000, _ ; 0xC = 12 = Green 0XFFFF00, _ ; 0xD = 13 = Yellow 0X00FFFF, _ ; 0xE = 14 = Aqua 0xFFFFFF]; ; 0xF = 15 = White Global $MyGui = GUICreate("", 335, 630, -1, -1, $WS_POPUPWINDOW, BitOR($WS_EX_DLGMODALFRAME, $WS_EX_CLIENTEDGE, $WS_EX_COMPOSITED, $WS_EX_LAYERED)) $hGlass = GUICtrlCreateLabel("", 0, 0, 335, 630, -1, $GUI_WS_EX_PARENTDRAG) ; Protect the RichEdit and allows to drag the GUI around GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) ; This is like a glass over the underlying RichEdit GUICtrlSetCursor(-1, 2) ; Cursor is an arrow (instead of the default I-beam) ; ; This RichEdit is used to simulate the LoRes Graphic of tha Apple 2 (40x40 pixels) Global $hGR = _GUICtrlRichEdit_Create($MyGui, $sBuffer, 0, 0, 335, 630, BitOR($ES_READONLY, $ES_MULTILINE)) _GUICtrlRichEdit_SetSel($hGR, 0, -1) _GUICtrlRichEdit_SetFont($hGR, 10, "Courier new") _GUICtrlRichEdit_SetBkColor($hGR, 0xffffff) GUISetState() ; Main loop ; --------- While 1 For $W = 3 To 50 For $x = 19 To 1 Step -1 For $y = 19 To 0 Step -1 $xy = $x + $y $iColor = Mod(Int($y * 3 / ($x + 3) + $x * $W / 12), 16) $sChar = ChrW(32 + $iColor) ; comment this if you don't want chars (only color) If $iColor > 15 Then $iColor = 15 Print($sChar, $x, $xy, $iColor) Print($sChar, $xy, $x, $iColor) Print($sChar, 40 - $x, 40 - $xy, $iColor) Print($sChar, 40 - $xy, 40 - $x, $iColor) Print($sChar, $xy, 40 - $x, $iColor) Print($sChar, 40 - $x, $xy, $iColor) Print($sChar, $x, 40 - $xy, $iColor) Print($sChar, 40 - $xy, $x, $iColor) Next Next Next WEnd ; Print a char to Htab (Horiz. pos), Vtab (Vert pos) on the RichEdit ; ------------------------------------------------------------------ Func Print($sChar = "", $iHtab = 1, $iVtab = 1, $iColor = 0xffffff) _GUICtrlRichEdit_SetSel($hGR, GetAbsPos($iHtab, $iVtab), GetAbsPos($iHtab, $iVtab) + 1, True) _GUICtrlRichEdit_SetCharBkColor($hGR, $aApplesoft_color[$iColor]) _GUICtrlRichEdit_ReplaceText($hGR, $sChar, False) EndFunc ;==>Print ; From Htab Vtab (1 based) to Absolute position within the RichEdit ; ----------------------------------------------------------------- Func GetAbsPos($iHtab = 1, $iVtab = 1, $iScreenWidth = $iHwidth) Return ($iVtab - 1) * ($iScreenWidth + 2) + $iHtab EndFunc ;==>GetAbsPos ; returns one or more chars replicated n times ; Example: ConsoleWrite(_StringReplay('*', 5) & @CRLF) Func _StringReplay($sChars = "", $iRepeats = 0) $sChars = String($sChars) $iRepeats = Int(Abs(Number($iRepeats))) Return StringReplace(StringFormat('%' & $iRepeats & 's', ""), " ", $sChars) EndFunc ;==>_StringReplay Func _TheEnd() If WinActive("[ACTIVE]") = $MyGui Then _GUICtrlRichEdit_Destroy($hGR) Exit EndIf EndFunc ;==>_TheEnd
- 14 replies
-
Just for fun Idea from here: http://codegolf.stackexchange.com/questions/73259/output-the-current-time-in-ascii-art Edit: Also added an analogue experimental version in post #11 #include <GUIConstants.au3> HotKeySet("{ESC}", "End") Local $hClock, $sDelim = ";", $aChar, $sScanLines, $aScanLine[6], $aFont[13] = [ _ ' ___ ; / _ \ ; | | | | ; | | | | ; | |_| | ; \___/ ', _ ; 0 ' __ ; /_ | ; | | ; | | ; | | ; |_| ', _ ; 1 ' ___ ; |__ \ ; ) | ; / / ; / /_ ; |____| ', _ ; 2 ' ____ ; |___ \ ; __) | ; |__ < ; ___) | ; |____/ ', _ ; 3 ' _ _ ; | || | ; | || |_ ; |__ _| ; | | ; |_| ', _ ; 4 ' _____ ; | ____| ; | |__ ; |___ \ ; ___) | ; |____/ ', _ ; 5 ' __ ; / / ; / /_ ; | _ \ ; | (_) | ; \___/ ', _ ; 6 ' ______ ; |____ | ; / / ; / / ; / / ; /_/ ', _ ; 7 ' ___ ; / _ \ ; | (_) | ; > _ < ; | (_) | ; \___/ ', _ ; 8 ' ___ ; / _ \ ; | (_) | ; \__, | ; / / ; /_/ ', _ ; 9 ' ; _ ;(_); _ ;(_); ', _ ; : " ; ; __ _ _ __ ;/ _` | ' \;\__,_|_|_|_|; ", _ ; am " ; ; _ __ _ __ ;| '_ \ ' \;| .__/_|_|_|;|_|"]; pm Global $hAsciiClock = GUICreate("Ascii clock", 390, 80, 10, 10, $WS_POPUPWINDOW, BitOR($WS_EX_DLGMODALFRAME, $WS_EX_CLIENTEDGE, $WS_EX_COMPOSITED)) $hClock = GUICtrlCreateLabel("", 0, 0, 390, 80, -1, $GUI_WS_EX_PARENTDRAG) GUICtrlSetFont(-1, 7, 0, 0, "Courier new") GUISetState() While 1 $sTime = StringFormat("%02s", @HOUR - (12 * (@HOUR > 12))) & "A" & @MIN & "A" & @SEC & Hex(11 + Number(@HOUR > 12), 1) For $x = 1 To StringLen($sTime) $achar = StringSplit($aFont[Dec(StringMid($sTime, $x, 1))], $sDelim, 3) For $i = 0 To 5 If $x = StringLen($sTime) Then ; last char (am or pm) $aScanLine[$i] = StringFormat('%-65s', $aScanLine[$i]) & $achar[$i] Else $aScanLine[$i] &= $achar[$i] EndIf Next Next For $i = 0 To 5 $sScanLines &= $aScanLine[$i] & @CRLF $aScanLine[$i] = "" Next GUICtrlSetData($hClock, $sScanLines) $sScanLines = "" Sleep(1000) WEnd Func End() If WinActive("[ACTIVE]") = $hAsciiClock Then Exit EndFunc ;==>End