There is a Halachic concept relevant to the laws of Shabbat called "Dabar She’eno Mitkaven," which refers to a situation where one performs an essentially permissible act that could result in a Melacha (forbidden act). If the Melacha will inevitably result from the act in question, then the situation is called "Pesik Resheh," and it is forbidden to perform the act. A classic example is a case where one forgot to turn off the refrigerator light before Shabbat. If he opens the refrigerator door, the light will automatically turn on. Therefore, even though he has no interest in turning on the light, and his intention is solely to open the door so he can access something in the refrigerator, he may not open the door. Since opening the door will inevitably cause the light to turn on, it is forbidden. The example of this rule given in the Gemara is removing a chicken’s head to give it to a child as a toy. Even though one’s intent is to access the head, and not to kill the chicken, this is forbidden, since removing the head will inevitably result in killing the chicken, which is forbidden on Shabbat. The expression used by the Gemara in reference to this concept is "Pesik Resheh Ve’lo Yamut" – "If its head is severed, will it not die?"
However, even though it is forbidden for one to perform an act of "Pesik Resheh" on Shabbat, it is permissible to ask a non-Jew to perform such an act. For example, in the olden days people would often place pots of food in simmering coals to keep the food warm. It was forbidden to remove the pot from the coals on Shabbat, as the shifting of the coals would cause them to be kindled, in violation of Shabbat. However, it was permissible to ask a non-Jew to remove the pot from the coals, since the person’s intent was not to ignite the coals, but rather to retrieve the pot. This is thus a situation of "Pesik Resheh," which may be done through a gentile.
A modern application of this rule would be asking a gentile to remove food from an oven that turns on automatically when the door is opened and cold air enters the oven. Although one is not allowed to open such an oven on Shabbat, as this will inevitably cause the motor to turn on, one may ask a non-Jew to open the oven door, since this is a situation of "Pesik Resheh," as one has no intention to cause the motor to turn on.
Likewise, in the aforementioned case of the refrigerator light which one forgot to disable before Shabbat, it would be permissible to ask a gentile to open the refrigerator door anytime during Shabbat one wishes to take something from the refrigerator. Since the intention is simply to open the door, and not to turn on the light, this qualifies as "Pesik Resheh" and it may be done through a non-Jew.
Another example is the Shabbat prohibition against carrying an oil lamp. It is forbidden to carry an oil lamp on Shabbat because as one walks, he inevitably moves some oil closer to the flame, which has the effect of enhancing the flame, in violation of Shabbat. However, since one has no intention of moving the oil as he walks, this is a situation of "Pesik Resheh" and it is thus permissible to ask a gentile to carry the lamp to provide light as one walks.
This Halacha also affects the situation of somebody who forgot a necessary item in his car before Shabbat, such as his Tallit or drinks for the Shabbat meal. He may not open the car door to retrieve the item, because this will cause the light in the car to turn on. However, it is permissible to ask a non-Jew to retrieve the item, since he has no intention to turn on the light, and the intention is solely to gain access to the item inside the car. (Of course, this assumes that there is an Erub and there is thus no prohibition involved in carrying the item from the car to the house.)
Finally, it is permissible to ask a non-Jew to turn on the hot water faucet on Shabbat. Halacha forbids turning on the hot water faucet on Shabbat, because when hot water leaves the boiler, cold water enters the tank and is heated. And thus even though one has no intention of heating new water when he turns on the faucet, it is nevertheless forbidden to turn on the hot water, as this constitutes "Pesik Resheh." However, one may ask a non-Jew to turn on the hot water for him, in accordance with the general rule allowing "Pesik Resheh" through a non-Jew. (We speak here of using warm water for washing one’s hands or face; a separate prohibition forbids bathing and showering on Shabbat.)
Summary: It is forbidden on Shabbat to perform an act that is in itself permissible, if it will inevitably result in a forbidden act, such as opening a refrigerator or car door, since this will cause the light to go on. One may, however, ask a gentile to perform the act in such a case.
(Based on Hacham Ovadia Yosef's Hazon Ovadia, vol. 3, p. 430)