2

I use AutoHotKey to autocomplete all kind of brackets in the following way:

  • typing ( gives ( -> opening brace bracket only
  • typing (( gives () -> open & close brace with input cursor between the braces.

The same thing happen for square brackets [] and curly brackets {}.

My code for braces (for example) is as follow:

{ ; Automatic BRACES
  :*?:((::
    SendInput, {Raw}()
    Send {SPACE} 
    SendInput, {Left 2}
  return
}

After pressing the double opening brace, I enter my text between the braces, then simply press END and continue typing. The space after the closing brace is already added.

MY PROBLEM:

I would like quotes "" to behave the same way but obviously AHK treat quotes differently and I cannot figure how. With the Code :

{ ; Automatic Quotes
  :*?:""::
    Send {U+0022}
    Send {U+0022}
    Send {SPACE} 
    SendInput, {Left 2} 
    return
}

pressing " -> nothing happen.

pressing "" -> make a double quote with the cursor in-between (as expected)

Changing the code to :

{ ; Automatic Quotes
  :*?:"::
    Send {U+0022}
    Send {U+0022}
    Send {SPACE} 
    SendInput, {Left 2} 
   return
 }

will add "" with cursor in-between after one single press of the " key.

QUESTION:

Does anyone have an idea how I can make QUOTES behave the same way as my other brackets?

Many thanks in advance for your help.

Michel
  • 21

1 Answers1

0

You may use the AutoHotKey Hotstrings with a script like this:

:*:""::
Send,""
Send,{Left}
return

The hoststring here is "".
The * option means that AHK doesn't wait for an ending character after the "".

Relax
  • 3,785
harrymc
  • 498,455