3

I would like to do an auto hot key script that will paste:

{ get; set; }

for C#

Is this possible or does it not know how to handle the spaces, {, ;?

I've tried the following, but it does not work:

    ^NumPad3::
    SendInput, { get; set; }
    return
Cave Johnson
  • 6,499
  • 5
  • 38
  • 57
tvb108108
  • 398
  • 3
  • 19
  • Ctrl-C, Ctrl-V. { get; set; }{ get; set; }{ get; set; }{ get; set; }{ get; set; }{ get; set; }{ get; set; }{ get; set; }{ get; set; }{ get; set; }{ get; set; }{ get; set; } – Robert Harvey Dec 28 '18 at 23:20
  • Take a look at https://learn.microsoft.com/en-us/visualstudio/ide/code-snippets?view=vs-2017 – Flydog57 Dec 28 '18 at 23:21
  • You need to escape curlies in autohotkey like so: `{{}` for `{` and `{}}` for `}`. Semi colons start comment lines unless you escape them like `\`;` – Jonathon Chase Dec 28 '18 at 23:24

1 Answers1

1

Comma, semicolon, and other characters such as {}^!+# have special meaning in AHK and need to be escaped in order to be interpreted differently than it normally would.

F1:: SendInput, {{} get`; set`; {}}

https://autohotkey.com/docs/commands/_EscapeChar.htm#Escape_Sequences

The easiest way to send such a text is

F2::
Send {Raw}  
(
{ get; set; }
)
return

or

F3::
Send {Blind}{Text} ; [v1.1.27+] 
(
{ get; set; }
)
return

https://autohotkey.com/docs/commands/Send.htm

user3419297
  • 9,537
  • 2
  • 15
  • 24
  • Thanks user3419297! This worked fine: F1:: SendInput, `{{`} get`; set`; `{}`} (I had to make sure I was doing it in the right section where get; set; are allowed etc.!) – tvb108108 Dec 29 '18 at 04:08