Shukr
Mufti Taqi Usmani DB, stresses that one should imagine the countless bounties being showered by Allah SWT all the time: to be thankful unto him, as a routine!
He then quotes this dua recited upon seeing someone in trial or tribulation;
الْحَمْـدُ للهِ الّذي عافاني مِمّا ابْتَـلاكَ بِهِ، وَفَضَّلَـني عَلى كَثيـرٍ مِمَّنْ خَلَـقَ تَفضيلا
(Alhamdu lillahil-lathee AAafanee mimmab-talaka bih, wafaddalanee AAala katheerin mimman khalaqa tafdeela.)
Meaning: ‘All praise is for Allah Who saved me from that which He tested you with and Who most certainly favoured me over much of His creation.’
He further relates that one of his teachers once told him to recite this dua, not only upon seeing the afflicted person in a physical problem, but also, when someone is unfortunately committing an act of gunah. In this way, instead of thinking our own self of being superior (more pious) than another, we ‘thank’ Allah, that he did not put us in that state of trial (that act of gunah).