2

I am beginner with autohotkey.
I wanted make script which checks if I write ":)" and then it replaces with this "" (emoji in web.whatsapp) I dont know if it's possible to do using GetKeyState because in my keyboard I need Shift+dot for ":" and Shift+9 for ")".

I am sorry about my bad english. Hope you understand. :)

Thank you.

Code that works (thank Forivin)

:::)::
    clipSave := ClipboardAll
    Clipboard := "" ;
    Send, ^v
    Clipboard := clipSave
Return

:::D::
    clipSave := ClipboardAll
    Clipboard := "" ;
    Send, ^v
    Clipboard := clipSave
Return

2 Answers2

5

This works for me:

:::)::
    clipSave := ClipboardAll
    Clipboard := "" ;make sure this actually contains the smiley character, once you copied that into your notepad application
    Send, ^v
    Clipboard := clipSave
Return

:::(::
    clipSave := ClipboardAll
    Clipboard := "" ;make sure this actually contains the smiley character, once you copied that into your notepad application
    Send, ^v
    Clipboard := clipSave
Return

Make sure to save your file with the correct encoding (UTF-8 did the job for me). You may wanna use something like Notepad++ for that.
It might also help to install the unicode version Autohotkey. (I use the latest 32bit Unicode version of AHK_L.)

Forivin
  • 14,780
  • 27
  • 106
  • 199
0

What you are looking for is Hotstrings.

Example:

:::)::

Basically surrounding your statement with :: followed by what you want to replace it with.

errorseven
  • 2,672
  • 2
  • 14
  • 20
  • Thanks for fast reply! My code looks now like this: :::):: return When I do ":)" it replaces "😊"..thats weird. Any help? – user3794822 Sep 01 '15 at 13:15
  • It likely has to do with the way AutoHotkey is encoding characters. Not familiar with a specific fix. Hopefully someone will expand on this and find an answer for you. – errorseven Sep 01 '15 at 14:08
  • @user3794822 try this http://www.autohotkey.com/board/topic/80362-how-to-insertpaste-an-image-into-a-microsoft-word-document/ – phil294 Sep 01 '15 at 18:20
  • @user3794822, you (or anyone else finding their way here) have to make sure the AHK script file is a BOM-encoded file. That is, when you save your file, it can't be just an ASCII file, or even a raw UTF file, it MUST have the [Byte Order Mark](https://en.wikipedia.org/wiki/Byte_order_mark) at the start (for UTF-8, it's **0xEF,0xBB,0xBF**). – Synetech Aug 22 '22 at 15:22