Here's a concept inspired by this related answer -- imagine an airplane that is essentially a sailplane with an electric motor for added assistance. Normally, once a sailplane has climbed to the top of a thermal updraft, there is no way to extract any more energy from that updraft. However, our new concept sailplane will use the propeller and motor as a generator to charge a battery while climbing, accepting a lower climb rate for the sake of extracting more energy from the thermal updraft. The same can be done in wave lift, etc. Wave lift in particular would be conducive to simply remaining at a fixed altitude where the updraft is strongest, and extracting energy with the generator at a very high rate, until the batteries are fully charged.
The purpose of our new concept aircraft will be to make very long-range flights-- potentially trans-continental or trans-global, and potentially spanning multiple days-- using no energy other than atmospheric energy. This could be done for the sake of competition (flying against other similar aircraft), or to attract publicity to various causes, or simply to advance the state of aeronautical technology. A new category of FAI record might be appropriate.
In order to meet the stated goal, take-off would be conducted with the batteries containing only enough charge to climb to a limited altitude representative of a normal aerotow, or else the batteries would be drained after the initial climb before proceeding with the rest of the flight.
A logical variant would be to also include solar panels, in which case the goal would be to fly using only external, natural energy harvested during the course of the flight, be it "direct" solar, or "indirect" solar (i.e. atmospheric). Or if the "harvested during the course of the flight" were dropped, the batteries could be fully charged (via solar energy) before takeoff and freely used as needed. Another variant of the concept would omit the solar panels, but would fully charge the batteries before takeoff using energy harvested from wind turbines.
This thought experiment should make it clear that the answer to the original question--
Can an aircraft use ram air to generate power while flying?
Is "yes".