AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

For the coders - Automatic comment box

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
jballi



Joined: 01 Oct 2005
Posts: 334
Location: Texas, USA

PostPosted: Tue Nov 01, 2005 6:06 am    Post subject: For the coders - Automatic comment box Reply with quote

Adding documentation to code is a pain but it is even more difficult if you're like me and you like to put the titles for functions, subroutine, etc. inside of comment boxes. For AHK code, I use (at least) 4 different types of comment boxes for various sections of the code. I did a cursory search of this forum for utility or function to automatically build a comment box (not exactly sure what to search for) but I didn't find anything.

So... I wrote some code to put stuff into a comment box. I turned it into a function to make it more flexible. The code is not as mature as I would like but I wanted to share it while I was thinking about it.

Most of the need-to-know stuff has been included in the comments of the function, so take a few minutes to take a look-see before coding for it. Here's the code:

Code:

;*********************
;*                   *
;*    Comment Box    *
;*                   *
;*********************
CommentBox(p_LeftBox,p_RightBox,p_Border,p_TitleWidthPad=2,p_TitleHeightPad=0
    ,p_MinBoxWidth=0,p_Justify="")
    {
;
; Parameters
; ==========
; p_LeftBox        - Left Box character(s). Required parameter
; p_RightBox       - Right Box character(s). Required parameter
; p_Border         - Top/Bottom border character (1st character (for now)).  Required parameter
; p_TitleWidthPad  - Number of space characters to pad title. Default=2
; p_TitleHeightPad - Number of empty lines before and after title(s). Default=0
; p_MinBoxWidth    - Minimum width of the comment box.  Default=0
; p_Justify        -
;
;   "L" to justify left
;   "C" to center (default)
;   "R" to justify right.  Don't know why you would use this but wth
;   "N" for no justification.  All intelligent processing (AutoTrim) turned off
;
; Example:
;
;    AAAACCCCCCCCCCCCCCCCCCCBB    A=Left Box, B=Right Box, C=Border
;    AAAA                   BB
;    AAAA                   BB
;    AAAADDDDDThe TitleDDDDDBB    D=%p_TitleWidthPad% space characters before and after title
;    AAAA      Title 2      BB
;    AAAA                   BB    This line is created if p_TitleHeightPad >= 1
;    AAAA                   BB    This line is created if p_TitleHeightPad >= 2, etc., etc.
;    AAAACCCCCCCCCCCCCCCCCCCBB   
;
;
; Notes
; =====
;
; Clipboard
; ---------
; This function uses the clipboard as the source of the comment
; title(s) but the clipboard is not modified by this function.
; The resulting comment box is returned as string.
;
; AutoTrim
; --------
; By default, this function automatically removes all leading and
; trailing spaces and tabs from a title before determining where the
; title fits in the box.  For example, if the titles contains the
; following lines (sans quotes):
;
;     "Title1    "
;     "Title2      "
;
; The function will return a box that will look something like this
; (sans quotes):
;
;     "************"
;     "*  Title1  *"
;     "*  Title2  *"
;     "************"
;
; To turn off this "feature", set p_Justify to "N" (no justification).
; All leading and trailing spaces and tabs will be considered part of
; the title.
;
;
; AutoPad
; -------
; By default, the function analyzes the 1st title line to determine
; where the left side of the box will begin on each line.  If the 1st
; line has leading spaces and/or tabs, each line of the box will lead
; with the same.  For example, if the titles contains the following
; lines (sans quotes):
;
;     "    Title1"
;     "        Title2   "
;
; The function will return a box that will look something like this
; (sans quotes):
;
;     "    ************"
;     "    *  Title1  *"
;     "    *  Title2  *"
;     "    ************"
;
; This "feature" can be bypassed by removing all leading spaces/tabs
; from the 1st line or by including a blank line as the 1st line
; (delete the extra line after the box is built).  This feature can
; also be bypassed by setting p_Justify to "N" but the results may
; not be as expected.
;
;
; Misc
; ----
; This function does not format text.  If you want to enclose a lot of
; text in a comment box, be sure to format it before doing so.
;
;
; Example of use
; --------------
; The following is an example of how this function can be used within
; a Hotkey:
;     
;      ;========== start of example ==========
;      $Clipboard:=ClipboardAll  ;-- Save current clipboard

;      ;-- Copy selected
;      clipboard=
;      send ^c
;      ClipWait 0.1
;      if errorlevel=0
;          {
;          clipboard:=CommentBox(";*","*","*",4,2,0,"Center")
;          Send ^v  ;-- Paste clipboard
;          }

;      clipboard:=$Clipboard  ;-- Restore original clipboard
;      ;========== end of example ==========
;
;
; To execute (using this example), select the desired text, press the
; associated hotkey, and the selected text will be replaced with a
; comment box.  Most editors will allow you to reverse the action by
; entering Ctrl+Z.
;
;---------------------------------------------------------------------

    ;--------------
    ;-- Initialize
    ;--------------
    AutoTrim off
    t_CRLF=`r`n
    t_Clipboard:=clipboard  ;-- Working copy of clipboard
    t_CommentBox=

    ;------------------------
    ;-- Transform parameters 
    ;------------------------
    StringLeft p_Border,p_Border,1
    t_LeftBoxLen:=strlen(p_LeftBox)
    t_RightBoxLen:=strlen(p_RightBox)

    if p_TitleWidthPad is not integer
        p_TitleWidthPad=2
    if p_TitleHeightPad is not integer
        p_TitleHeightPad=0
    if p_MinBoxWidth is not integer
        p_MinBoxWidth=0

    ;-- p_Justify
    StringLeft p_Justify,p_Justify,1
    if p_Justify not in l,c,n,r
        p_Justify=C


    ;------------------------
    ;-- Identify environment
    ;------------------------

    ;-- If it exists, delete trailing CRLF from t_clipboard
    t_TrailingCRLF=N
    StringRight t_RString,t_clipboard,2
    if t_RString=%t_CRLF%
        {
        StringTrimRight t_clipboard,t_clipboard,2
        t_TrailingCRLF=Y
        }
       
    ;-- Identify leading spaces/tabs of 1st line
    t_BoxPad=
    if p_justify<>N
        loop parse,t_clipboard,`n,`r
            {
            t_Title:=A_LoopField  ;-- Assign but don't AutoTrim
            loop parse,t_Title
                {
                if A_LoopField=%A_Space%
                    t_BoxPad=%t_BoxPad%%A_Space%
                 else
                    if A_LoopField=%A_Tab%
                        t_BoxPad=%t_BoxPad%%A_Tab%
                     else
                        break
                }
            break
            }

    ;-- Identify maximum title length
    AutoTrim on
    if p_Justify=N
        AutoTrim off
    t_MaxTitleLen=0
    loop parse,t_clipboard,`n,`r
        {
        t_cbLine=%A_LoopField%  ;-- Assign and AutoTrim
        if strlen(t_cbLine)>t_MaxTitleLen
            t_MaxTitleLen:=strlen(t_cbLine)
        }

    ;-- Adjust for minimum?
    t_BoxWidth:=t_LeftBoxLen + t_RightBoxLen + t_MaxTitleLen + (p_TitleWidthPad * 2)
    if p_MinBoxWidth>%t_BoxWidth%
        t_MaxTitleLen:=p_MinBoxWidth - (t_LeftBoxLen + t_RightBoxLen + (p_TitleWidthPad * 2))

    ;---------------------------
    ;-- Build preliminary stuff
    ;---------------------------
    AutoTrim off

    ;-- Title pad
    t_TitlePad=
    loop %p_TitleWidthPad%
        t_TitlePad=%t_TitlePad%%A_Space%

    ;-- Border and Title Fill
    t_FillLen:=t_MaxTitleLen + (p_TitleWidthPad * 2)
    t_BorderFill=
    t_TitleFill=
    loop %t_FillLen%
        {
        t_BorderFill=%t_BorderFill%%p_Border%
        t_TitleFill=%t_TitleFill%%A_Space%
        }
    t_BorderLine=%p_LeftBox%%t_BorderFill%%p_RightBox%
    t_TitleFillLine=%p_LeftBox%%t_TitleFill%%p_RightBox%


    ;---------------------
    ;-- Build Comment Box
    ;---------------------
    AutoTrim off

    ;-- Top border
    t_CommentBox=%t_CommentBox%%t_BoxPad%%t_BorderLine%%t_CRLF%

    ;-- Before title empty line(s)
    loop %p_TitleHeightPad%
        t_CommentBox=%t_CommentBox%%t_BoxPad%%t_TitleFillLine%%t_CRLF%

    ;-- Title lines
    loop parse,t_clipboard,`n,`r
        {
        AutoTrim on
        if p_Justify=N
            AutoTrim off
        t_Title=%A_LoopField%  ;-- Assign and AutoTrim
        AutoTrim off

        ;-- Justify Title
        loop
            {
            if strlen(t_Title)=t_MaxTitleLen
                break

            ;-- Pad left
            if p_Justify in c,r
                {
                t_Title=%A_Space%%t_Title%
                if strlen(t_Title)=t_MaxTitleLen
                    break
                }

            ;-- Pad right
            if p_Justify in c,n,l
                t_Title=%t_Title%%A_Space%
            }

        t_TitleLine=%p_LeftBox%%t_TitlePad%%t_Title%%t_TitlePad%%p_RightBox%
        t_CommentBox=%t_CommentBox%%t_BoxPad%%t_TitleLine%%t_CRLF%
        }


    ;-- After title empty line(s)
    loop %p_TitleHeightPad%
        t_CommentBox=%t_CommentBox%%t_BoxPad%%t_TitleFillLine%%t_CRLF%

    ;-- Bottom border
    t_CommentBox=%t_CommentBox%%t_BoxPad%%t_BorderLine%%t_CRLF%

    ;-- If appropriate, delete final CRLF
    if t_TrailingCRLF=N
        StringTrimRight t_CommentBox,t_CommentBox,2

    ;-- Housekeeping
    AutoTrim on
   
    ;-- Return to sender
    return t_CommentBox
    }



