SendText - hotstring, text snippet manager

Post your working scripts, libraries and tools.
User avatar
aeiklmr
Posts: 17
Joined: 09 Dec 2018, 22:28
Location: Europe
Contact:

SendText - hotstring, text snippet manager

Post by aeiklmr » 29 Mar 2023, 15:11

Hi everyone,

SendText simplifies the management of your hotstrings and text snippets.

The script includes 155 built-in symbols and special characters and allows for the quick and easy addition of new texts and hotstrings.

Image

Features:

▪ send texts via win32 menus or using hotstrings
▪ manages categories, menu items, and hotstrings from one file
▪ can be integrated easily into your own existing config, menu
▪ emoji support: :]
▪ old school ascii texts: ଘ(੭ˊᵕˋ)੭ ̀ˋ ɪɴᴛᴇʀɴᴇᴛ!
▪ long text support
▪ warn compatible

More info, examples, download:

https://github.com/bceenaeiklmr/SendText

Here are a few examples of each category:

[Roman Numerals] I, II, III, IV, ...
[AutoHotkey] keystrokes with Send()
[Brackets] 〔...〕, ⌜⌝, ...
[ASCII texts] ଘ(੭ˊᵕˋ)੭ ̀ˋ ɪɴᴛᴇʀɴᴇᴛ!, (҂^.^)ᕤ, ...
[ASCII symbols] ⏵, ⟫, ⊙, €, ∑, ...
[Emoji symbols] ...
[Emoji faces] ...
[Emoji hands] ...

How to use it:

1. Download both SendText.ahk and hotstring.ini into the same folder.

2. Run SendText.ahk

3. Hold Mbutton down for at least 500 ms or press simultaneously Win + c to show the menu.

4. Select an element and the text will be pasted into the last active window.

⏵ Alternatively, you can call the snippets via hotstrings.

By default, all hotstrings start with the semicolon : character. You can alter this value.

The ini file:

Code: Select all

; displayed preview text | menu item | hotstring | ahk code
; e.g listen | ☝ | listen, important | (ahk send code)

[Roman Numerals]

1                        | roman1                       | Ⅰ
2                        | roman2                       | Ⅱ
3                        | roman3                       | Ⅲ
4                        | roman4                       | Ⅳ
5                        | roman5                       | Ⅴ
6                        | roman6                       | Ⅵ
7                        | roman7                       | Ⅶ
8                        | roman8                       | Ⅷ
9                        | roman9                       | Ⅸ
10                       | roman10                      | Ⅹ
11                       | roman11                      | Ⅺ
12                       | roman12                      | Ⅻ
50                       | roman50                      | Ⅼ
100                      | roman100                     | Ⅽ
500                      | roman500                     | Ⅾ
1000                     | roman1000                    | Ⅿ

[AutoHotkey]

