  Given a semidirect product $\frak{g}=\frak{s}\uplus\frak{r}$ of semisimple
Lie algebras $\frak{s}$ and solvable algebras $\frak{r}$, we construct
polynomial operators in the enveloping algebra $\mathcal{U}(\frak{g})$ of
$\frak{g}$ that commute with $\frak{r}$ and transform like the generators of
$\frak{s}$, up to a functional factor that turns out to be a Casimir operator
of $\frak{r}$. Such operators are said to generate a virtual copy of $\frak{s}$
in $\mathcal{U}(\frak{g})$, and allow to compute the Casimir operators of
$\frak{g}$ in closed form, using the classical formulae for the invariants of
$\frak{s}$. The behavior of virtual copies with respect to contractions of Lie
algebras is analyzed. Applications to the class of Hamilton algebras and their
inhomogeneous extensions are given.