I use code to build a comment box when I use the Ctrl+B hotkey while within an text editor (Notepad, Wordpad, EditPad). Here's a simplified version of what my code looks like: Since this a simplified version, I haven't tested it this state.
Code:

;[==========]
;[  Ctrl+B  ]
;[==========]
$^b::

;-- Notepad, Wordpad, or EditPad active?
WinGetClass $WindowClass,A  ;-- Class of active window
if $WindowClass not in Notepad,WordPadClass,TFormEditPadLite  ;-- Add whatever editor you use
    {
    send ^b
    return
    }

;-- Save current clipboard
$Clipboard:=ClipboardAll


;-- Copy to clipboard if something is selected
clipboard=
send ^c
ClipWait 0.1
if errorlevel<>0
    {
    clipboard:=$Clipboard
    soundplay *16 ;-- Error
    return
    }

;-- Collect 1 character command
Input $Command,L1 M T5,,1,2,3,4
if errorlevel not in 0,Match
    {
    clipboard:=$Clipboard
    soundplay *16 ;-- Error
    return
    }

;-----------------------
;-- Build comment boxes
;-----------------------
if $Command=1
    clipboard:=CommentBox(";--","","-",1)
if $Command=2
    clipboard:=CommentBox(";[","]","=")
if $Command=3
    clipboard:=CommentBox(";*","*","*",4,1)
if $Command=4
    clipboard:=CommentBox(";*","*","*",4,2,124,"N")

;-------------------
;-- Paste results
;-------------------
Send ^v

;-- Restore original clipboard
clipboard:=$Clipboard

return

I've also created a GUI front-end for this function. If you're interested, let me know and I'll post it.

I hope someone finds this useful.
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Tue Nov 01, 2005 3:19 pm    Post subject: Reply with quote

That's really nice. Although I don't make many comment boxes, I can see why this would be very useful to a lot of programmers and scripters.

Thanks for posting it and for the clear presentation.
Back to top
View user's profile Send private message Send e-mail
Atomhrt



Joined: 02 Sep 2004
Posts: 128
Location: Sunnyvale

PostPosted: Wed Nov 02, 2005 10:16 pm    Post subject: Reply with quote

Oh yeah! Cool! Please post the GUI frontend too. Many thanks.
_________________
I am he of whom he speaks!
Back to top
View user's profile Send private message
jballi



Joined: 01 Oct 2005
Posts: 334
Location: Texas, USA

PostPosted: Thu Nov 03, 2005 7:05 am    Post subject: Re: For the coders - Automatic comment box Reply with quote

These 4 subroutines represent my (scaled down) version of the GUI front-end to create a comment box using the CommentBox function.

A few notes...

This is not stand-alone code. These subroutines must be incorporated into a existing script. This bunch of code (subroutines and functions) can easily be turned into a stand-alone program if you so desire. I like incorporating it into my main script because the use of global variables allows you to have easy-to-use dynamic defaults.

About the GUI...

I am a GUI n00b. I'm sure that this little dialog could be improved significantly.

If this is the only GUI window you have in your script, you're set. If you have other GUI windows, you may have to modify the code to account for multiple GUI windows. I've never done it so I'm not exactly sure what all is involved. Check the documentation for more information.

The GUI is time-control via a timer. The operation will abort if the user does not press the OK or Cancel button within 60 seconds. Feel free to increase/decrease the time limit or get rid of the timer entirely.

Here are the subroutines. Since this is the scaled-down version, I haven't tested it this state.
Code:

;*************************
;*                       *
;*    Comment Box GUI    *
;*                       *
;*************************
CommentBoxGUI:

;-- Set defaults
if strlen($gui_TitleWidthPad)=0
    $gui_TitleWidthPad=2
if strlen($gui_TitleHeightPad)=0
    $gui_TitleHeightPad=0
if strlen($gui_MinBoxWidth)=0
    $gui_MinBoxWidth=0
if strlen($gui_JustifyCenter)=0
    $gui_JustifyCenter=1
if strlen($gui_JustifyLeft)=0
    $gui_JustifyLeft=0
if strlen($gui_JustifyRight)=0
    $gui_JustifyRight=0
if strlen($gui_JustifyNone)=0
    $gui_JustifyNone=0

;-- Build/Show dialog
; Generated using SmartGUI Creator 3.5.1
gui +AlwaysOnTop -SysMenu
gui Add, Text, x16 y20 w110 h20, Left box character(s):
gui Add, Edit, v$gui_LeftBox  x126 y20 w60 h20, %$gui_LeftBox%
gui Add, Text, x16 y50 w110 h20, Right box character(s):
gui Add, Edit, v$gui_RightBox x126 y50 w60 h20, %$gui_RightBox%
gui Add, Text, x16 y80 w110 h20, Border character:
gui Add, Edit, v$gui_Border limit1 x126 y80 w20 h20, %$gui_Border%
gui Add, Text, x16 y110 w110 h30, Number of spaces to pad title line(s):
gui Add, Edit, v$gui_TitleWidthPad +number x126 y120 w20 h20, %$gui_TitleWidthPad%
gui Add, Text, x16 y150 w110 h40, Number of empty lines before and after title line(s):
gui Add, Edit, v$gui_TitleHeightPad +number x126 y170 w20 h20, %$gui_TitleHeightPad%
gui Add, Text, x16 y200 w110 h20, Minimum box width:
gui Add, Edit, v$gui_MinBoxWidth +number x126 y200 w30 h20, %$gui_MinBoxWidth%
gui Add, Text, x16 y230 w110 h20, Justify title text:
gui Add, Radio, v$gui_JustifyCenter checked%$gui_JustifyCenter% x126 y230 w50 h20, Center
gui Add, Radio, v$gui_JustifyLeft checked%$gui_JustifyLeft% x126 y250 w50 h20, Left
gui Add, Radio, v$gui_JustifyRight checked%$gui_JustifyRight% x126 y270 w50 h20, Right
gui Add, Radio, v$gui_JustifyNone checked%$gui_JustifyNone% x126 y290 w50 h20, None
gui Add, Button, +default gCommentBoxGUI_OK x16 y330 w70 h20, &OK
gui Add, Button, gCommentBoxGUI_Cancel x116 y330 w70 h20, Cancel
gui Show, x374 y141 h363 w206, Build Comment Box
SetTimer CommentBoxGUI_Timeout,60000
return


