Jump to content

Search the Community

Showing results for tags 'banner'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. I personally like to make (large) headers in my code which makes it simpler for me to navigate quickly. There was the FigLet tool already, but it was not integrated into the editor. I modified it a little and present here my first try of example script. Features: [version 1.01] Settings via ini file Will ignore non-English characters and replace by user-defined User-definable comment style when inserting Auto-insert at cursor point in SciTE (thanks to Jon for help with this !) My idea of the tool is to bind it to a key, to very quickly be able to insert banners, already commented out. I would really appreaciate any comments on this. You are welcome to make / suggest additions + improvements. Edit: attached zip.au3. ;~ ####### ####### ;~ # # #### # ###### ##### # #### #### # ;~ # # # # # # # # # # # # # ;~ ##### # # # ##### # # # # # # # ;~ # # # ### # # # # # # # # # ;~ # # # # # # # # # # # # # ;~ # # #### ###### ###### # # #### #### ###### ;~ ;~ ####### # ### ####### ##### ;~ # #### ##### # # # # ##### #### # # # # ;~ # # # # # # # # # # # # # # # ;~ ##### # # # # # # # # # # # # # ##### ;~ # # # ##### ####### # # # # # # # # ;~ # # # # # # # # # # # # # # # # ;~ # #### # # # # #### # #### ### # ##### ;~ ;~ _ _ _ __ _____ __ ;~ | | | | (_) / | | _ |/ | ;~ | | | | ___ _ __ ___ _ ___ _ __ `| | | |/' |`| | ;~ | | | | / _ \| '__|/ __|| | / _ \ | '_ \ | | | /| | | | ;~ \ \_/ /| __/| | \__ \| || (_) || | | | _| |_ _ \ |_/ /_| |_ ;~ \___/ \___||_| |___/|_| \___/ |_| |_| \___/(_) \___/ \___/ ;~ #include <Array.au3> #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <File.au3> #include <GUIComboBox.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <Zip.au3> Global $gInputText, $gComboFont, $gEditSignature, $gCurrentFont = "", $gSelFont, $gCommentStyle, $gUnknownReplace Global $gFontData, $gFontMetaData[10], $gFontDir = @ScriptDir & "\fonts\" _Main() Exit Func _Main() ; Create and show GUI GUICreate("AutoFiglet", 810, 426, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX)) GUICtrlCreateLabel("Text line", 8, 8, 550, 16) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHEIGHT, $GUI_DOCKTOP, $GUI_DOCKLEFT)) $gInputText = GUICtrlCreateInput("", 8, 28, 550, 20) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHEIGHT, $GUI_DOCKTOP, $GUI_DOCKLEFT)) $gEditSignature = GUICtrlCreateEdit("", 8, 56, 794, 320, BitOR($ES_AUTOVSCROLL, $WS_HSCROLL, $ES_WANTRETURN)) GUICtrlSetResizing(-1, BitOR($GUI_DOCKRIGHT, $GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKBOTTOM)) GUICtrlSetFont(-1, 9, 400, 0, "Courier New") Local $btnGenerate = GUICtrlCreateButton("Generate", 680, 384, 122, 32, $BS_DEFPUSHBUTTON) GUICtrlSetResizing(-1, BitOR($GUI_DOCKRIGHT, $GUI_DOCKBOTTOM, $GUI_DOCKHEIGHT, $GUI_DOCKWIDTH)) GUISetState(@SW_SHOW) ; setup selected font $gSelFont = IniRead(@ScriptDir & "\figlet.ini", "figlet", "font", "banner") ; does font exist ? No, set to "banner" If Not FileExists($gFontDir & "\" & $gSelFont & ".zip") Then $gSelFont = "banner" EndIf ; setup comment style $gCommentStyle = IniRead(@ScriptDir & "\figlet.ini", "figlet", "comment", ";" & @TAB) $gCommentStyle = StringReplace($gCommentStyle, "\t", @TAB) ; setup unknown replacement $gUnknownReplace = IniRead(@ScriptDir & "\figlet.ini", "figlet", "unknown", "space") $gUnknownReplace = StringReplace($gUnknownReplace, "space", " ") $gUnknownReplace = StringReplace($gUnknownReplace, "question", "?") $gUnknownReplace = StringReplace($gUnknownReplace, "none", "") ; initially load the font _LoadFont($gSelFont) ; WM_COMMAND will tell us when the text has changed GUIRegisterMsg($WM_COMMAND, "_WmCommand") Local $nMsg While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $btnGenerate ;~ _SciTE_InsertText($figlet) $figlet = GUICtrlRead($gEditSignature) ; Comment out for AutoIT $figlet = StringRegExpReplace($figlet, "(?m)^.", $gCommentStyle) ; fix for insertion into SciTE ; thanks to Jos for help on this!! $figlet = StringReplace($figlet, @CRLF, "\r") _SciTE_InsertText($figlet) Exit EndSwitch WEnd ; Discard GUI GUIDelete() EndFunc ;==>_Main Func _WmCommand($hWndGUI, $msgID, $wParam, $lParam) If $lParam = GUICtrlGetHandle($gInputText) Then If _WinAPI_HiWord($wParam) = $EN_CHANGE Then ;~ _Display(GUICtrlRead($gInputText), GUICtrlRead($gComboFont)) _Display(GUICtrlRead($gInputText), $gCurrentFont) EndIf EndIf EndFunc ;==>_WmCommand Func _Display($sText, $sFontName) Local $i, $j, $sChar, $sOutput = "" _LoadFont($sFontName) For $i = 1 To $gFontMetaData[2] For $j = 1 To StringLen($sText) $sChar = StringMid($sText, $j, 1) ; need to handle English (figlet compatible) chars only... If StringRegExp($sChar, "(?i)[a-z0-9[:punct:]\s]") Then $sOutput &= _GetCharacter($sChar, $i) Else ; handle replacement with nothing... if stringlen($gUnknownReplace) >0 then $sOutput &= _GetCharacter($gUnknownReplace, $i) EndIf EndIf Next $sOutput &= @CRLF Next GUICtrlSetData($gEditSignature, $sOutput) EndFunc ;==>_Display Func _LoadFont($sFontName) If $sFontName = $gCurrentFont Then Return Local $aTemp, $sTemp, $nUBound, $sFileLocation = $gFontDir & $sFontName & ".flf", $fTemp = False ; Try and unzip it first FileCopy($sFileLocation, @TempDir & "\" & $sFontName & ".zip") _Zip_UnzipAll(@TempDir & "\" & $sFontName & ".zip", @TempDir) If @error = 0 Then ; It unzipped OK so let's flag the temporary file $fTemp = True $sFileLocation = @TempDir & "\" & $sFontName & ".flf" EndIf FileDelete(@TempDir & "\" & $sFontName & ".zip") ; Read in the figlet font in to out array _FileReadToArray($sFileLocation, $gFontData) $aTemp = StringSplit($gFontData[1], " ", 2) ; Split the first line at spaces $nUBound = UBound($aTemp) ; Remember how many parameters we have $sTemp = $aTemp[0] ; This contains the signature and the hard blank character $gFontMetaData[0] = StringLeft($sTemp, StringLen($sTemp) - 1) ; Signature $gFontMetaData[1] = StringRight($sTemp, 1) ; Hard blank $gFontMetaData[2] = Number($aTemp[1]) ; Height of each letter ;$gFontMetaData[3] = Number($aTemp[2]) ;$gFontMetaData[4] = Number($aTemp[3]) ;$gFontMetaData[5] = Number($aTemp[4]) $gFontMetaData[6] = Number($aTemp[5]) ;If ($nUBound > 6) Then $gFontMetaData[7] = Number($aTemp[6]) ;If ($nUBound > 7) Then $gFontMetaData[8] = Number($aTemp[7]) ;If ($nUBound > 8) Then $gFontMetaData[9] = Number($aTemp[8]) ;If ($gFontMetaData[0] <> "flf2a") Then Return SetError(1, 0, $sFontName & " is not a valid font") If $fTemp Then FileDelete($sFileLocation) $gCurrentFont = $sFontName EndFunc ;==>_LoadFont Func _GetCharacter($sChar, $nLine) Local $nStart = $gFontMetaData[6] + ((Asc($sChar) - 32) * $gFontMetaData[2]), $sTemp $sTemp = $gFontData[$nStart + $nLine + 1] $sTemp = StringReplace($sTemp, StringRight($sTemp, 1), "") $sTemp = StringReplace($sTemp, $gFontMetaData[1], " ") Return $sTemp EndFunc ;==>_GetCharacter ; ======================================================================================== Func _SciTE_InsertText($sString) Return _SciTE_Send_Command(0, WinGetHandle("DirectorExtension"), "insert:" & $sString) EndFunc ;==>_SciTE_InsertText Func _SciTE_Send_Command($hHandle, $hSciTE, $sString) Local $ilParam, $tData If StringStripWS($sString, 8) = "" Then Return SetError(2, 0, 0) ; String is blank. EndIf $sString = ":" & Dec(StringTrimLeft($hHandle, 2)) & ":" & $sString ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sString = ' & $sString & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $tData = DllStructCreate("char[" & StringLen($sString) + 1 & "]") ; wchar DllStructSetData($tData, 1, $sString) $ilParam = DllStructCreate("ptr;dword;ptr") ; ulong_ptr;dword;ptr DllStructSetData($ilParam, 1, 1) ; $ilParam, 1, 1 DllStructSetData($ilParam, 2, DllStructGetSize($tData)) DllStructSetData($ilParam, 3, DllStructGetPtr($tData)) _SendMessage($hSciTE, $WM_COPYDATA, $hHandle, DllStructGetPtr($ilParam)) Return Number(Not @error) EndFunc ;==>_SciTE_Send_Command A ini-file for settings: [figlet] ; name of font file without extension ; if not existing or not found, font is "banner" font=banner ; default style of commenting ; use \t for tab comment=;~\t ; value of unknown ; use space | question | none unknown=none Zip.au3
×
×
  • Create New...