It seems that in a defensive deployment cannon could be used against approaching forces, but that moving and erecting a cannon in a forward offensive position would be slow, difficult, and dangerous. How was this done? Could artillery be moved forward at the same rate as marching infantry?
All the way back in the 17^th century Swedish king Gustavus Adolphus sort of revolutionised the usage of artillery by equipping his infantry with light and mobile pieces for direct support. Then during the latter half of the 18^th century we have another revolution in artillery, thanks to the French artillery officer Jean-Baptiste Vaquette de Gribeauval, who introduced a new and vastly more efficient system of production, the Gribeauval system, which suddenly cut the weight of cannons by about half. In England the same system was pioneered by Dutch painter and master founder Jan Verbruggen, who invented a special horizontal boring machine for the Royal Foundry. By changing from casting a full cannon including bore with all its imperfections, artillery was now cast as a solid piece and the bore drilled later, which allowed bores better fitted to the munition, making the guns more effective, in turn meaning they could be made smaller and still keep their old power.
Heavy foot artillery pieces (12 and 9-pounders) still were a hassle to move, requiring lots of horse- and manpower and favorable terrain and/or weather. But those were just the big guns for dominating the battlefield. Ideally your army carried all sorts of light support artillery.
There was horse artillery, which was light enough so its crew could ride on the drawing horses, thus speeding up the deployment massively. They could move together with cavalry, unlimber in about a minute and provide support fire to break up enemy formations so the cavalry could pick them off. Very efficient for small scouting parties ahead of the army or in the rear guard covering a retreat.
You also had battallion guns, small 3 and 6-pounders that were light enough to move together with infantry. This is a British Grasshopper, a 3-pounder artillery piece that was either pulled by a single horse or just its 8 men strong crew alone if needed, with a convenient ammo supply right in that box behind the barrel. Very convenient for deployment even in bad terrain.
Not to mention mortars (not necessarily that 12-inch one, but smaller bores) and field howitzers that were considerably lighter to move than most foot artillery.
To add to /u/notamacropus, generally artillery was not used offensively during the 18th century. This was due to the weight of artillery and the difficulty of moving them.
In general, most nations employed civilian moving teams to move and deploy artillery, so once they were placed, they were generally placed for the day as civilians wouldn't have the courage to stand up and move artillery when under counter battery fire or musket fire and the gunners alone wouldn't be able to move it own their own. So moving artillery during a battle was generally out of the question. This would change during the Revolution and Napoleonic Wars when the French created their own service for the movement of artillery and wagons.
As mentioned, the weight of the guns themselves would keep them from being used in offensive warfare. The Valliere system used heavy artillery that was much heavier than the Gribeauval system that would replace it, further the carriage systems made movement and targeting harder than the Gribeauval system. As a result, artillery would be considered a supporting arm rather than a primary arm up until the Revolution.
Further, there was little interest in making a supporting arm a primary attack method. Artillery wasn't a noble field of military service. Generally the artillery was the home for the technically minded, proto-egalitarian, and sometimes middle class (read as non-noble) rather than the noble dominated cavalry or the honorable infantry. So very little importance was put into the artillery.
However, there are exceptions; Frederick would be the first to create a horse artillery company who would dash forward to the lines, unlimber their guns, pour a few rounds of canister shot into the enemy and dash away before they could be in danger. He would take advantage of new methods of artillery design that would make the guns lighter but also saw their use in offensive warfare.
Generally, artillery wasn't deployed offensively as a result of technological and social aspects.
The only time cannon were really used in an offensive role was against fortifications. The defending cannon (6, 9 and 12, pdrs) and attacking cannon would duel it out while the infantry dug the saps below until they got to the lip of the outer ditch at which time they would wheel the heavier cannon (25 pdrs) up to blast holes in the revetment of the forts curtain or bastion provided all the defending guns had been dismounted or destroyed on that face. Once a breach had been made the infantry would storm it and force a capitulation.