CommentBoxGUI_Timeout:
SetTimer CommentBoxGUI_Timeout,off
gui destroy
msgbox CommentBoxGUI: Timeout. Operation canceled
return


CommentBoxGUI_Cancel:
SetTimer CommentBoxGUI_Timeout,off
gui destroy
return


CommentBoxGUI_OK:
SetTimer CommentBoxGUI_Timeout,off
gui submit
gui destroy

;-- Save current clipboard
$Clipboard:=ClipboardAll

;-- Copy selected text to clipboard
clipboard=
send ^c
ClipWait 0.1
if errorlevel<>0
    clipboard:=$Clipboard
    msgbox No text selected.  Command aborted.
    return
    }

;---------------------
;-- Build comment box
;---------------------
if $gui_JustifyCenter=1
    $Justify=Center
 else
    if $gui_JustifyLeft=1
        $Justify=Left
     else
        if $gui_JustifyRight=1
            $Justify=Right
         else
            if $gui_JustifyNone=1
                $Justify=None

clipboard:=CommentBox($gui_LeftBox,$gui_RightBox,$gui_Border,$gui_TitleWidthPad,$gui_TitleHeightPad,$gui_MinBoxWidth,$Justify)

;-- Paste results
Send ^v

;-- Restore original clipboard
clipboard:=$Clipboard

return


To use, call the CommentBoxGUI subroutine from anywhere. For example [untested]:
Code:

;[==========]
;[  Ctrl+B  ]
;[==========]
$^b::

;-- Notepad, Wordpad, or EditPad active?
WinGetClass $WindowClass,A  ;-- Class of active window
if $WindowClass not in Notepad,WordPadClass,TFormEditPadLite  ;-- Add whatever editor you use
    {
    send ^b
    return
    }

gosub CommentBoxGUI
return
Back to top
View user's profile Send private message
Trubbleguy



Joined: 20 Jan 2007
Posts: 73
Location: Melbourne

PostPosted: Fri Aug 31, 2007 3:38 am    Post subject: Reply with quote

Try this then, it also jumps to any subroutine you select from the Gui instantly
Code:
;---------------------------------------------------------------------------------------------
; @@@@          @@@      @@@@                   @@            @      @@  @@  @@@@      @@@@@  ;
;@@  @@          @@     @@  @@                               @@      @@  @@ @@  @@    @@   @@ ;
;@@@    @@  @@   @@     @@@     @@@@   @@ @@@  @@@  @@ @@@  @@@@@    @@  @@     @@    @@  @@@ ;
; @@@   @@  @@   @@@@@   @@@   @@  @@   @@@ @@  @@   @@  @@  @@      @@  @@   @@@     @@ @@@@ ;
;   @@@ @@  @@   @@  @@    @@@ @@       @@  @@  @@   @@  @@  @@      @@  @@  @@       @@@@ @@ ;
;@@  @@ @@  @@   @@  @@ @@  @@ @@  @@   @@      @@   @@@@@   @@ @     @@@@  @@  @@ @@ @@@  @@ ;
; @@@@   @@@ @@ @@ @@@   @@@@   @@@@   @@@@    @@@@  @@       @@       @@   @@@@@@ @@  @@@@@  ;
;---------------------------------------------------@@@---------------------------------------;
;With BigNotes...and ToolTipper.
;use ;tag as the key to jumping to a sub ALT+T will insert one wherever you need it
;whatever is on the next line after ;tag is displayed in the subscript window
; language:       english
; platform:       win9x/nt
; author:         t. gowshall <trubbleguy@optusnet.com.au>
#singleinstance force
#WinActivateForce
#persistent
normal:=A_BatchLines
#noenv
onexit, quit
sendmode input
wingetactivetitle,_title
programname = subscript ; debug: to do
programversion = v1.001 ; debug: to do
programfullname = %programname% %programversion%
programauthor = trubbleguy ; debug: to do
inifilename=none
guinum=1
SetTimer, Tooltipclear,250
Settimer caps, 1000
settitlematchmode,2
_ini=%a_scriptdir%\%inifilename%.ini
stringcasesense,off
sysget, mwa, monitorworkarea,1
_y := mwabottom-30
_l:=_y/15
splash=looking for tags in %_title%
progress, x1 y15 zh0 zy1  b w%a_screenwidth% c10 cwdefault ct00ff00 fs14,%splash%,,status
winmove,status,%splash%,1,1
;winset, transcolor, default, status
gosub traymenu
gosub buttoninfo

