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

up vote 2 down vote accepted

"#" 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

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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