News:

Welcome to our NEW forum! We invite you to sign up today
so it can grow to be a valuable resource to all Toolbox users!

Main Menu

Help with script - Clean phone number (spaces/dots/slashes → compact)

Started by Sunny, December 14, 2025, 06:46:43 PM

Previous topic - Next topic

Sunny

Hello,

Problem: I copy numbers like 06.12.65.11.22, 06 12 65 11 22 or 06/12/65/11/22
Goal: 0612651122 (digits only)

Wanted functionality:

Keyboard shortcut (Ctrl+Win+P)

Read clipboard

Remove spaces, dots, slashes

Put result back in clipboard

Ready to paste Ctrl+V

Can someone help me code this? Thanks!  :)

Paul (Lead Developer)

Hi Sunny. This action will do it:

(Start)
TIP: Copy from Start to End to paste into an action.
0001 String: Assign from clipboard text ""
0002 String: Make numeric ""
0003 Clipboard: Assign text "string$"
(End)

Set the action's hotkey to Ctrl+Win+P, and it will convert the clipboard text to digits only, ready for pasting with Ctrl+V.

Bazza

Could you make the hotkey paste it as well? Removing the need for Ctrl+V after conversion?

Paul (Lead Developer)

Hi Bazza. Yes, you could add a single step at the end like this so that the hotkey pastes it:

(Start)
TIP: Copy from Start to End to paste into an action.
0001 String: Assign from clipboard text ""
0002 String: Make numeric ""
0003 Clipboard: Assign text "string$"
0004 Keyboard: Paste ""
(End)

Or, if you don't want to do it with several hotkeys (Ctrl+X, Ctrl+Win+P, and Ctrl+V) then you can make it cut the selected text, convert it, and paste it back all with one hotkey like this:

(Start)
TIP: Copy from Start to End to paste into an action.
0001 Keyboard: Cut ""
0002 String: Assign from clipboard text ""
0003 String: Make numeric ""
0004 Clipboard: Assign text "string$"
0005 Keyboard: Paste ""
(End)

Sunny

Quote from: Paul (Lead Developer) on December 14, 2025, 08:25:37 PMHi Sunny. This action will do it:

(Start)
TIP: Copy from Start to End to paste into an action.
0001 String: Assign from clipboard text ""
0002 String: Make numeric ""
0003 Clipboard: Assign text "string$"
(End)

Set the action's hotkey to Ctrl+Win+P, and it will convert the clipboard text to digits only, ready for pasting with Ctrl+V.

Hello Paul,
I pasted the script and ran a test, but an error message appeared  :-[


Paul (Lead Developer)

Yes, the Step's help says that "String: Make numeric" can only be used on single lines of clipboard text. The examples you posted were a single line (eg. "06/12/65/11/22").

Maybe you have copied a line break before and/or after the text? If so, you can remove them like this (Step 2):

(Start)
TIP: Copy from Start to End to paste into an action.
0001 String: Assign from clipboard text ""
0002 String: Remove line breaks "0"
0003 String: Make numeric ""
0004 Clipboard: Assign text "string$"
(End)

The "0" for Step 2's value means to NOT insert a space where the line breaks are. Specifying "1" will put a space.

Sunny

Quote from: Paul (Lead Developer) on December 18, 2025, 08:20:36 PMYes, the Step's help says that "String: Make numeric" can only be used on single lines of clipboard text. The examples you posted were a single line (eg. "06/12/65/11/22").
Maybe you have copied a line break before and/or after the text? If so, you can remove them like this (Step 2):
(Start)
TIP: Copy from Start to End to paste into an action.
0001 String: Assign from clipboard text ""
0002 String: Remove line breaks "0"
0003 String: Make numeric ""
0004 Clipboard: Assign text "string$"
(End)

The "0" for Step 2's value means to NOT insert a space where the line breaks are. Specifying "1" will put a space.
Huge thanks Paul, it's all working perfectly now, you're a lifesaver  :D



Paul (Lead Developer)

Good to hear, Sunny. Which gives me an idea: there's already an option to remove spaces from the start and end of copied lines, but maybe removing {Enter} from the start and end of copied text should be an option, too. After all, how often do we need extra blank copied lines? I've added this for the next update. :)