I was reading about the battle of midway and one thing that struck me as weird was the fact that army B-17s were deployed against the Japanese fleet. I looked into this idea further and learned about an entire class of patrol aircraft such as the PB4Y-2 Privateer, Fw-200 condor to name a few. My understanding is these planes would primarily hunt submarines and merchant shipping, but could engage warships like the battle of midway I mentioned earlier. I was wondering how exactly these planes would go about attacking such a target? How effective were they in this role? I can't imagine it was easy, the maneuvering of the ships and the difficulty maneuvering the bomber to hit the ships, compounded by the fact that they are taking varying amounts of fire based on how high up they were flying. I'm just having trouble wrapping my head around how they would accomplish this often enough to make it worth attempting?
B-17s were used in the defense of Midway, albeit more because they were there and able to be used than because they had any realistic hope of hitting warships from high altitude. At least one B-17 strike was launched against the Japanese transport force, where they may have been relatively more effective, and then diverted to strike the Japanese carriers, but the B-17s were ineffective as strike planes. The way they would attack is to approach at very high altitude and drop their bombs at the predicted spot the Japanese ships would be when the bombs fell; the Japanese fleet evaded the bomb attacks by waiting for them to be released and then putting the helm hard over -- here's a picture of Akagi with its plane-guard destroyer following evading an attack.
The Army also used B-26 Marauder medium bombers, to launch torpedo attacks at lower altitude -- one B-26 nearly crashed into Akagi's bridge, which would have decapitated the Japanese leadership at one stroke, and certainly contributed to Nagumo's somewhat distracted lack of situational awareness as the battle went on.
What the Army bombers did contribute was to add yet another threat for Nagumo to worry about, and force his carriers to maneuver to avoid being hit (which complicated CAP launch and recovery, as well as rearming of planes belowdecks). Japanese Zeroes had to climb to high altitude to attack the B-17s, which was not a preferred altitude for them, and then recover, re-load and re-launch to meet new threats. The repeated, if disorganized, attacks from Midway did force the Japanese carriers out of their typical steaming formation, and made life difficult for Nagumo and his subordinates, so that when he learned of an American carrier force on his flank he had CAP scattered all over the sky, and not many options to rescue his tactical situation.
It's pretty easy to see from the math why level bombing from medium and heavy bombers was almost completely ineffective against maneuvering ships during the war. A bomb dropped from 10,000 feet takes about one minute to fall to Earth; during that same time an object moving at 30 knots (typical for an aircraft carrier or fast battleship) will cover a full kilometer. So even a slight course correction as soon as the bombs are away will take the target ship well out of danger.
However, multi-engine bombers (especially German ones) did prove effective against shipping because of their ability to carry powerful guided munitions like the Fritz-X, which had numerous anti-shipping successes including the sinking of the Italian battleship Roma and the serious damaging of the battleships Italia and HMS Warspite, among others.