This sounded like an extremely easy question at first glance but as I think about it, I can see why this might be confusing. I'm not even certain anymore and English is the only language I can speak.
Here's how I would understand those three sentences out of context:
1. Throw the pen out the window.
Take a pen that is currently inside and throw it through the open window such that it is inside no longer.
2. Throw the pen through the window
Take a pen (that may be inside or outside) and throw it through the closed window, breaking the glass in the process.
NOTE: This understanding is ambiguous in that the original sentence does not make it clear whether the window was open or not. Another way of putting this is that the English word "window" is ambiguous because it refers to both the glass part and the hole itself.
If a larger object like a ball or a brick had been thrown "through" the window, it would definitely imply breaking the window. A pen however, is too small. Thus it is unclear.
3. Throw the pen out of the room through the window.
Take a pen that is currently inside and throw it through the open window such that it is inside the room no longer.
Consider a generic adverbial phrase "out the NOUN".
There are two types of nouns that can replace NOUN.
NOUN can be a location, or
NOUN can be a barrier between locations
When NOUN is a location (1 above), often times and following far more complex rules than I can summarize or even understand, "out of" can be used instead of just "out".
For these reasons, if you wanted to make it clear that window was a location rather than a barrier (meaning that the pen is physically inside the window, you could clarify by stating "throw the pen out of the window."