Copy one template that auto fills another

Get help with using AutoHotkey and its commands and hotkeys
Tweety
Posts: 7
Joined: 20 Feb 2018, 13:27

Copy one template that auto fills another

20 Feb 2018, 18:27

Hello all!I'm sorry if this has been asked before of if this is in the wrong place. I could be wording it wrong maybe because I can't find the solution anywhere :(

So, thanks for the help in advance! Here is what I'm trying to do. Let's say I have a template that looks like this:

Name: John Doe
Issues: Needs Help
Resolution: Helped them
Conclusion: Issue Resolved

I want to copy this template and it fills another template I have in ahk:

Code: Select all

:*:template::
(
Name:
Date: 
Phone Number: 
Reason Called:
Fixed:
Update:
)
I just want to be able to copy the first template, type "template" and it pastes the second template but now it looks like this:

Name: John Doe
Date:
Phone Number:
Reason Called: Needs Help
Fixed: Helped them
Update: Issue Resolved

This is all done in notepad++. I keep notepad++ open so I don't need to save the file. Any help would be appreciated!
User avatar
boiler
Posts: 2372
Joined: 21 Dec 2014, 02:44

Re: Copy one template that auto fills another

20 Feb 2018, 21:28

If I understand it, you will already have this:
Name: John Doe
Issues: Needs Help
Resolution: Helped them
Conclusion: Issue Resolved
...in the clipboard, then you will type "template".

It that's correct, the following will fill in and paste your revised template when you type "template":

Code: Select all

:*:template::
RegExMatch(Clipboard, "`n)Name: (.*)`nIssues: (.*)`nResolution: (.*)`nConclusion: (.*)", Match)
Clipboard =
(
Name: %Match1%
Date:
Phone Number:
Reason Called: %Match2%
Fixed: %Match3%
Update: %Match4%
)
Send, ^v
Tweety
Posts: 7
Joined: 20 Feb 2018, 13:27

Re: Copy one template that auto fills another

21 Feb 2018, 08:30

Works like a charm! Thank you so much!!
Tweety
Posts: 7
Joined: 20 Feb 2018, 13:27

Re: Copy one template that auto fills another

22 Feb 2018, 22:21

Hello all! So, I've run into an issue. If I take:

Name: John Doe
Issues: Needs Help
Resolution: Helped them
Conclusion: Issue Resolved

and turn it into this:

Name: John Doe

Issues: Needs Help

Resolution: Helped them

Conclusion: Issue Resolved

it doesn't work. It doesn't seem to like the spaces. Anyway to fix this? Thanks.
User avatar
boiler
Posts: 2372
Joined: 21 Dec 2014, 02:44

Re: Copy one template that auto fills another

22 Feb 2018, 23:37

It's important for you to describe all the situations in which you expect it to work.

Code: Select all

:*:template::
RegExMatch(Clipboard, "s)Name: ([^\n]*).*Issues: ([^\n]*).*Resolution: ([^\n]*).*Conclusion: ([^\n]*)", Match)
Clipboard =
(
Name: %Match1%
Date:
Phone Number:
Reason Called: %Match2%
Fixed: %Match3%
Update: %Match4%
)
Send, ^v
Tweety
Posts: 7
Joined: 20 Feb 2018, 13:27

Re: Copy one template that auto fills another

23 Feb 2018, 09:08

I'm sorry, I'm an idiot and assumed the next line wouldn't matter. I also assumed I'd be able to figure it out on my own, but I obviously suck. Thank you again. I really appreciate all of your help!
Tweety
Posts: 7
Joined: 20 Feb 2018, 13:27

Re: Copy one template that auto fills another

23 Feb 2018, 14:36

Ok, so please don't be mad at me. I'm testing different scenarios and after trying to resolve it myself (when I fail miserably) I ask for help. So, in this scenario these:

Issues: Needs Help

Resolution: Helped them

have more than one line of text. So it looks more like:

Issues: Needs Help

Step 1 - Tried this

Step 2 - Tried this

Resolution: Helped them by:

First tried - this

Gathered these things

Tried that

I also should mention that for Issues and Resolution, I would also test to see if it works with no matter how many lines there are. So I was thinking maybe an array to grab each line with an for each loop maybe? Thank you.
User avatar
boiler
Posts: 2372
Joined: 21 Dec 2014, 02:44

Re: Copy one template that auto fills another

23 Feb 2018, 16:01

Well, if it still has all for elements (you showed just Issues and Resolution, but I'm guessing that's just part of the whole) and you don't mind (in fact want) all the line feeds in there, then you can use this:

Code: Select all

:*:template::
RegExMatch(Clipboard, "s)Name: (.*)Issues: (.*)Resolution: (.*)Conclusion: (.*)", Match)
Clipboard =
(
Name: %Match1%
Date:
Phone Number:
Reason Called: %Match2%
Fixed: %Match3%
Update: %Match4%
)
Send, ^v
Tweety
Posts: 7
Joined: 20 Feb 2018, 13:27

Re: Copy one template that auto fills another

23 Feb 2018, 17:43

Ah ok, neat, you are a genius :) This is easy to modify for places you don't want a line feed so this is perfect! One more scenario and I'll leave you alone :D

Ok now say I want to have parenthesis in the clipboard like I've added to Issues below:

Name: John Doe
Issue(s): Needs Help
Resolution: Helped them
Conclusion: Issue Resolved

I can do without it unless there is an easy fix for that? When I add parenthesis the %Match% part of the code does not work and I get:

Name:
Date:
Phone Number:
Reason Called:
Fixed:
Update:
User avatar
boiler
Posts: 2372
Joined: 21 Dec 2014, 02:44

Re: Copy one template that auto fills another

23 Feb 2018, 18:37

Code: Select all

:*:template::
RegExMatch(Clipboard, "s)Name: (.*)Issue\(s\): (.*)Resolution: (.*)Conclusion: (.*)", Match)
Clipboard =
(
Name: %Match1%
Date:
Phone Number:
Reason Called: %Match2%
Fixed: %Match3%
Update: %Match4%
)
Send, ^v
Tweety
Posts: 7
Joined: 20 Feb 2018, 13:27

Re: Copy one template that auto fills another

23 Feb 2018, 18:40

Oh wow, that was too easy. Thank you again very much!! Really appreciate all of your help. I want to be just as awesome with this stuff as you are when I grow up ;) (I'm in my 30s btw lol)

Return to “Ask For Help”

Who is online

Users browsing this forum: stretch65, vvhitevvizard and 28 guests