Skip to content

Instantly share code, notes, and snippets.

@JamoCA
Last active April 22, 2024 17:01
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save JamoCA/1d6d4a14b3ccfd9b3a0bf94db0c447ed to your computer and use it in GitHub Desktop.
Save JamoCA/1d6d4a14b3ccfd9b3a0bf94db0c447ed to your computer and use it in GitHub Desktop.
AutoHotKey Script to emulate typing. Use CTRL+SHIFT+V to paste clipboard character-by-character as if typing.
^+v:: ; paste text and emulate typing (CTRL+SHIFT+V)
AutoTrim,On
string = %clipboard%
Gosub,ONLYTYPINGCHARS
StringSplit, charArray, string
Loop %charArray0%
{
this_char := charArray%a_index%
Send %this_char%
Random, typeSlow, 1, 3
typeMin = 50
typeMax = 150
if (typeSlow >= 3){
typeMin = 150
typeMax = 350
}
Random, t, typeMin, typeMax
Sleep, %t%
}
Return
ONLYTYPINGCHARS:
AutoTrim,Off
StringCaseSense,On
StringReplace,string,string,–,-,All ;emdash
StringReplace,string,string,´,',All
StringReplace,string,string,’,',All
StringReplace,string,string,©,(C),All
StringReplace,string,string,“,",All ;left quote
StringReplace,string,string,”,",All ;right quote
StringReplace,string,string,®,(R),All
StringReplace,string,string,¼,1/4,All
StringReplace,string,string,½,1/2,All
StringReplace,string,string,¾,3/4,All
StringReplace,string,string,™,TM,All
StringReplace,string,string,«,<<,All
StringReplace,string,string,»,>>,All
StringReplace,string,string,„,',All
StringReplace,string,string,•,-,All ;bullet
StringReplace,string,string,…,...,All
StringReplace,string,string,`r`n,`n,All ;replace newlines
StringReplace,string,string,chr(0),A_Space,All ;NULL
StringReplace,string,string,chr(9),A_Space,All ;Horizontal Tab
StringReplace,string,string,chr(10),A_Space,All ;Line Feed
StringReplace,string,string,chr(11),A_Space,All ;Vertical Tab
StringReplace,string,string,chr(14),A_Space,All ;Column Break
StringReplace,string,string,chr(160),A_Space,All ;Non-breaking space
Return
@peanutcracker1
Copy link

Is there a way to have this only activate in certain Windows or applications, but not override the hotkey in other Windows?

@JamoCA
Copy link
Author

JamoCA commented Apr 22, 2024

Consult the AutoHotKey documentation. To do this, you'd need to use WinGetActiveTitle and then use IfInString (or If Title contains) to check against a list of allowed window names.

For example, if you wanted this to work with app that have a window title that contain the text "Visual Studio Code", you could use:

WinGetActiveTitle, Title
IfInString, Title, Visual Studio Code
{
 ; all of the logic
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment