How to make AHK to type braces (curly brackets) Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ujm

How to make AHK to type braces (curly brackets)

06 Nov 2014, 22:16

A simple question, and probably answered several times already, but the answer seems hard to find. I want AHK to type a text that includes the braces { and }, which AHK normally uses to define blocks. How to do that? Thanks for your help!
geek
Posts: 1052
Joined: 02 Oct 2013, 22:13
Location: GeekDude
Contact:

Re: How to make AHK to type braces (curly brackets)

06 Nov 2014, 22:20

Wrap them in {} :D
Or use SendRaw to disable all {} stuff

Code: Select all

Send, {{} ; Sends {
Send, {}} ; Sends }
Send, {{}{}} ; Sends {}
SendRaw, {} ; Sends {}
Send, {Raw}{} ; Sends {}
Guest

Re: How to make AHK to type braces (curly brackets)  Topic is solved

02 Jun 2016, 09:31

This solution works for curly braces in short cuts as well (thanks)

e.g.

:?:\scpr::${{}PWD/html/release/{}}

yielding

${PWD/html/release/}
Bluscream
Posts: 16
Joined: 10 Jan 2017, 23:12
Contact:

Re: How to make AHK to type braces (curly brackets)

10 Aug 2020, 13:38

Thanks for the tip, i made a little snippet to escape them:

Code: Select all

EscapeCurly(text) {
    ; str := StrReplace(str, "{", "{{}" ; Sends {
    ; str := StrReplace(str, "}", "{}}" ; Sends }
    ; return StrReplace(str, "{}", "{{}{}}" ; Sends {}
    Loop, Parse, text              ; retrieves each character from the variable, one at a time
    {
        if (A_LoopField == "{") {
            str .= "{{}"
        } else if (A_LoopField == "}") {
            str .= "{}}"
        } else {
            str .= A_LoopField
        }
    }
    return str
}

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: jollyjoe, Scr1pter, ziru and 304 guests