I would assume the anti-cheat software is noticing the behaviour of your hack (Win32 API calls) and terminating it.
Instead, render your GUI using the rendering back-end of the game you're making a tool for (OpenGL/Direct3D) and find a way to handle keyboard/mouse input.
I don't have experience with X-Trap, but I doubt it can pick up the behaviour patterns of every custom application.
If it doesn't interfere with overlays like Xfire, Fraps, Teamspeak, etc then you can probably write a GUI using OpenGL/D3D and handling input.
My guess is it has a black-list of known/common tools, and traces Win32 API calls for ones commonly used by hacks.
If you don't want to disable X-trap, just don't become its enemy.