Does anyone know of any code that records actions that mouse and keyboard performs on my computer then save the file so I can replay it later

I have 340,000 pdf documents to work through
The Idea is to ...
The recording app will do three things, when I start it up it must load what was recorded under A that is to open the first PDF in a directory copy a line of text thats in the same place every time - paste into the recording app, I plan to make text box that when end edit is fired it "reads" the text - if text pasted into textbox says "PAID" it must do what's recorded in B
If not it must do what was recorded under C

When B or C is done ot must do it again (The pdf will be moved from the original folder so the pdf it will open will not be the same, I have covered for that)

The thing is I have found code and it does not save the actions to a file so I can run it again or whenever I want, plus I need to save more than one set of actions ... the bad part is it was done in C# and I am not very good at it :( YET.

Can anyone point me to examples or show me ho to save the actions to a file to play again
Code attached