early 15c., "a cheat, a mean ruse," from Old North French trique "trick, deceit, treachery, cheating," from trikier "to deceive, to cheat," variant of Old French trichier, probably from Vulgar Latin *triccare, from Latin tricari "be evasive, shuffle," from tricæ "trifles, nonsense, a tangle of difficulties," of unknown origin.
Meaning "a roguish prank" is recorded from 1580s; sense of "the art of doing something" is first attested 1610s. Meaning "prostitute's client" is first attested 1915; earlier it was U.S. slang for "a robbery" (1865). Trick-or-treat is recorded from 1942.
1590s, from trick (v.). Related: Tricked; tricking. An earlier sense of "to dress, adorn" (c.1500) is perhaps a different word entirely.
To do exactly what is needed for the desired result: this makeup ought to do the trick