I never did it, but my Dad did a few. Here's what I learned from him:
Contact the Patent Office directly. You'll need drawings, an explanation of how it works and what makes it unique. It's usually inexpensive (<$100) - at least it used to be.
Once you apply for a patent, you've announced to the world what you've created. There are people out there that watch for patent applications (public record). The trick is to keep them from making a minor modification to your design and doing an end run around your patent.
Inventing is the easy part. Marketing it is the key.
Depending on the product, it's sometimes better to bypass the patent process, just manufacture & market it yourself and make your profits before the copycats get in.
Stay away from the patent lawyers that advertise their service - they're usually crooks.
Your dilemma now is that you've got an idea that you can't tell anybody about for fear they'll take it.
Good Luck.