Act on Dock Selection

Since Yosemite has screwed Spaces i’m wanting to create a macro that will, in response to clicking on a dock item, open the applications default window.
Being new to KM I am not too sure where to start.