WD-40 doesn't attract water, in fact the WD stands for Water Displacement. It's great for drying out electronics and machinery.

It can, however, attract dirt and dust over time, which is why it is not recommended for lubricating guns and such, and probably isn't the best for window mechanisms.