user3794822
user3794822

Reputation: 23

Autohotkey Replace 2 specific character with one

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

Upvotes: 2

Views: 1242

Answers (2)

Forivin
Forivin

Reputation: 15508

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.)

Upvotes: 5

errorseven
errorseven

Reputation: 2672

What you are looking for is Hotstrings.

Example:

:::)::😊

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

Upvotes: 0

Related Questions