Stopping python script for user input

I have been trying to solve this problem for some time , maybe I have been looking at it wrong.

I would like to be able to (for example) select a bunch of verts and then run a script that would write them to an array and pause until the user selects a "target " vertex to position them against.

Currently I make my selections, then select a target and ctrl z twice and move on from there. I would make a significant impact on my workday to be able to include this move in my scripts.

Does anyone know a way to either pause a script like this or access undo from a script? Is there a conventional way to approach this that I have overlooked?

Many thanks in advance!

You can use active vertex as “target” or 2 buttons to execute - copy vertices button and position button.

I took me a moment to parse your reply. Thanks for your thoughts JuhaW. This was a case example of a larger problem tho…

If I can solve the pause for input problem, it leverages into a whole list of possibilities that would streamline my modeling significantly.

Also maybe I should mention that the target in these cases is generally the 3D cursor that is unaffected by undo’s.

I have it.
it all happens with one array, the last (2nd,3rd,4th) vertex selected is in a particular position because of its selection order.
simply select the target vertex last and and the one array will populate the two variables.