رَأَيْتُهُ — -hu: direct object, accusative position.
مَرَرْتُ بِهِ — -hi: object of a preposition, genitive position.
كِتَابُهُ — -hu: annexed possessive, genitive position.
إِنَّهُ قَائِمٌ — -hu: noun of inna, accusative position.
Determine position from the governing expression and syntactic role, not merely the pronoun’s vowel.