2

I'd like to do this using Autohotkey:

Keyboard press

 ``#

to get two lines of text in my text editor:

#!/usr/bin/env python3
#coding: utf-8

I find it hard to achieve, because # and {enter} seems to be mutual exclusive in hotstring content.

For example (A),

:*:`````#::/usr/bin/env python3{enter}coding: utf-8

gives me:

/usr/bin/env python3
coding: utf-8

-- looks normal so far.

But if I write (B):

:*:`````#::#!/usr/bin/env python3{enter}#coding: utf-8

The added #s will trigger windows Win Key. I will not get # in my text editor.

How to workaround this? Thank you in advance.

Autohotkey 1.1.24.05

2

"#" doesn`t need to be escaped in a hotstring definition.

:*:``#::`{#`}`{!`}/usr/bin/env python3{enter}`{#`}coding: utf-8

https://autohotkey.com/docs/Hotstrings.htm#remarks

or

:*:``#::
Send {Raw}  
(
#!/usr/bin/env python3
#coding: utf-8
)
return

or

:*:``#::
Send {Blind}{Text} ; [v1.1.27+] 
(
#!/usr/bin/env python3
#coding: utf-8
)
return

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

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.