What if a ball runs a wicket but hits a ball lying in the wicket?

In this case the other ball is actually protruding into the wicket from the non-playing side (or back side), so that your ball hits the other ball before any part of your ball begins to score the wicket on the non-playing side, and then both balls fully clear the wicket. In this scenario, you get two shots for the roquet on the other ball (provided you are live on it), but you do not get credit for making the wicket, even if your ball fully clears the wicket after hitting the other ball. You can use your two shots to go through the wicket again, and when you do, you become live on that ball you had just roqueted. This is because the first event that happened was hitting the other ball. As explained above, you do not begin to score a wicket until your ball begins to exit from the non-playing side of the wicket. In this scenario, the roquet on the other ball occurred before your ball began to score the wicket. You may want to ask referee or another player to watch this shot for you to decide any dispute over whether your ball began to score the wicket before it hit the other ball.

Blue is about to attempt the wicket, while red is partly in the wicket.

Blue hits red before beginning to score the wicket. (A ball does not begin to score a wicket until it breaks the plane of the non-playing side.)

Even though blue has passed through the wicket, it counts as a hit and not a wicket, because the hit came first.