By the first principles plane-wave pseudopotential calculations based on the density functional theory, we studied the equations of states and structural properties of transition metal compounds OsB2 and OsO2 and the possible high pressure phase transitions of OsO2. Three (rutile, pyrite and fluorite) phases of OsO2 are studied under high pressure. The calculated results support the opinion that OsB2 and the fluorite phase of OsO2 should be potential ultralow-compressible hard materials. The microscopic mechanism of large bulk modulus and high hardness can be understood from the calculated electronic structures. It is therefore suggested that incorporating light elements (boron, oxygen, carbon or nitrogen) into transition metals with high valence electron densities is possibly a new way to prepare superhard materials.