comment block            | //                           | /* .... */ | */*{Enter}*/{Up}{Enter}{Tab}
#########  ..  ######### | ##, _1                       | ########   | *; {# 20} Comment {# 20}
######### [..] ######### | _2                           | ## [..] ## | *; {# 20} [ Comment ] {# 20}
_________ [..] _________ | __                           | __ [..] __ | *; {_ 20} [ Comment ] {_ 20}
######### cent ######### | center                       | # cent #   | *{Home};{Space}{# 20}{Space}{End}{# 20}{CtrlDown}{ShiftDown}{Left}{CtrlUp}{ShiftUp}{Left 2}
line feed LF             | newline, LF, linefeed        | `n
carriage return CR       | CR, carriage                 | `r
CRLF                     | CRLF                         | `r`n
tabulator                | tabulator, tab, column       | `t
less than                | less, less than              | <
greater than             | more, greater                | >
logical AND              | AND                          | &&
logical OR               | OR                           | ||
standard loop            | loop                         | loop ()    | *loop {{}{Enter}{Up}{End}{Left 2}{Space}
for loop                 | for                          | for ()     | *for k, v in obj {{}{Enter}{Left 2}{Tab}{Up}{End}{Left 2}{ShiftDown}{Left 3}{ShiftUp}
while loop               | while                        | while ()   | *while (condition){{}{Enter}{Left 2}{Tab}{Up}{End}{Left 3}{CtrlDown}{ShiftDown}{Left}{CtrlUp}{ShiftUp}
until loop               | until                        | until ()   | *loop {{}{Enter}{Down}{Space}until (condition){Space}{Left 2}{CtrlDown}{ShiftDown}{Left}{CtrlUp}{ShiftUp}
ternary operator         | tern                         | !x ? y:z   | *(x = y) ? 1 : 0{Home}{Right}{ShiftDown}{Right 5}{ShiftUp}
if condition             | if                           | if ()      | *if (condition) {{}{Enter}{Down}{End}{Space}else{Space}{{}{Enter 2}{}}{Up 4}{Home}{Right 4}{CtrlDown}{ShiftDown}{Right}{CtrlUp}{ShiftUp}
else if condition        | elseif                       | else if () | *if (condition) {{}{Enter}{Down}{End}{Space}else if (c2){Space}{{}{Enter 2}{}}{Up 4}{End}{Left 3}{CtrlDown}{ShiftDown}{Left}{CtrlUp}{ShiftUp}

[Brackets]

parentheses              | parent                       | ( )
brackets square          | squarebracket                | [ ]
bracket curly            | curlybracket                 | { }
super script parentheses | ^, superscr                  | X⁽²⁾
sub script parentheses   | !^, subscr                   | X₍₂₎
tortoise shell bracket   | tortoise, shell              | 〔...〕
boxed text               | boxed                        | ⎸...⎹
bracket angle            | anglebracket                 | ⟨ ⟩
bracket ceiling          | ceilingbracket               | ⌈ ⌉
bracket floor            | floorbracket                 | ⌊ ⌋
quasi-quotation          | quine, topbracket, quasi     | ⌜⌝
editorial notation       | botbracket, editorial        | ⌞⌟
curly bracket extension  | curlyextension, extension    | ⎪

[ASCII texts]

coffee                   | coffee                       | c[_]
bored                    | bored                        | (-_-)
bearhug                  | bearhug                      | ʕっ•ᴥ•ʔっ
creep                    | creep                        | ƪ(ړײ)ƪ
endure                   | endure                       | (҂^.^)ᕤ
fancyme                  | fancyme                      | вєωαяє, ι αм ƒαη¢у!
fancyyou                 | fancyyou                     | вєωαяє, you αяє ƒαη¢у!
flower                   | flower                       | (✿◠‿◠)
greetings                | greetings                    | O╯[Greetings{!}]
internet                 | internet                     | ଘ(੭*ˊᵕˋ)੭* ̀ˋ ɪɴᴛᴇʀɴᴇᴛ{!}
bearlove                 | bearlove                     | ʕ♥ᴥ♥ʔ
meh                      | meh                          | ಠ_ಠ
rolleyes                 | rolleyes                     | _<oO>_
wut                      | wut                          | OωO
uwu                      | uwu                          | UωU
hmm                      | hmm                          | ¯\_(ツ)_/¯

[ASCII symbols]

EUR                      | EUR                          | €
summa                    | sum, total                   | ∑
delta                    | delta, diff                  | Δ
approximately            | cirka, appr                  | ∼
tiny square              | square, tinysq               | ▪
normal square            | normalsq, normalsquare       | ■
big square               | bigsq, fatsq                 | ⏹
dotted rectangle         | dottedre, dotrect            | ⊡
dotted ring              | dottedri, dotring            | ⊙
single left arrow        | arrow1L                      | ‹
single right arrow       | arrow1R                      | ›
double left arrow        | leftarrow, arrowleft         | ‹‹
double right arrow       | rightarrow, arrowright       | ››
left arrows              | leftarrow, arrowleft         | ⟪
right arrows             | rightarrow, arrowright       | ⟫
fat arrow left           | fatarrowL                    | ⇐
fat arrow right          | fatarrowT                    | ⇒
fat arrow top            | fatarrowtop, arrowtop        | ⇑
fat arrow bot            | fatarrowbot, arrowbot        | ⇓
fat arrows horizontal    | arrowH, fatarrowH            | ⇔
fat arrow vertical       | arrowV, fatarrowV            | ⇕
small triangle left      | triangleL                    | ⏴
small triangle right     | triangleR                    | ⏵
small triangle top       | triangleT                    | ⏶
small triangle bot       | triangleB                    | ⏷
triangle upper left      | triangleUL                   | ◤
triangle upper right     | triangleUR                   | ◥
triangle bot left        | triangleBL                   | ◣
triangle bot right       | triangleBR                   | ◢
triangle top             | triangletop, toptriang       | ∆
triangle bot             | trianglebot, bottriang       | ∇

[Emoji symbols]

checked norm             | checkednorm                  | ✔
checked thin             | checkedthin                  | ✓
crossed 1                | crossed1                     | ❌
crossed 2                | crossed2                     | ❎
crossed 3                | crossed3                     | ✕
crossed 4                | crossed4                     | ✖
crossed 5                | crossed5                     | ✗
crossed 6                | crossed6                     | ✘
question red             | questionred                  | ❓
question white           | questionwhite                | ❔
exclamation white        | exclamationwhite             | ❕
exclamation red          | exclamationred               | ❗
alarm clock              | alarmclock                   | ⏰
wall clock               | wallclock                    | ⌚
hourglass full           | hourglassfull                | ⌛
hourglass half           | hourglasshalf                | ⏳
small heart              | smallhearth                  | ♡
electricity              | electricity                  | ⚡
snowman                  | snowman                      | ⛄
cloudy day               | cloud                        | ⛅
white big ring           | whitebigring                 | ⚪
black big ring           | blackbigring                 | ⚫
white ring               | whitering                    | ⏺
small ring               | smallring                    | ⚬
stop sign                | stop, dont                   | ⛔
pause                    | pause                        | ⏸

[Emoji faces]

eyes                     | eyes, rolleyes, check        | 👀
smile                    | smile, grin                  | 😁
crying out loud          | cryingoutloud, col           | 😂
smiling eyes             | smilingeyes                  | 😄
open mouth               | openmouth                    | 😃
joy                      | joy, tears                   | 😂
rolling on the floor     | rofl                         | 🤣
laughing hand            | laughing                     | 🤭
embarassed               | embarassed                   | 😊
halo                     | halo, saint                  | 😇
upside down              | upsidedown                   | 🙃
winking                  | wink                         | 😉
relived                  | relived                      | 😌
love eyes                | love                         | 😍
delicous                 | delicious, toungue, yummi    | 😋
sunglasses               | sunglass, cool               | 😎
hearths                  | hearth                       | 🥰
thinking                 | think                        | 🤔

[Emoji hands]

perfect                  | ok, perfect                  | 👌
victory                  | victory, win                 | ✌
fingers crossed          | fingerscrossed               | 🤞
love you                 | lovey, rockit                | 🤟
call me                  | callme                       | 🤙
thumbs up                | thumbsup                     | 👍
thumbs down              | thumbsdown                   | 👎
fist                     | fist                         | 👊
left fist                | leftfist                     | 🤛
right fist               | rightfist                    | 🤜
handshake                | handshake                    | 🤝
praying                  | pray                         | 🙏
clapping                 | clap                         | 👏
raising hand             | raisin                       | 🙌
hand                     | hand                         | ✋
listen                   | listen, important            | ☝
The script:

Code: Select all

; Script     SendText.ahk
; Github:    https://github.com/bceenaeiklmr/SendText
; Date       20.02.2023
; Version    0.2

#Requires AutoHotkey >=2.0
#Warn
#SingleInstance

; ############################################

Main := Menu()
Sys  := Menu()

Main.Add("System", sys)
Sys.Add("My computer",  (*) => Run("::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"))
Sys.Add("Recycle bin",  (*) => Run("::{645FF040-5081-101B-9F08-00AA002F954E}"))
Sys.Add("Downloads",    (*) => Run("C:\users\" A_userName "\Downloads"))
Sys.Add("My documents", (*) => Run(A_MyDocuments))
Sys.Add("My desktop",   (*) => Run(A_Desktop))

Text := sendText(":")
Main.Add("Texts", Text)

previewIcon := 0
if previewIcon {
    pIcon := PreviewIcons()
    Main.Add("Icons", pIcon)
}

; set icons
Main.SetIcon("Texts",       "Shell32.dll", 75)
Main.SetIcon("System",      "Shell32.dll", 16)
Sys.SetIcon("My computer",  "Shell32.dll", 16)
Sys.SetIcon("Recycle bin",  "Shell32.dll", 32)
Sys.SetIcon("My documents", "Shell32.dll", 39)
Sys.SetIcon("Downloads",    "Shell32.dll", 46)
Sys.SetIcon("My desktop",   "Shell32.dll",  5)

; ############################################

#c::showMain(1)      ; windows + c, instantly
MButton::showMain(0) ; middle mouse button after 500 ms

; ############################################

sendText(TriggerHotkey := ":") {
    
    ; Unfortunately, IniRead doesn't support UTF-16 which is neccessary to use emojis
    Input := FileRead(A_ScriptDir "\hotstring.ini")
    ; temporaly replace OR
    InputFile := StrReplace(Input, "||", "Ͻ")
    Sect := Array()
    
    loop Parse, InputFile, "`n" {
        
        ; skip empty and comment lines
        if (A_LoopField ~= "^;") || (3 > StrLen(A_LoopField))
            continue
        Line := StrReplace(A_LoopField, Chr(13))
        ; category names
        if RegExMatch(Line, "^\[\w+(\s\w+)*\]", &Lines) {    ; regex
            Name := Trim(SubStr(Lines[], 2, -1))
            Sect.Push({ Name: Name, Hotkeys: [] })
        } else { ; hotkeys
            ; columns are separated by the pipe '|' chr
            Col := StrSplit(Line, "|")
            for v in Col {
                Col[A_index] := Trim(v)
                ; make `n chars visible in menus
                if (A_index = 4)
                    Col[A_index] := StrReplace(v, "``n", "`n")
                if InStr(v, "Ͻ")
                    Col[A_index] := StrReplace(v, "Ͻ", "||")
            }

            obj := { Preview : Col[1]
                   , Hotstrg : Col[2]
                   , Text    : Col[3]
                   , Code    : (4 > Col.length) ? "" : Col[4] }

            Sect[Sect.Length].Hotkeys.Push(obj)
        }
    }
    ; create menus
    Texts := Menu()
    for v in Sect {
        SectMenu := Menu()
        for hk in v.Hotkeys {
            Strg := Trim((hk.Code !== "") ? hk.Code : hk.Text)
            Sectmenu.Add(hk.Preview "`t" hk.Text, SendStr.Bind(Strg))
            ; register hotstrings
            hStrings := StrSplit(hk.HotStrg, ",")
            for hStr in hStrings
                HotString(":*:" TriggerHotkey Trim(hStr), SendStr.Bind(Strg))
        }
        texts.Add(v.Name, sectmenu)
    }
    return texts
}