onmessage(0x200,"mouseover")
;---------------------
;  @@@@           @@  ;
; @@  @@              ;
;@@      @@  @@  @@@  ;
;@@      @@  @@   @@  ;
;@@  @@@ @@  @@   @@  ;
; @@  @@ @@  @@   @@ ;
;  @@@@@  @@@ @@ @@@@ ;
;---------------------;
;tag
;Gui:
gui, 1:add, listview,y35 w100 r%_l% gok default,Subs
gui, 1:add, button,x13 y5 w95 h27 gBigNotes,Add BigNote`nat cursor line
gui, 1:show,x0 y0 w120 h%_y%,subscript
WinActivate,%_title%
Gosub getprog
onmessage(0x200,"mouseover")
;--------------------------------------------------------
;@@  @@             @    @@@                             ;
;@@  @@            @@     @@                             ;
;@@  @@   @@@@    @@@@@   @@  @@  @@@@   @@  @@   @@@@@  ;
;@@@@@@  @@  @@    @@     @@ @@  @@  @@  @@  @@  @@      ;
;@@  @@  @@  @@    @@     @@@@   @@@@@@  @@  @@   @@@@   ;
;@@  @@  @@  @@    @@ @   @@ @@  @@       @@@@@      @@  ;
;@@  @@   @@@@      @@   @@@  @@  @@@@       @@  @@@@@   ;
;-----------------------------------------@@@@-----------;
;tag
hotkeys:
!t::send {home};tag{enter}
!f12::gosub getprog
!esc::exitapp
!^b::Gosub BigNotes
return
;----------------------------------------
;  @@    @@@                        @    ;
; @@@@    @@                       @@    ;
;@@  @@   @@      @@@@   @@  @@   @@@@@  ;
;@@  @@   @@@@@  @@  @@  @@  @@    @@    ;
;@@@@@@   @@  @@ @@  @@  @@  @@    @@    ;
;@@  @@   @@  @@ @@  @@  @@  @@    @@ @  ;
;@@  @@  @@ @@@   @@@@    @@@ @@    @@   ;
;----------------------------------------;
;tag
about:
   msgbox, 64, %programfullname%,
   ( ltrim
      %programfullname%
      %a_space%by %programauthor%

      subscript jump to subs
      utility

      http://trubbleguy.com
     
      use [alt]+[esc] to terminate the program.
   )
return
;------------------------------------
; @@@@           @                   ;
;@@  @@         @@                   ;
;@@@     @@@@  @@@@@ @@  @@  @@ @@@  ;
; @@@   @@  @@  @@   @@  @@   @@  @@ ;
;   @@@ @@@@@@  @@   @@  @@   @@  @@ ;
;@@  @@ @@      @@ @ @@  @@   @@@@@  ;
; @@@@   @@@@    @@   @@@ @@  @@     ;
;----------------------------@@@-----;
;tag
;Setup:

setup:
msgbox setup routine here
return
;-----------------------------------------------------------------------------------
;  @@@@                            @@                     @@@          @@@          ;
; @@  @@                           @@                      @@         @@ @@         ;
;@@       @@@@   @@ @@@   @@@@@    @@       @@@@   @@@@    @@  @@    @@   @@ @@@@@  ;
;@@          @@   @@  @@ @@        @@      @@  @@ @@  @@   @@ @@     @@   @@ @@  @@ ;
;@@       @@@@@   @@  @@  @@@@     @@      @@  @@ @@       @@@@      @@   @@ @@  @@ ;
; @@  @@ @@  @@   @@@@@      @@    @@      @@  @@ @@  @@   @@ @@      @@ @@  @@  @@ ;
;  @@@@   @@@ @@  @@     @@@@@     @@@@@@   @@@@   @@@@   @@@  @@      @@@   @@  @@ ;
;----------------@@@----------------------------------------------------------------;
;tag
;Caps Lock On:
caps:
if getkeystate("capslock","t")
   soundbeep, 2200,20
return
;-------------------------------------------------------------------
;@@   @@                                @@@                         ;
;@@@ @@@                               @@ @@                        ;
;@@@@@@@  @@@@  @@  @@   @@@@@  @@@@  @@   @@ @@  @@  @@@@  @@ @@@  ;
;@@@@@@@ @@  @@ @@  @@  @@     @@  @@ @@   @@ @@  @@ @@  @@  @@@ @@ ;
;@@ @ @@ @@  @@ @@  @@   @@@@  @@@@@@ @@   @@ @@  @@ @@@@@@  @@  @@ ;
;@@   @@ @@  @@ @@  @@      @@ @@      @@ @@   @@@@  @@      @@     ;
;@@   @@  @@@@   @@@ @@ @@@@@   @@@@    @@@     @@    @@@@  @@@@    ;
;-------------------------------------------------------------------;
;tag
;MouseOver:
MOUSEOVER()
{
If A_Gui=1 ;check if mouse is on gui
   {
   SetTimer, Tooltipclear,Off
   MouseGetPos, X,Y,,, ;get the mouse co-ordinates
   X:=X+20 ;move it over a bit
   Y:=Y+5 ;move it down a bit
   _tword=%A_GuiControl% ;make A_GuiControl a modifyable variable
   StringReplace,_tword,_tword,%A_Space%,,all ;remove the spaces so it can find the tooltip
   StringReplace,_tword,_tword,-,,all ;remove -
   StringReplace,_tword,_tword,:,,all ;remove :
   StringReplace,_tword,_tword,\,,all ;remove \
   StringReplace,_tword,_tword,.,,all ;remove .
   StringReplace,_tword,_tword,`n,,all ;remove any line returns
   _tip:=TT_%A_Gui%_%_tword% ;get the tooltip to display
   Tooltip,%_tip%,%X%,%Y% ;display it
   }
   SetTimer, Tooltipclear,-100
Return
}   
;-----------------------------------------------------------------------
;@@@@@@            @     @                    @@@@          @@@         ;
; @@  @@          @@    @@                     @@          @@ @@        ;
; @@  @@ @@  @@  @@@@@ @@@@@  @@@@  @@@@@      @@  @@@@@   @@     @@@@  ;
; @@@@@  @@  @@   @@    @@   @@  @@ @@  @@     @@  @@  @@ @@@@   @@  @@ ;
; @@  @@ @@  @@   @@    @@   @@  @@ @@  @@     @@  @@  @@  @@    @@  @@ ;
; @@  @@ @@  @@   @@ @  @@ @ @@  @@ @@  @@     @@  @@  @@  @@    @@  @@ ;
;@@@@@@   @@@ @@   @@    @@   @@@@  @@  @@    @@@@ @@  @@ @@@@    @@@@  ;
;-----------------------------------------------------------------------;
;tag
;Button Info:

