The second link you provided has the code I pasted above, and purports to do what you want.
_________________________
(... better days ahead)