It really depends on what the underlying technology. For Win32 there is Spy++ that ships with Visual Studio. For applications that properly implement the MSAA api's for accessibility you can use UIAutomation, so the tool for that is UISpy which is part of the Windows SDK. For managed .net applications I cannot recommend Hawkeye enough.
If the application is a IE based, you can use my Control Grabber, which is open source here. It uses code from hawkeye to hook the browser control and then uses WatiN (on a 32Bit machine), to read the entire DOM and spit out code in a format that I want.
Hope that helps.