Four series of thin films have been deposited as the precursory sources of Zn(CH3COO)2, Mg(CH3COO)2, NH4CH3COO and AlCl3 aqueous solutions using ultrasonic spray pyrolysis (USP) method. The crystalline structure, morphology images, electrical, optical properties of the films are characterized by x-ray diffraction (XRD), field emission-scan electron image (FE-SEM), Hall-effect measurement and photoluminescence (PL). From the XRD patterns and SEM images, we can see that all the films present good crystallinity and surface uniformity. Hall-effect measurement results indicate that ZnO is n-type, while N-Al codoped ZnO and N-Al codoped Zn1-xMgxO exhibit p-type conduction. Temperature dependent of electrical measurement is carried out from 300K to 500K, then the conductive mechanism and carriers scattering are analysed. Furthermore, the photoluminescence peak of Zn1-xMgxO is tuned into shorten wavelength than pure ZnO (λ＝379－352＝27nm), and also the same phenomenon of the p-type Zn1-xMgxO film exhibits blue-shifted behavior from 378nm to 356nm compared with p-type ZnO film (λ＝378－356＝21nm). In other word, the p-type Zn1-xMgxO film shifts to a shorter wavelength of 356 nm while maintaining excellent electrical performances.