Is it possible to get the highlighted component and its objects name?

I want to create a simple command, that will take the selected components and align them to a point under the users mouse, limiting the movement to a single axis.

This can be done in default Maya but its cumbersome and involves multiple steps:

  1. Select components to be moved
  2. Activate the axis they are to be moved along (by clicking on the pivots/gizmos axis)
  3. Turn on point snapping on the status line (or hotkey)
  4. with pointer under the target vertex, middle click to complete the operation

The above is one of my favourite features in Maya, I uses it all the time. I really need to streamline it. The command I have in mind is:

  1. Select components to be moved
  2. with pointer under the target vertex, trigger command (or hotkey) to complete the operation

The following is what I so far have, it works but with one limitation, the “target” vertex is hardcoded:

global proc snapToPoint(string $axis){
	string $sel[]= `ls -flatten -orderedSelection`;
	vector $target = `pointPosition -world pPlane1.vtx[1]`;  // <--- replace this hardcoded value with the vertex under the pointer
	
	if ($axis == "x")
		move -x ($target.x) ($target.y) ($target.z) -worldSpace $sel;
	else if ($axis == "y")
		move -y ($target.x) ($target.y) ($target.z) -worldSpace $sel;
	else if ($axis == "z")
		move -z ($target.x) ($target.y) ($target.z) -worldSpace $sel;
}

This is why I need a way to get the vertex under the users mouse or the one that is being highlighted, as shown here:

I have searched for solutions and I keep coming across C++ answers like this

I have looked at the Mel reference as well and did not come across potential commands.

I am on the latest Maya.