Preheat oven to 350 degrees. Butter a large casserole dish.
Heat butter in a large skillet. Add onions and cook for 1 to 2 minutes, or until they start to turn translucent. Add ham and cook for 3 to 4 minutes until thoroughly heated. Remove from heat and set aside.
Combine half-and-half and cream in a microwave-safe container and nuke for a minute or so, until no longer cold. Whisk in flour and black pepper until totally combined. Set aside. (You may add salt, but cheese and ham are salty, so add sparingly.)
Combine the two grated cheeses. Set aside.
Using a mandoline or slicer, slice potatoes into 1/8-inch slices (very thin.) Layer 1/3 of the potato slices in the buttered casserole dish. Sprinkle on 1/3 of the ham/onion mixture, then 1/3 of the cheese, then pour on 1/3 of the cream mixture.
Repeat this twice more, ending with a sprinkling of cheese and a pouring on of the rest of the cream mixture. Cover dish with foil and bake for 40 minutes. Remove the foil and bake for an additional 20 minutes at least, or until bubbly and hot.
Enjoy!