SendStr(Strg, *) {
    if (SubStr(Strg, 1, 1) == "*")
        return Send(SubStr(Strg, 2))
    ClipSaved := ClipboardAll()
    A_Clipboard := Strg
    if ClipWait(.5, 1) {
        Send("{CtrlDown}v{CtrlUp}")
        Sleep 100
    }
    A_Clipboard := ClipSaved
    return
}

showMain(Instant := 1) {
    if Instant
        Main.Show()
    else {
        pressed := 0
        while getKeyState(A_thisHotkey,"P") {
            if (A_TimeSinceThisHotkey > 500) {
                Main.Show()
                pressed := 1
            }
        }
        if !pressed
            send "{" A_thisHotkey "}"
    }
}

PreviewIcons() {
    IconMenu := Menu()
    loop 10 {
        index := A_index
        submenu := Menu()
        IconMenu.Add(A_index, submenu)
        loop 32 {
            index2 := A_index + 32*(index2-1)
            submenu.Add(index2, (*) => "")
            submenu.SetIcon(index2, "Shell32.dll", A_index + 32*(index-1))
        }
    }
    return IconMenu
}
Kind regards,
Bence

Jasonosaj
Posts: 50
Joined: 02 Feb 2022, 15:02
Location: California

Re: SendText - hotstring, text snippet manager

