Combo of Back Spaces and Arrow keys

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
shuyungboat
Posts: 7
Joined: 27 Nov 2021, 11:31

Combo of Back Spaces and Arrow keys

Post by shuyungboat » 27 Nov 2021, 11:36

For my job, I often have to take a phone number in this format 555-222-1234 and turn it into this format 5552221234. I want to write a little hotkey or hotstring to automate this process, so that when I place my cursor at the end of the phone number, I can type the hotkey and it will move the left arrow key 4 times, back space, left arrow 3 times, back space, left arrow 3 times again, backspace 2-3 times to remove any rogue spaces. Just as a test, I tried something like this: (I am a noob at AHK and only have word replacement scripts and some hoykeys running so far).

Code: Select all

:*:pnp::{left 4}{BackSpace}{left3}{BackSpace}{left4}{BackSpace}
I know that something to do with the Send command would help but I am a bit lost, any help would be greatly appreciated!

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

Re: Combo of Back Spaces and Arrow keys

Post by mikeyww » 27 Nov 2021, 12:21

Welcome to AHK!

Code: Select all

:?*:pnp::{Left 4}{BS}{Left 3}{BS}{Left 3}{BS 2}

User avatar
shuyungboat
Posts: 7
Joined: 27 Nov 2021, 11:31

Re: Combo of Back Spaces and Arrow keys

Post by shuyungboat » 27 Nov 2021, 13:16

Thank you so much, Mike! That did the trick!

User avatar
shuyungboat
Posts: 7
Joined: 27 Nov 2021, 11:31

Re: Combo of Back Spaces and Arrow keys

Post by shuyungboat » 27 Nov 2021, 13:18

I forgot to ask, what does the ? do in this context?

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

Re: Combo of Back Spaces and Arrow keys

Post by mikeyww » 27 Nov 2021, 14:46

Question mark:
The hotstring will be triggered even when it is inside another word; that is, when the character typed immediately before it is alphanumeric.

User avatar
shuyungboat
Posts: 7
Joined: 27 Nov 2021, 11:31

Re: Combo of Back Spaces and Arrow keys

Post by shuyungboat » 27 Nov 2021, 22:15

mikeyww wrote:
27 Nov 2021, 14:46
Question mark:
The hotstring will be triggered even when it is inside another word; that is, when the character typed immediately before it is alphanumeric.
Thanks! I ended up doing some reading and found it among some other useful stuff! Thanks for being so helpful so quickly :)

Post Reply

Return to “Ask for Help (v1)”