I need some help with removing : from file name with hotkey Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
SweetLife
Posts: 14
Joined: 02 Jan 2023, 15:41

I need some help with removing : from file name with hotkey

Post by SweetLife » 31 Mar 2023, 21:10

Here is what I am trying to do:
I recently went to hobby lobby and grabbed a few rip off papers that show how-to tips and DIYs. I decided to look online when I got home to see if they have them on there site and yes they do. So I wanted to open them up on my google chrome and then download the ones I want so that I can get rid of the paper ones and keep the digital version. Now here is the issue I am having.

Each time I click the "Down" arrow on the PDF viewer on google chrome it pops up a downloads box telling me the location of the downloaded file and then the name of the file. Sometimes the name is just random numbers or random text or just words with - between each word.

So what I decided to do was copy the name of the project from the original page before hitting "View Inspiration" which takes me to the "PDF Reader" thing. So now I have the new file name.

If the file name has : the file name can't be saved is there any way to block these from being placed inside the space.

For example to get this : I need to hold Shift ^ and then ; so even though I copied the entire text when this : is placed can it do something else like give me a space and - then a second space.

To go from: 123:456 to 123 - 456 I hope this makes sense.

I would copy the title as 123:456 and then paste it as 123 - 456 without needing to change the : to - myself.


[Moderator note: Topic originated in "Ask for Help (v2)" but was moved to the v1 section after it became apparent OP is using v1.]

SweetLife
Posts: 14
Joined: 02 Jan 2023, 15:41

Re: I need some help with removing : from file name with hotkey

Post by SweetLife » 31 Mar 2023, 21:54

I'm sorry for the 123:456 it would actually be 123: 456 the space on the right side of the 3 is already there so I would need to add a space after the 3 and swap the : for a -. I hope this makes more sense.

User avatar
mikeyww
Posts: 26848
Joined: 09 Sep 2014, 18:38

Re: I need some help with removing : from file name with hotkey

Post by mikeyww » 31 Mar 2023, 22:12

Welcome to this AutoHotkey forum!

Code: Select all

#Requires AutoHotkey v2.0
F3:: {
 A_Clipboard := '', Send('^c')
 If ClipWait(1)
  SendText StrReplace(A_Clipboard, ':', ' - ')
 Else MsgBox 'An error occurred while waiting for the clipboard.', 'Error', 48
}

SweetLife
Posts: 14
Joined: 02 Jan 2023, 15:41

Re: I need some help with removing : from file name with hotkey

Post by SweetLife » 31 Mar 2023, 23:40

I received "Error at line 2. Line Text: ''
Error: The leftmost character above is illegal in an expression.
The program will exit.

I also tried to change the F3 to a number key I would like to use (4) from the key pad. I use (2) to close a chrome tab which is Ctrl+w and then I use (3) to click on the download button and I would like to use (4) for this hotkey. But there is a error. I don't know much about how to make hotkeys still. What am I doing wrong while trying to start this hotkey.

User avatar
boiler
Posts: 16900
Joined: 21 Dec 2014, 02:44

Re: I need some help with removing : from file name with hotkey

Post by boiler » 01 Apr 2023, 06:34

You apparently didn't run his whole script (left out line 1), or you would have received an error saying you are not using the correct version of AHK (or another error if you are using such an old version it doesn't recognize #Requires at all). You can't just omit that line and use the script with v1. You posted in the v2 section, so I'm moving this thread to the v1 section.

User avatar
mikeyww
Posts: 26848
Joined: 09 Sep 2014, 18:38

Re: I need some help with removing : from file name with hotkey  Topic is solved

Post by mikeyww » 01 Apr 2023, 06:54

Here is v1.

Code: Select all

#Requires AutoHotkey v1.1.33

F3:: 
Clipboard := ""
Send ^c
ClipWait 0
If ErrorLevel
 MsgBox 48, Error, An error occurred while waiting for the clipboard.
Else SendInput % "{Text}" StrReplace(Clipboard, ":", " -")
Return

SweetLife
Posts: 14
Joined: 02 Jan 2023, 15:41

Re: I need some help with removing : from file name with hotkey

Post by SweetLife » 01 Apr 2023, 10:16

Sorry for posting in the V2 I thought that is what I was using. But I retried the first script and found out I am actually using "AutoHotkey v1.1.36.01 Unicode 64-bit". The second code worked great but I could not use F3 all it did was change the "Volume" level of my laptop so I used NumPad4 instead. But otherwise this worked great.

User avatar
mikeyww
Posts: 26848
Joined: 09 Sep 2014, 18:38

Re: I need some help with removing : from file name with hotkey

Post by mikeyww » 01 Apr 2023, 10:23

Good to hear.

You didn't actually press F3. You pressed the volume adjustment key. To press F3, you probably need to press and hold Fn first. You can likely change this toggle default through your computer's BIOS configuration.

SweetLife
Posts: 14
Joined: 02 Jan 2023, 15:41

Re: I need some help with removing : from file name with hotkey

Post by SweetLife » 01 Apr 2023, 10:42

mikeyww wrote:
01 Apr 2023, 10:23
You didn't actually press F3. You pressed the volume adjustment key. To press F3, you probably need to press and hold Fn first. You can likely change this toggle default through your computer's BIOS configuration.
I actually prefer the NumPad since I use 1 for downloading 2 for closing tabs and now 3 for a simple download hotkey for downloading from hobby lobby DIYs for today once done I will remove the hotkey and use 3 for something else and I will also change out 4 as well. But for now I'm just tinkering trying to find the best hotkeys to make for my keypad. My windows 10 laptop has a keypad to the right and my newer windows 11 laptop is a bit smaller without a keypad so downloading and stuff will be done on the windows 10 and windows 11 will be used for something else with autohotkey.

So numpad works best for me currently. but thanks for the tip with the FN button I think I will use the F keys for my Windows 11 laptop once I find out what I want each key to do.

User avatar
mikeyww
Posts: 26848
Joined: 09 Sep 2014, 18:38

Re: I need some help with removing : from file name with hotkey

Post by mikeyww » 01 Apr 2023, 10:49

Of course, it is up to you to decide what hotkey is best. Enjoy! :) :wave:

Post Reply

Return to “Ask for Help (v1)”