buttoninfo:
tt_1_AddBigNoteatcursorline=click here to 'INSERT' a Big Note`n  at the current cursors 'LINE'`nThis Automatically creates a tag also
tt_1_=Doubleclick any name here to 'JUMP'`nto that SubRoutine in your Program
return
;---------------------------------------------------------------
;@@@@@@                           @@   @@                       ;
;  @@                             @@@ @@@                       ;
;  @@   @@ @@@   @@@@   @@  @@    @@@@@@@  @@@@  @@@@@  @@  @@  ;
;  @@    @@@ @@     @@  @@  @@    @@@@@@@ @@  @@ @@  @@ @@  @@  ;
;  @@    @@  @@  @@@@@  @@  @@    @@ @ @@ @@@@@@ @@  @@ @@  @@  ;
;  @@    @@     @@  @@   @@@@@    @@   @@ @@     @@  @@ @@  @@  ;
;  @@   @@@@     @@@ @@     @@    @@   @@  @@@@  @@  @@  @@@ @@ ;
;------------------------@@@@-----------------------------------;
;tag
;Tray Menu:
traymenu:
   ; set tray tip
   menu, tray, tip, %programfullname%
   ; disable standard menu items
   menu, tray, nostandard
   ; show info message
   menu, tray, add, &about, about
   ; separator
   menu, tray, add
   ; show setup message
   menu, tray, add, &setup, setup
   ; separator
   menu, tray, add
   ; terminate script
   menu, tray, add, &quit, quit
return
;------------------------------------------------------
; @@@@@@          @@    @        @@                    ;
; @@                   @@       @@@@                   ;
; @@     @@   @@ @@@  @@@@@    @@  @@  @@ @@@  @@ @@@  ;
; @@@@    @@ @@   @@   @@      @@  @@   @@  @@  @@  @@ ;
; @@       @@@    @@   @@      @@@@@@   @@  @@  @@  @@ ;
; @@      @@ @@   @@   @@ @    @@  @@   @@@@@   @@@@@  ;
; @@@@@@ @@   @@ @@@@   @@     @@  @@   @@      @@     ;
;--------------------------------------@@@-----@@@-----;
;tag
;Exit App:
exit:
quit:
guiclose:
   ; restore clipboard contents -- debug: optional (see above)
   clipboard := clipboardbak
   ; terminate script
   exitapp
return
;-------------------------------------------
; @@@@          @@@                 @@@     ;
;@@  @@          @@                  @@     ;
;@@@    @@ @@@   @@   @@@@    @@@@@  @@ @@  ;
; @@@    @@  @@  @@      @@  @@      @@@ @@ ;
;   @@@  @@  @@  @@   @@@@@   @@@@   @@  @@ ;
;@@  @@  @@@@@   @@  @@  @@      @@  @@  @@ ;
; @@@@   @@     @@@@  @@@ @@ @@@@@  @@@  @@ ;
;-------@@@---------------------------------;
;tag
;Splash:
splash:
   ifwinexist,status
   {
   settitlematchmode 2   
   controlsettext,,%splash%,status
   winset,redraw,,status
   }   
   else
   {
   progress, x1 y15 zh0 zy1  b w%_swidth% c10 cwdefault ctff0000 fs14,%splash%,%a_index%,status
   winmove,status,%splash%,1,1
   }
   return
;----------------
;  @@@   @@@  @@ ;
; @@ @@   @@  @@ ;
;@@   @@  @@ @@  ;
;@@   @@  @@@@   ;
;@@   @@  @@ @@  ;
; @@ @@   @@  @@ ;
;  @@@   @@@  @@ ;
;----------------;
;tag
;DoubleClick:
;tag
;OK:
ok:
If A_GuiEvent=DoubleClick
{
lv_gettext(rowtext, a_eventinfo)  ; get the text from the row's first field.
if rowtext=@TOP
   {
   winactivate,%_title%
   send {ctrl down}{home}{ctrl up}
   return
   }   
if rowtext=~BOTTOM
   {
   winactivate,%_title%
   send {ctrl down}{end}{ctrl up}
   return
   }   
winactivate,%_title%
send {ctrl down}{home}{ctrl up}
sleep 100
send {ctrl down}f{ctrl up}%rowtext%{enter}
sleep 100
send {home}{ESC}
}
Listvars
return
;-----------------------------------------------------
;  @@@@           @        @                          ;
; @@  @@         @@       @@                          ;
;@@       @@@@  @@@@@    @@@@@  @@@@    @@@ @@  @@@@@ ;
;@@      @@  @@  @@       @@       @@  @@  @@  @@     ;
;@@  @@@ @@@@@@  @@       @@    @@@@@  @@  @@   @@@@  ;
; @@  @@ @@      @@ @     @@ @ @@  @@   @@@@@      @@ ;
;  @@@@@  @@@@    @@       @@   @@@ @@     @@  @@@@@  ;
;---------------------------------------@@@@----------;
;tag
;Get tags:
getprog:
WinActivate,.ahk
wingetactivetitle,_title
winset,Transparent,255,status
If _title not contains.ahk
Return
Clipboard=
MsgBox,0,should be, % _title,1
WinActivate, %_title%
sleep 600
WinActivate,%_title%
splash=finding all subs to display
gosub splash
Send {ctrl down}{home}{ctrl up}
send {ctrl down}a{ctrl up}
sleep 600
send {ctrl down}c{ctrl up}
sleep 200
t=0
sleep 200
LV_Delete()
lv_add(" ","@TOP")
lv_add(" ","~BOTTOM")
loop, parse, clipboard, `n, `r
{
   if t=1
   {
   stringupper,namee,a_loopfield
   StringReplace,namee,namee,`;,,
   lv_add(" ",namee)
   t=0
   continue
   }      
   stringleft,hunt,a_loopfield,4
   if hunt contains;tag
      {
      t=1
      continue
      }   
}
lv_modifycol(1,"sort")
WinActivate, %_title%
send {home}
splash=double click any sub in the list to jump to it immediately
gosub splash
sleep 5000
splash=
gosub splash
;winmove,status,%splash%,1,1
winset, transcolor, default, status
winset,Transparent,0,status
return
;-----------------------------------------------------------
;@@@@@@   @@             @@   @@          @                 ;
; @@  @@                 @@@  @@         @@                 ;
; @@  @@ @@@   @@@ @@    @@@@ @@  @@@@  @@@@@  @@@@   @@@@@ ;
; @@@@@   @@  @@  @@     @@ @@@@ @@  @@  @@   @@  @@ @@     ;
; @@  @@  @@  @@  @@     @@  @@@ @@  @@  @@   @@@@@@  @@@@  ;
; @@  @@  @@   @@@@@     @@   @@ @@  @@  @@ @ @@         @@ ;
;@@@@@@  @@@@     @@     @@   @@  @@@@    @@   @@@@  @@@@@  ;
;--------------@@@@-----------------------------------------;
;tag
;Big Notes:
BigNotes:
SetBatchlines,-1
border=
loop 8
aline%A_Index%=
;--------------------------------------------------------------------
;@@   @@   @@    @@@@@@  @@   @@ @@@@ @@   @@   @@@@   @@   @@   @@  ;
;@@   @@  @@@@    @@  @@ @@@  @@  @@  @@@  @@  @@  @@ @@@@ @@@@ @@@@ ;
;@@   @@ @@  @@   @@  @@ @@@@ @@  @@  @@@@ @@ @@      @@@@ @@@@ @@@@ ;
;@@ @ @@ @@  @@   @@@@@  @@ @@@@  @@  @@ @@@@ @@      @@@@ @@@@ @@@@ ;
;@@@@@@@ @@@@@@   @@ @@  @@  @@@  @@  @@  @@@ @@  @@@  @@   @@   @@  ;
;@@@ @@@ @@  @@   @@  @@ @@   @@  @@  @@   @@  @@  @@                ;
;@@   @@ @@  @@  @@@  @@ @@   @@ @@@@ @@   @@   @@@@@  @@   @@   @@  ;
;--------------------------------------------------------------------;
;tag
;Warning!!:
;in the Vars AA1 thru AA8, the spaces are "NO-Break" and not normal spaces, use ALT+0160 to create one
;Vars; char width is WW1,the letter is above its width
;;;; !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
WW1=24476773447736277666766666445666777777776477777777766667767575776777766774674766777657677666267
AA1=         @@     @  @     @@ @@    @@    @@@  @@   @@@    @@       @@    @@                                                   @@  @@@@@    @@     @@@@    @@@@      @@@  @@@@@@    @@@   @@@@@@   @@@@    @@@@                      @@            @@      @@@@    @@@@@    @@    @@@@@@    @@@@  @@@@@    @@@@@@  @@@@@@   @@@@  @@  @@  @@@@       @@@@ @@@  @@ @@      @@   @@ @@   @@   @@@   @@@@@@   @@@@   @@@@@@   @@@@   @@@@@@  @@  @@  @@  @@  @@   @@ @@   @@ @@  @@  @@@@@@@  @@@@   @@       @@@@      @              @@            @@@                @@@            @@@           @@@      @@         @@  @@@     @@@                                                               @                                                        @@@  @@      @@@      @@@ @@        
AA2=        @@@@    @  @     @@ @@   @@@@@  @@@ @@@  @@ @@   @@      @@      @@      @@  @@    @@                               @@  @@   @@  @@@    @@  @@  @@  @@    @@@@  @@       @@     @@  @@  @@  @@  @@  @@    @@      @@      @@              @@    @@  @@  @@   @@  @@@@    @@  @@  @@  @@  @@ @@   @@      @@      @@  @@ @@  @@   @@         @@   @@  @@ @@      @@@ @@@ @@@  @@  @@ @@   @@  @@ @@  @@   @@  @@ @@  @@    @@    @@  @@  @@  @@  @@   @@ @@   @@ @@  @@       @@  @@      @@        @@     @@@             @@             @@                 @@           @@ @@           @@                      @@      @@                                                              @@                                                       @@    @@        @@    @@ @@@         
AA3=        @@@@            @@@@@@@ @@         @@@    @@@   @@      @@        @@      @@@@     @@                              @@   @@  @@@   @@        @@      @@   @@ @@  @@@@@   @@          @@  @@  @@  @@  @@    @@      @@     @@     @@@@@@     @@       @@  @@ @@@@ @@  @@   @@  @@ @@       @@  @@  @@      @@     @@      @@  @@   @@         @@   @@ @@  @@      @@@@@@@ @@@@ @@ @@   @@  @@  @@ @@  @@   @@  @@ @@@       @@    @@  @@  @@  @@  @@   @@  @@ @@  @@  @@      @@   @@       @@       @@    @@ @@             @@    @@@@    @@      @@@@       @@   @@@@    @@      @@@ @@  @@ @@  @@@         @@   @@  @@  @@     @@  @@  @@@@@    @@@@   @@ @@@   @@@ @@ @@ @@@   @@@@@  @@@@@   @@  @@  @@  @@  @@   @@ @@   @@ @@  @@  @@@@@@    @@    @@        @@                   
AA4=        @@@@             @@ @@   @@@@     @@@    @@@ @@         @@        @@    @@@@@@@ @@@@@@@@        @@@@@@            @@    @@ @@@@   @@      @@@     @@@   @@  @@      @@  @@@@@      @@    @@@@    @@@@@                  @@                  @@     @@   @@ @@@@ @@  @@   @@@@@  @@       @@  @@  @@@@    @@@@   @@      @@@@@@   @@         @@   @@@@   @@      @@@@@@@ @@ @@@@ @@   @@  @@@@@  @@  @@   @@@@@   @@@      @@    @@  @@  @@  @@  @@ @ @@   @@@    @@@@      @@    @@        @@      @@   @@   @@                     @@   @@@@@  @@  @@   @@@@@  @@  @@  @@@@    @@  @@   @@@ @@  @@         @@   @@ @@   @@     @@@ @@@ @@  @@  @@  @@   @@  @@ @@  @@   @@@ @@ @@       @@     @@  @@  @@  @@  @@ @ @@  @@ @@  @@  @@  @  @@   @@@     @@         @@@                 
AA5=         @@             @@@@@@@     @@   @@@    @@ @@@          @@        @@      @@@@     @@                            @@     @@@@ @@   @@     @@         @@  @@@@@@@     @@  @@  @@    @@    @@  @@      @@                   @@                @@     @@    @@ @@@@ @@@@@@   @@  @@ @@       @@  @@  @@      @@     @@  @@@ @@  @@   @@     @@  @@   @@ @@  @@      @@ @ @@ @@  @@@ @@   @@  @@     @@ @@@   @@ @@     @@@    @@    @@  @@  @@  @@  @@@@@@@   @@@     @@      @@     @@         @@     @@                            @@@@@   @@  @@ @@      @@  @@  @@@@@@   @@     @@  @@   @@  @@  @@         @@   @@@@    @@     @@@@@@@ @@  @@  @@  @@   @@  @@ @@  @@   @@  @@  @@@@    @@     @@  @@  @@  @@  @@@@@@@   @@@   @@  @@    @@      @@    @@        @@                   
AA6=                         @@ @@  @@@@@   @@@ @@@ @@  @@           @@      @@      @@  @@    @@    @@             @@      @@      @@@  @@   @@    @@  @@  @@  @@      @@  @@  @@  @@  @@    @@    @@  @@     @@     @@      @@      @@    @@@@@@    @@            @@      @@  @@   @@  @@  @@  @@  @@ @@   @@      @@      @@  @@ @@  @@   @@     @@  @@   @@  @@ @@      @@   @@ @@   @@  @@ @@   @@      @@@@    @@  @@ @@  @@    @@    @@  @@   @@@@   @@@ @@@  @@ @@    @@     @@      @@          @@    @@                           @@  @@   @@  @@ @@  @@  @@  @@  @@       @@      @@@@@   @@  @@  @@     @@  @@   @@ @@   @@     @@ @ @@ @@  @@  @@  @@   @@@@@   @@@@@   @@         @@   @@ @   @@  @@   @@@@   @@@ @@@  @@ @@   @@@@@   @@  @    @@    @@        @@                   
AA7=         @@              @@ @@    @@    @@  @@@  @@@ @@           @@    @@                      @@              @@      @        @@@@@  @@@@@@  @@@@@@   @@@@      @@@@  @@@@    @@@@     @@     @@@@    @@@      @@     @@        @@            @@       @@     @@@@   @@  @@  @@@@@@    @@@@  @@@@@    @@@@@@  @@       @@@@@ @@  @@  @@@@     @@@@   @@@  @@ @@@@@@  @@   @@ @@   @@   @@@   @@@@       @@@  @@@  @@  @@@@     @@    @@@@@@    @@    @@   @@ @@   @@  @@@@   @@@@@@@  @@@@         @  @@@@                            @@@ @@ @@ @@@   @@@@    @@@ @@  @@@@   @@@@        @@  @@@  @@ @@@@    @@  @@  @@@  @@ @@@@    @@   @@ @@  @@   @@@@    @@         @@  @@@@    @@@@@     @@     @@@ @@   @@    @@   @@ @@   @@     @@  @@@@@@     @@@  @@      @@@                    
AA8=------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------@@@@@@@----------------------------------------------------------@@@@--------------------@@@@-------------------------------------------@@@---------@@@----------------------------------------------------------@@@@-------------------------------------------
:   1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567 1234567
;   |32   |33 ! |34 " |35 # |36 $ |37 % |38 & |39 ' |40 ( |41 ) |42 * |43 + |44 , |45 - |46  |47 / |48 0 |49 1 |50 2 |51 3 |52 4 |53 5 |54 6 |55 7 |56 8 |57 9 |58 : |59 ; |60 < |61 = |62 > |63 ? |64 @ |65 A |66 B |67 C |68 D |69 E |70 F |71 G |72 H |73 I |74 J |75 K |76 L |77 M |78 N |79 O |80 P |81 Q |82 R |83 S |84 T |85 U |86 V |87 W |88 X |89 Y |90 Z |91 [ |92 \ |93 ] |94 ^ |95 _ |96 ` |97 a |98 b |99 c |100 d|101 e|102 f|103 g|104 h|105 i|106 j|107 k|108 l|109 m|110 n|111 o|112 p|113 q|114 r|115 s|116 t|117 u|118 v|119 w|120 x|121 y|122 z|123 {|124 ||125 }|126 ~/

