Search code examples
windowsunicodeautohotkey

How to replace text in AutoHotKey but iff. the needle matches the exact capitalization of the ReplaceText?


Code

#NoEnv
#SingleInstance, Force
#Warn
SendMode, Input
SetBatchLines, -1
SetWorkingDir, %A_ScriptDir%
StringCaseSense, 1

:*?:EmDash::—

Explanation

My goal is to replace the text "EmDash" with —, but only if the text is spelt exactly as "EmDash", not emdash or any other spelling except exactly that. The code currently works for replacing emdash with —, but this is not my goal. I have tried to solve this by using "StringCaseSense, 1", but to no avail. If anyone knows the answer please share it here. I have not found the answer to this problem on any forum.


Solution

  • Option Case sensitive:

    C: When you type an abbreviation, it must exactly match the case defined in the script. Use C0 to turn case sensitivity back off.

    :c*?:EmDash::—