I need help creating a script (to format text)

Get help with using AutoHotkey and its commands and hotkeys
Jomanto
Posts: 3
Joined: 15 Sep 2018, 21:24

I need help creating a script (to format text)

15 Sep 2018, 22:06

Hi,

I've just started using AHK and I would like to do the following, if possible:

Basically I want to copy a text into the clipboard and have it automatically formatted in a certain way (or highlight it in notepad and press a certain key combination to achieve the same thing, either way is fine).

Example:

Code: Select all

\t\:placeholder\,\s\:0.00,\e\:0.02,\t\:placeholder2,\s\:0.03,\e\:0.04
I want to replace \t\: with t:
replace \s\: with s:
replace \e\: with e:

And use "|" as a separator, so it becomes:

Code: Select all

 t:placeholder | s:0.00 | e:0.02 | t:placeholder2 | s:0.03 | e:0.04 |
Then I want it to break into a new line after t:, therefore it should become:

Code: Select all

t:placeholder | s:0.00 | e:0.02 | 
t:placeholder2 | s:0.03 | e:0.04 |
I would really appreciate it if someone could help me.

Thanks a lot!
Guest078
Posts: 11
Joined: 28 Aug 2016, 13:44

Re: I need help creating a script (to format text)

16 Sep 2018, 01:41

Code: Select all

Clipboard := "\t\:placeholder\,\s\:0.00,\e\:0.02,\t\:placeholder2,\s\:0.03,\e\:0.04"
Clipboard := RegExReplace(Clipboard, "$", " | ")
Clipboard := RegExReplace(Clipboard, "\\?t\\:", "`nt:")
Clipboard := RegExReplace(Clipboard, "\\(s|e)\\", "$1")
Clipboard := RegExReplace(Clipboard, "\\?,", " | ")
Msgbox, % Clipboard
Jomanto
Posts: 3
Joined: 15 Sep 2018, 21:24

Re: I need help creating a script (to format text)

16 Sep 2018, 02:36

Just to clarify:

Code: Select all

\t\:placeholder\,\s\:0.00,\e\:0.02,\t\:placeholder2,\s\:0.03,\e\:0.04
This Is just an example, the 'placeholder' and 'placeholder2' will always be replaced with different texts. The script should work regardless of what is in place of 'placeholder' and 'placeholder2'.
Guest078
Posts: 11
Joined: 28 Aug 2016, 13:44

Re: I need help creating a script (to format text)

16 Sep 2018, 02:39

And? Remove the first line, copy something to the clipboard that contains whatever placeholder, execute the script...
Jomanto
Posts: 3
Joined: 15 Sep 2018, 21:24

Re: I need help creating a script (to format text)

16 Sep 2018, 02:47

Oh I see, I just tested it with different texts. It works great!

Thanks a lot! I really appreciate your help.

Return to “Ask For Help”

Who is online

Users browsing this forum: Albireo, MannyKSoSo, Portwolf, smbs, SunAndSuch and 60 guests