Removing Leading and Trailing Whitespace from Clipboard

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
DuncanVicente95
Posts: 12
Joined: 13 Feb 2024, 13:23

Removing Leading and Trailing Whitespace from Clipboard

21 Mar 2024, 08:51

I currently have a very simple script to type out my clipboard.

+`::Send A_Clipboard

I would like to modify the script to remove trailing (and leading if it is easy enough) spaces, tabs and line breaks before typing the contents.

I have looked around online for scripts but everything I see is for AHK 1.
User avatar
boiler
Posts: 16985
Joined: 21 Dec 2014, 02:44

Re: Removing Leading and Trailing Whitespace from Clipboard

21 Mar 2024, 09:50

Code: Select all

+`::Send Trim(A_Clipboard, ' `t`n`r')
DuncanVicente95
Posts: 12
Joined: 13 Feb 2024, 13:23

Re: Removing Leading and Trailing Whitespace from Clipboard

21 Mar 2024, 12:07

When attempting to use this I receive an error that says "error: expected a string but got a func.".

What I pasted was just a single cell from excel into notepad.
DuncanVicente95
Posts: 12
Joined: 13 Feb 2024, 13:23

Re: Removing Leading and Trailing Whitespace from Clipboard

21 Mar 2024, 12:29

Disregard, I tried again and it does work. I must have mistyped something

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: Google [Bot], hiahkforum, lexikos, Noitalommi_2, w_i_k_i_d and 52 guests