Character replace in clipboard

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
foguetes
Posts: 19
Joined: 19 Oct 2018, 04:58

Character replace in clipboard

04 Dec 2019, 07:01

I'm trying to create a script that replaces a \ with a / when I press windows+shift+c.

This has worked only a few times, so it's very inconsistent. I really don't know why.

I'm using it to convert windows filepaths to mac file paths, so if I have:

\\desktop\Users\Me\Desktop\mpv-shot0001.jpg

When I press this shortcut I would get:

//desktop/Users/Me/Desktop/mpv-shot0001.jpg

Code: Select all

#Persistent
return

#+c::

Send, ^c
ClipWait, 1

Clipboard	:= RegExReplace(Clipboard, "\/", "\")
MsgBox, % Clipboard

return
Mod edit: Added title
What am I doing wrong?
Rohwedder
Posts: 7768
Joined: 04 Jun 2014, 08:33
Location: Germany

Re:

04 Dec 2019, 08:25

Hallo,
try:

Code: Select all

Clipboard := StrReplace(Clipboard, "\", "/")
or:

Code: Select all

Clipboard := RegexReplace(Clipboard, "\\", "/")

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Spawnova, william_ahk and 253 guests