They were fighting very hard, but independent rule only started after panipat and the gains consolidated by Ranjit Singh from 1805-20 and ended in 1849, around 40 years. With due respects to those who died during smaller and bigger massacres( including 1746 and 1762) Sikhs were relentlessly fighting and rebelling, but were not the rulers during that timeframes.
Khalsa was created in 1699 Visakhi day.
Guru Gobind Singh attained martyrdom in 1705.
Aurungzeb passed away in 1707.
Banda Bahadur defeated the mughal governor of Sarhind on 12th May 1710 and took over the large area of Punjab between Delhi and Lahore declaring his independence asking for only 10% tax or join Khalsa forces. He advanced towards Lahore but couldn't break upon the fort.
Upto this point the population of Khalsa was not more than 100,000.
In December 1710 the Mughal emperor passed out a writ to "kill the worshippers of Nanak (the Sikhs), wherever they were to be found." (Nanak Prastan ra Har ja kih bayaband baqatl rasanand)., along with rewards for the head of Sikhs.
In 1716 Banda Bahadur was captured and executed along with 800 Sikhs for not converting to Islam at Mehrauli, Delhi.
In 1720s. The Sikhs who saw the martyrdom of Banda Bahadur organized themselves into two groups with over all leadership of Jathedar Kapur Singh Virk. Jathedar Kapur Singh Virk was founder of the state of Kapurthala. In 1750s Kapur Singh passed on the leadership of Sikhs to Jassa Singh Ahluwalia and then later Jassa Singh Ahluwalia organized 13 Misls that ruled the area from River Sindh to River Ganga.
1. Phulkian Misl Patiala
Nabha Rajpura, Bathinda, Sangrur, Tohana, Sirhind, etc.
2. Ahluwalia Misl Kapurthala Nurmahal, Talwandi, Phagwara,Kana Dhillon, Hariana,etc.
3. Bhangi Misl Amritsar Tarn Taran, Gujrat, Wazirabad, Sialkot, Chiniot, Rawalpindi, Jhelum, Sialkot, Jhang, Bhera, Lahore, Hasan Abdal, Bhairowal, Majitha, Bedian, Bulaki, Bazidpur, Shahpur, etc.
4. Kanheya Misl Sohian Ajnala,Sohiau,Nag,,Surdaspur, Dera Baba Nanak,
Kalanaur, Pathankot, Sujanpur
5. Ramgarhia Misl Sri Hargobindpur Batala,Jukerian, Qadian, Ghoman, Mukerian, Dasua, Kalanaur, Zahura, Mattewal, Shahpur Kandi, Dinanagar, Riarki, Urmur Tanda, Sanh, Miani Bhagupurian, Garhdivala, Begowal,etc.
6. Singhpuria Misl Jalandhar Haibatpur,Patta, Bunga, Banga, Bela, Attal Garh, Adampur, Singhpura, Bhareli, Kandhola, Manauli, Bharatgarh, etc.
7. Panjgarhia Misl[note 2] Bhunga Nawashahr,Burka,Bassisn, Pindorian,Hoshiarpur,
Kathgarh,Bhangs
8. Nishanwalia Misl Ambala. Firozpur,etc.
9. Sukerchakia Gujranwala Kunja,Ladhe Wala Waraich, Ramnagar, Eminabad, Sodhra, Qila Didar Singh, Rohtas, etc.
10. Dallewalia Misl Rahon Nakodar,Talwan ,Badala, Rahon, Philluar, Goraya, Apra, Mau, Bilga, etc.
11. Nakai Misl Chunian Baharwal, Khem Karan, Khudian, Jamber kalan etc.
12. Shaheedan Misl Shahzadpur Talwandi Sabo, Much of Northern Ambala.
Shaheedan Misl and Nishaanwalia Misl got together and invaded Delhi in march 1783 (18 years after Abdali's invasion) and got Mughals to build Sikh historical gurdwaras in Delhi (Guru Nanak, Guru Har Kishen, Guru Tegh Bahadur martyrddom, etc).
In 1739 Nadir Shah attacked India and fought a battle between Panipat and Karnal. Sikh misls harassed him and freed many enslaved women. Jassa singh Ahluwalia was even given a name "Baandi Chor" i.e. "Women Slave stealer" by Mughals. Just in one raid he freed 2200 women. Many of these women didn't want to go back to their parents/families and they lived at Gurdwara Kaulsar at Amritsar., Many of these girsl became Khalsa and participated in the struggle.
As soon as Nadir Shah left India Sikhs occupied the fort of Lahore., Abdali in 1751 attacked India and sikhs retreated. Sikhs never knew how to fight a "real battle" as they only had fought "Guerilla battles". They decided to keep on the struggle in Guerilla warfare.
Abdali attacked three more times till 1754 and then he attacked and occupied Delhi installed Alamgir II as mughal emperor wedded his son to the daughter of Alamgir II and he himself wedded the daughter of Mohammad Shah Rangila. Returning from this occasion he destroyed Golden Temple slaughtering the cows in the Sarovar and filling it up with the debris. Baba Deep Singh along with a farmer army of 10000 Sikhs attacked Abdali at Golden Temple (during Diwali) and attained martyrdom at Golden Temple. After Abdali was gone India sikhs rebuild the Golden Temple.
Peshwa Baliji rao sent Raghunath Rao to ouster Tamur Shah from mughal court and thus whole of North India came under marathas in 1757.
Abdali declared Jihad against Marathas and thus third battle of panipat was fought in January of 1761. Sikhs were still guerilla fighters on the side of Marathas. Leader of Phulkian Misl (Congress Amarinder Singh ancestors) let Abdali passed through his territory and he was declared "out of Khalsa".
What Ranjit Singh the leader of Shukarchakia Misl did was that he got all Misls together and stopped the usage of Guerilla warfare tactics and started using modern warfare (both French and British).
Mughals only ruled in the cities of Delhi, Sarhind, Lahore, Peshawar, malerkotla and small jagirdars like Patti (close to amritsar) but their rule of law was effectively 0% after Banda Singh Bahadur's rule from 1710-1716. Farmers just didn't paid any taxes to Mughals and when Nadir Shah or Abdali attacked India they harassed the foreigners through guerilla tactics. A very useful tactic was named "Dhai Phat" i.e. 2 and a 1/2 strikes.
Two groups (25-50 horsemen) of cavalry Sikhs would be charging from the either side of the enemy forces first with guns and then cutting them through going across. That is one strike. They they will fill up their guns and come back doing the same at some other point of the enemy forces that is strike two. Then both groups would strike again meeting in the middle forming one group and running away that is 1/2 strike. They used this against Mughals, Abdali and Nadir Shah.