To achieve efficient carbon capture, utilization, and storage, it is necessary to separate CO2 from the atmosphere. In an attempt to move towards selective separation of CO2, some of us have shown that ionic liquids (ILs) can be efficiently used to separate CO2 and H2S from CH4 and H2O. In the present work, we perform Density Functional Theory and Molecular dynamics simulations for four different ILs: [DBNH][1,2,3-triaz], [DBNH][1,2,4-triaz], [DBUH][1,2,3-triaz] and [DBUH][1,2,4-triaz]. DFT calculations have unveiled the additional selective character of H2S with respect to CO2. Whereas CO2 binds to the nitrogen of the anionic moiety of the IL forming a new CN bond, H2S transfers a proton to one of the nitrogen atoms of the IL with the consequent generation of a HS- anion. Radial distribution function analysis shows the presence of hydrogen bonds between cation and anion in neat ILs as well in presence of gases. Hydrogen bond analysis shows higher number of hydrogen bonds in the ILs between cation and the [1,2,3-triaz] anion as compared to [1,2,4-triaz] anion. Molecular dynamics simulations also show that these ionic liquids have stronger interaction with CO2 and H2S as compared to CH4. Overall, our study confirms the usage of studied ILs to efficiently capture CO2 and H2S.