Post by Jasonosaj » 31 Mar 2023, 10:17

Extremely tangentially related question - do you align your code manually or do you have a script or function that does it for you? Sorry for the minor post jack!

User avatar
NPerovic
Posts: 34
Joined: 31 Dec 2022, 01:25
Contact:

Re: SendText - hotstring, text snippet manager

Post by NPerovic » 08 Apr 2023, 09:30

Can we keep the original function of SendText? ....
https://www.autohotkey.com/docs/v2/lib/Send.htm
Collection of My AHK v2 Scripts
⭐ DarkThemeListView.ahk - Dark Theme ListView Control
⭐ KeyboardLayout.ahk - Switching between Keyboard Layouts
⭐ Dark_WindowSpy.ahk - Dark Theme Window Spy
⭐ SystemThemeAwareToolTip.ahk - Tooltip with System Theme Awareness
⭐ MouseHook.ahk - Tool for Intercepting Mouse Events
⭐ ToolTipEx.ahk - Extension for Custom Tooltips

User avatar
Chunjee
Posts: 1417
Joined: 18 Apr 2014, 19:05
Contact:

Re: SendText - hotstring, text snippet manager

Post by Chunjee » 12 Apr 2023, 12:39

I am trying this. However I needed to add the encoding for it to read the ini correctly
FileRead(A_ScriptDir "\hotstring.ini", "UTF-8")