InputBox,_WORD,Huge txt maker, type the work,20,200,center
If ErrorLevel
Return
StringSplit,_letter,_WORD,,
Loop %_letter0%
{
  lt:=_letter%A_Index%
   Num := (Asc(lt)-32)*8+1
   wd :=(Asc(lt)-32)+1
   if lt=%A_Space%
      Num :=0

  Loop 8
  {
   StringMid,dw,WW1,%wd%,1
   dw++
      if lt=%A_Space%
   StringMid,line,AA%A_Index%,%Num%,%dw%
   if lt<>%A_Space%
   StringMid,line,AA%A_Index%,%Num%,%dw%
   line%A_Index%=%line%
  }
IF dw = 8
  _B=--------
IF dw = 7
  _B=-------
IF dw = 6
  _B=------
IF dw = 5
  _B=-----
IF dw = 4
  _B=----
IF dw = 3
  _B=---
IF dw = 2
  _B=--
IF dw = 1
  _B=-
  border .=_B
  aline1 .= line1
  aline2 .= line2
  aline3 .= line3
  aline4 .= line4
  aline5 .= line5
  aline6 .= line6
  aline7 .= line7
  aline8 .= line8
}
;tag
;send Bignote:
Winactivate, %_title%
Send,{HOME}{HOME};%border%{ENTER}
Send,{HOME}{HOME}`;%aline1%`;{ENTER}
Send,{HOME}{HOME}`;%aline2%`;{ENTER}
Send,{HOME}{HOME}`;%aline3%`;{ENTER}
Send,{HOME}{HOME}`;%aline4%`;{ENTER}
Send,{HOME}{HOME}`;%aline5%`;{ENTER}
Send,{HOME}{HOME}`;%aline6%`;{ENTER}
Send,{HOME}{HOME}`;%aline7%`;{ENTER}
Send,{HOME}{HOME}`;%aline8%`;{ENTER}
Send,{HOME}{HOME}`;tag{ENTER}
Send,{HOME}{HOME}`;%_WORD%:{ENTER}
sleep 2500
SetBatchlines,%normal%
StringUpper,_WORD,_WORD
_WORD=%_WORD%`:
lv_add(" ",_WORD)
Return
;-------------------------------------------------------------------------------------
;@@@@@@               @@@  @@@@@@  @@               @@@@  @@@                         ;
;  @@                  @@    @@                    @@  @@  @@                         ;
;  @@    @@@@   @@@@   @@    @@   @@@  @@ @@@     @@       @@   @@@@   @@@@   @@ @@@  ;
;  @@   @@  @@ @@  @@  @@    @@    @@   @@  @@    @@       @@  @@  @@     @@   @@@ @@ ;
;  @@   @@  @@ @@  @@  @@    @@    @@   @@  @@    @@       @@  @@@@@@  @@@@@   @@  @@ ;
;  @@   @@  @@ @@  @@  @@    @@    @@   @@@@@      @@  @@  @@  @@     @@  @@   @@     ;
;  @@    @@@@   @@@@  @@@@   @@   @@@@  @@          @@@@  @@@@  @@@@   @@@ @@ @@@@    ;
;--------------------------------------@@@--------------------------------------------;
;tag
;ToolTip Clear:

TooltipClear:
If A_Gui ;check if mouse is not on Subscript gui
   Return
tooltip
SetTimer, Tooltipclear,-100
return
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Timothy
Guest





PostPosted: Sat Sep 01, 2007 8:20 pm    Post subject: Reply with quote

I have tried it in Notepad but it comes all wrong.
Code:
;--------------------------------------------------------
;@@@@  @@@@@@@@   @@@@@;
;@@  @@@@@@ @@@@ @@@@;
;@@@@@ @@@@   @@@@ @@@@@  @@@@@@@@@;
;@@@@@@ @@@@   @@@@  @@@@  @@@@@@@@;
;@@@@@  @@@   @@@@  @@@  @@@@@@;
;@@@@@  @@@@@@@@@@ @@@@@  @@@@@@;
;@@@@  @@  @@@@  @@ @@@@   @@@@@@ @@@@@@@;
;--------------@@@@--------------------------------------;
;tag
;BigNotes:
I am using Windows XP SP2 and AutoHotkey version 1.0.47.04. What's wrong?
Back to top
Trubbleguy



Joined: 20 Jan 2007
Posts: 73
Location: Melbourne

PostPosted: Sun Sep 02, 2007 2:28 am    Post subject: Reply with quote

your font in notepad is proportional set notepad font to Lucida Console or similar which is evenly spaced.
I code using Lucida console 10

OR the insert key is on, make sure insert is never on or it overwrites,

Sorry but Insert is the only key thats just about impossible to get the state of. if Shift Insert is used it also toggles Insert but Not the actual Toggle, but AHK thinks it has changed and its wrong
Code:

;-------------------------------
;   @@@                         ;
;    @@                         ;
;    @@   @@@@   @@  @@  @@@@@  ;
; @@@@@      @@  @@@ @@@ @@  @@ ;
;@@  @@   @@@@@  @@@@@@@ @@  @@ ;
;@@  @@  @@  @@  @@ @ @@ @@  @@ ;
; @@@ @@  @@@ @@ @@   @@ @@  @@ ;
;-------------------------------;
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
engunneer



Joined: 30 Aug 2005
Posts: 6772
Location: Pacific Northwest, US

PostPosted: Tue Sep 04, 2007 6:50 pm    Post subject: Reply with quote

I had trouble with Troubleguy's script and Autotrim. Try adding AutoTrim, Off near the top.
_________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM
Back to top
View user's profile Send private message Visit poster's website
william.kelly.jr@gmail.co
Guest





PostPosted: Sat Oct 13, 2007 2:40 am    Post subject: simple just copy anad create new ahk script Reply with quote

Create script save. then run the script
Hightlight some text then hit CTR 0 "zero" and paste it wherever you would like. btw this is just a modified version of the script above for to use

Code:


;      *****************************
;      **                         **
;      **                         **
;      **       COMMMENT BOX      **
;      **    SECTION OF SCRIPT    **
;      **                         **
;      **                         **
;      *****************************


;*********************
;*                   *
;*    Comment Box    *
;*                   *
;*********************
CommentBox(p_LeftBox,p_RightBox,p_Border,p_TitleWidthPad=2,p_TitleHeightPad=0
    ,p_MinBoxWidth=0,p_Justify="")
    {
;
; Parameters
; ==========
; p_LeftBox        - Left Box character(s). Required parameter
; p_RightBox       - Right Box character(s). Required parameter
; p_Border         - Top/Bottom border character (1st character (for now)).  Required parameter
; p_TitleWidthPad  - Number of space characters to pad title. Default=2
; p_TitleHeightPad - Number of empty lines before and after title(s). Default=0
; p_MinBoxWidth    - Minimum width of the comment box.  Default=0
; p_Justify        -
;
;   "L" to justify left
;   "C" to center (default)
;   "R" to justify right.  Don't know why you would use this but wth
;   "N" for no justification.  All intelligent processing (AutoTrim) turned off
;
; Example:
;
;    AAAACCCCCCCCCCCCCCCCCCCBB    A=Left Box, B=Right Box, C=Border
;    AAAA                   BB
;    AAAA                   BB
;    AAAADDDDDThe TitleDDDDDBB    D=%p_TitleWidthPad% space characters before and after title
;    AAAA      Title 2      BB
;    AAAA                   BB    This line is created if p_TitleHeightPad >= 1
;    AAAA                   BB    This line is created if p_TitleHeightPad >= 2, etc., etc.
;    AAAACCCCCCCCCCCCCCCCCCCBB   
;
;
; Notes
; =====
;
; Clipboard
; ---------
; This function uses the clipboard as the source of the comment
; title(s) but the clipboard is not modified by this function.
; The resulting comment box is returned as string.
;
; AutoTrim
; --------
; By default, this function automatically removes all leading and
; trailing spaces and tabs from a title before determining where the
; title fits in the box.  For example, if the titles contains the
; following lines (sans quotes):
;
;     "Title1    "
;     "Title2      "
;
; The function will return a box that will look something like this
; (sans quotes):
;
;     "************"
;     "*  Title1  *"
;     "*  Title2  *"
;     "************"
;
; To turn off this "feature", set p_Justify to "N" (no justification).
; All leading and trailing spaces and tabs will be considered part of
; the title.
;
;
; AutoPad
; -------
; By default, the function analyzes the 1st title line to determine
; where the left side of the box will begin on each line.  If the 1st
; line has leading spaces and/or tabs, each line of the box will lead
; with the same.  For example, if the titles contains the following
; lines (sans quotes):
;
;     "    Title1"
;     "        Title2   "
;
; The function will return a box that will look something like this
; (sans quotes):
;
;     "    ************"
;     "    *  Title1  *"
;     "    *  Title2  *"
;     "    ************"
;
; This "feature" can be bypassed by removing all leading spaces/tabs
; from the 1st line or by including a blank line as the 1st line
; (delete the extra line after the box is built).  This feature can
; also be bypassed by setting p_Justify to "N" but the results may
; not be as expected.
;
;
; Misc
; ----
; This function does not format text.  If you want to enclose a lot of
; text in a comment box, be sure to format it before doing so.
;
;
; Example of use
; --------------
; The following is an example of how this function can be used within
; a Hotkey:
;     
;      ;========== start of example ==========
;      $Clipboard:=ClipboardAll  ;-- Save current clipboard

;      ;-- Copy selected
;      clipboard=
;      send ^c
;      ClipWait 0.1
;      if errorlevel=0
;          {
;          clipboard:=CommentBox(";*","*","*",4,2,0,"Center")
;          Send ^v  ;-- Paste clipboard
;          }

;      clipboard:=$Clipboard  ;-- Restore original clipboard
;      ;========== end of example ==========
;
;
; To execute (using this example), select the desired text, press the
; associated hotkey, and the selected text will be replaced with a
; comment box.  Most editors will allow you to reverse the action by
; entering Ctrl+Z.
;
;---------------------------------------------------------------------

    ;--------------
    ;-- Initialize
    ;--------------
    AutoTrim off
    t_CRLF=`r`n
    t_Clipboard:=clipboard  ;-- Working copy of clipboard
    t_CommentBox=

    ;------------------------
    ;-- Transform parameters 
    ;------------------------
    StringLeft p_Border,p_Border,1
    t_LeftBoxLen:=strlen(p_LeftBox)
    t_RightBoxLen:=strlen(p_RightBox)

    if p_TitleWidthPad is not integer
        p_TitleWidthPad=2
    if p_TitleHeightPad is not integer
        p_TitleHeightPad=0
    if p_MinBoxWidth is not integer
        p_MinBoxWidth=0

    ;-- p_Justify
    StringLeft p_Justify,p_Justify,1
    if p_Justify not in l,c,n,r
        p_Justify=C


    ;------------------------
    ;-- Identify environment
    ;------------------------

    ;-- If it exists, delete trailing CRLF from t_clipboard
    t_TrailingCRLF=N
    StringRight t_RString,t_clipboard,2
    if t_RString=%t_CRLF%
        {
        StringTrimRight t_clipboard,t_clipboard,2
        t_TrailingCRLF=Y
        }
       
    ;-- Identify leading spaces/tabs of 1st line
    t_BoxPad=
    if p_justify<>N
        loop parse,t_clipboard,`n,`r
            {
            t_Title:=A_LoopField  ;-- Assign but don't AutoTrim
            loop parse,t_Title
                {
                if A_LoopField=%A_Space%
                    t_BoxPad=%t_BoxPad%%A_Space%
                 else
                    if A_LoopField=%A_Tab%
                        t_BoxPad=%t_BoxPad%%A_Tab%
                     else
                        break
                }
            break
            }

    ;-- Identify maximum title length
    AutoTrim on
    if p_Justify=N
        AutoTrim off
    t_MaxTitleLen=0
    loop parse,t_clipboard,`n,`r
        {
        t_cbLine=%A_LoopField%  ;-- Assign and AutoTrim
        if strlen(t_cbLine)>t_MaxTitleLen
            t_MaxTitleLen:=strlen(t_cbLine)
        }

    ;-- Adjust for minimum?
    t_BoxWidth:=t_LeftBoxLen + t_RightBoxLen + t_MaxTitleLen + (p_TitleWidthPad * 2)
    if p_MinBoxWidth>%t_BoxWidth%
        t_MaxTitleLen:=p_MinBoxWidth - (t_LeftBoxLen + t_RightBoxLen + (p_TitleWidthPad * 2))

    ;---------------------------
    ;-- Build preliminary stuff
    ;---------------------------
    AutoTrim off

    ;-- Title pad
    t_TitlePad=
    loop %p_TitleWidthPad%
        t_TitlePad=%t_TitlePad%%A_Space%

    ;-- Border and Title Fill
    t_FillLen:=t_MaxTitleLen + (p_TitleWidthPad * 2)
    t_BorderFill=
    t_TitleFill=
    loop %t_FillLen%
        {
        t_BorderFill=%t_BorderFill%%p_Border%
        t_TitleFill=%t_TitleFill%%A_Space%
        }
    t_BorderLine=%p_LeftBox%%t_BorderFill%%p_RightBox%
    t_TitleFillLine=%p_LeftBox%%t_TitleFill%%p_RightBox%


    ;---------------------
    ;-- Build Comment Box
    ;---------------------
    AutoTrim off

    ;-- Top border
    t_CommentBox=%t_CommentBox%%t_BoxPad%%t_BorderLine%%t_CRLF%

    ;-- Before title empty line(s)
    loop %p_TitleHeightPad%
        t_CommentBox=%t_CommentBox%%t_BoxPad%%t_TitleFillLine%%t_CRLF%

    ;-- Title lines
    loop parse,t_clipboard,`n,`r
        {
        AutoTrim on
        if p_Justify=N
            AutoTrim off
        t_Title=%A_LoopField%  ;-- Assign and AutoTrim
        AutoTrim off

        ;-- Justify Title
        loop
            {
            if strlen(t_Title)=t_MaxTitleLen
                break

            ;-- Pad left
            if p_Justify in c,r
                {
                t_Title=%A_Space%%t_Title%
                if strlen(t_Title)=t_MaxTitleLen
                    break
                }

            ;-- Pad right
            if p_Justify in c,n,l
                t_Title=%t_Title%%A_Space%
            }

        t_TitleLine=%p_LeftBox%%t_TitlePad%%t_Title%%t_TitlePad%%p_RightBox%
        t_CommentBox=%t_CommentBox%%t_BoxPad%%t_TitleLine%%t_CRLF%
        }


    ;-- After title empty line(s)
    loop %p_TitleHeightPad%
        t_CommentBox=%t_CommentBox%%t_BoxPad%%t_TitleFillLine%%t_CRLF%

    ;-- Bottom border
    t_CommentBox=%t_CommentBox%%t_BoxPad%%t_BorderLine%%t_CRLF%

    ;-- If appropriate, delete final CRLF
    if t_TrailingCRLF=N
        StringTrimRight t_CommentBox,t_CommentBox,2

    ;-- Housekeeping
    AutoTrim on
   
    ;-- Return to sender
    return t_CommentBox
    }

   
   
;      **********************************************************************************************
;      **                                                                                          **
;      **                                                                                          **
;      **    Control + 0 "ZERO" will copy the selected Text and build the comment box. Paste it    **
;      **                                   with the Control + V                                   **
;      **                                                                                          **
;      **                                                                                          **
;      **********************************************************************************************

$^0::
   
     $Clipboard:=ClipboardAll  ;-- Save current clipboard
 
     ;-- Copy selected
     clipboard=
     send ^c
     ClipWait 0.1
     if errorlevel=0
         {
         clipboard:=CommentBox(";      **","**","*",4,2,0,"Center")
         }
 
     pclipboard:=$Clipboard  ;-- Restore original clipboard
     ;========== end of example ==========
return



;      *************************************
;      **                                 **
;      **                                 **
;      **    END OF COMMENT BOX SCRIPT    **
;      **                                 **
;      **                                 **
;      *************************************
Back to top
RaptoR



Joined: 27 Jun 2007
Posts: 22
Location: Earth, Cambrian period

PostPosted: Mon Jan 21, 2008 1:46 pm    Post subject: Re: For the coders - Automatic comment box Reply with quote

jballi wrote:
I did a cursory search of this forum for utility or function to automatically build a comment box (not exactly sure what to search for) but I didn't find anything.
...
I hope someone finds this useful.


JBalli, that's awesome!

PLT Scheme also has similar feature, but it is "semicolon oriented" only:
Code:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;                                         ;              ;
;   ;;;;   ;;;  ;;;   ;;;;   ;; ;;;   ;;;;;;;    ;;;;;   ;
;  ;    ;   ;    ;   ;    ;   ;;   ;    ;       ;    ;   ;
;  ;;;;;;    ;  ;    ;;;;;;   ;    ;    ;        ;;;;    ;
;  ;         ;  ;    ;        ;    ;    ;            ;   ;
;  ;    ;     ;;     ;    ;   ;    ;    ;    ;  ;    ;   ;
;   ;;;;      ;;      ;;;;   ;;;  ;;;    ;;;;   ;;;;;    ;
;                                                        ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; clear everything
^!r::Reload
...


Good luck!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group