I use the second code snippet in this link [1] for my autohotkey setup. It's pretty reliable.
[1]https://autohotkey.com/board/topic/10412-paste-plain-text-an...
[1]https://autohotkey.com/board/topic/10412-paste-plain-text-an...
function() hs.eventtap.keyStrokes(hs.pasteboard.getContents()) end