(҂^.^)ᕤ

Amunoto
Posts: 15
Joined: 01 Dec 2018, 08:31

Re: SendText - hotstring, text snippet manager

Post by Amunoto » 05 May 2023, 05:55

Looks like what I am searching for.
Thanks for keeping it up to date here and on GitHub.

Unfortunately for me, written in AHK 2.0.
I use an older version - too much work to migrate.
:(
(Thx anyways.)

User avatar
NPerovic
Posts: 34
Joined: 31 Dec 2022, 01:25
Contact:

Re: SendText - hotstring, text snippet manager

Post by NPerovic » 05 May 2023, 18:34

Amunoto wrote:
05 May 2023, 05:55
Looks like what I am searching for.
Thanks for keeping it up to date here and on GitHub.

Unfortunately for me, written in AHK 2.0.
I use an older version - too much work to migrate.
:(
(Thx anyways.)
Why don't you just use them both?
Collection of My AHK v2 Scripts
⭐ DarkThemeListView.ahk - Dark Theme ListView Control
⭐ KeyboardLayout.ahk - Switching between Keyboard Layouts
⭐ Dark_WindowSpy.ahk - Dark Theme Window Spy
⭐ SystemThemeAwareToolTip.ahk - Tooltip with System Theme Awareness
⭐ MouseHook.ahk - Tool for Intercepting Mouse Events
⭐ ToolTipEx.ahk - Extension for Custom Tooltips

Amunoto
Posts: 15
Joined: 01 Dec 2018, 08:31

Re: SendText - hotstring, text snippet manager

Post by Amunoto » 07 May 2023, 11:32

NPerovic wrote:
05 May 2023, 18:34
Amunoto wrote:
05 May 2023, 05:55
Looks like what I am searching for.
Thanks for keeping it up to date here and on GitHub.

Unfortunately for me, written in AHK 2.0.
I use an older version - too much work to migrate.
:(
(Thx anyways.)
Why don't you just use them both?
That doesn't pose any issues?
If so; simple and good idea! :) Thx!

guest3456
Posts: 3462
Joined: 09 Oct 2013, 10:31

Re: SendText - hotstring, text snippet manager

Post by guest3456 » 15 May 2023, 11:56

Jasonosaj wrote:
31 Mar 2023, 10:17
Extremely tangentially related question - do you align your code manually or do you have a script or function that does it for you? Sorry for the minor post jack!
use a good text editor like Vim, endure the learning curve, and find endless plugins like this:
https://github.com/junegunn/vim-easy-align


Post Reply

Return to “Scripts and Functions (v2)”