I want an AHK Script that remaps Control+v to send the Clipboard, as it is intended, in non-CMD terminals, like Bash and Putty.
Each terminal has a different command to paste the clipboard and it's always annoying to remmber which I should use in that moment. And the usual Control+C , Control+V causes some weird characters to appear (^[[200~...~), which then I need to delete manually.
I created the following script:
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance, Force
SetKeyDelay -1
^v::
sendRaw,% clipboard
return
Which works 'fine', but have some small cavieats:
When I copy something that expect another char to come right after, such as ` ´ ^ ~, or chars that are expected in pairs, such as " ( [ {, it has a strange behaviour, instead of just pasting the unique char I copied. On the first case, I have to paste twice in oder to anything to appear and then remove one of the duplicated chars. On the second, when the apps expect closures, like VScode, Intellij, instead of printing just the char I copied, it prints the opening and the closing characters, which I then have to delete the later.
As per Relax comment,
text modesolved almost all use cases...In the end I had to use
#IfWinActive, because print screens wouldn't work with that implementation...That's the final solution: