I run a Linux emulator (or subsystem) under Windows 10, and sometimes I need to past Windows paths in the Linux console. Windows paths use backslashes \ to separate directories whereas Linux paths use forward slashes / instead.
To avoid having to replace the \ with / manually, I have tried using an AHK script to do the replacement on any path that I copy, but it doesn't want to work.
This is my script (I have marked in the code
##works until here## the furthest point until where it seems to be working):
^+7:: ; Ctrl+Shift+7 (/) ;Empty the Clipboard. Clipboard = ;Copy the select text to the Clipboard. SendInput, ^c ;Wait for the Clipboard to fill. ClipWait ;Perform the RegEx find and replace operation, ;where the needle is what we want to replace. haystack := Clipboard needle := "\" replacement := "/" result := RegExReplace(haystack, needle, replacement) ;Empty the Clipboard Clipboard = ;Copy the result to the Clipboard. Clipboard := result ;##works until here## ;Wait for the Clipboard to fill. ClipWait ;-- Optional: -- ;Send (paste) the contents of the new Clipboard. SendInput, %Clipboard% ;Done! return
Thanks in advance for any tips.