def saveAsWave(hgw,filename): activateMenuItem(hgw,("File",7)) # save selection as menu item pidFunc = makePIDFilter(getPIDfromHandle(hgw)) hssa = findTopWindow(wantedText="Save Sound As",wantedClass="#32770",selectionFunction=pidFunc,maxWait = 5, retryInterval=0.3) editArea = findControl(hssa,wantedClass="Edit") setEditText(editArea,os.path.splitext(filename)[0]) def selectFunc(x): if win32gui.GetClassName(x) != "ComboBox": return False if getComboboxItems(x) and getComboboxItems(x)[0] == "Wave (*.wav)": return True return False hsat = findControl(hssa,wantedClass="ComboBox",selectionFunction=selectFunc) selectComboboxItem(hsat,"Wave (*.wav)") htcsf = findControl(hssa,wantedClass="TCustomSaveForm") hcb = findControl(htcsf,wantedClass="TComboBox") options = getComboboxItems(hcb) selectComboboxItem(hcb,"PCM signed 16 bit, mono") waveFile = os.path.splitext(filename)[0] + ".wav" try: if os.path.exists(waveFile): os.remove(waveFile) print "old wav file removed" except: print "error in removing file. do error logging/reporting here" saveButton = findControl(hssa,wantedClass="Button",wantedText="Save") clickButton(saveButton) waitToFinish(wantedText="Processing Saving",selectionFunction=pidFunc)
def doNoiseReduction(hgw): activateMenuItem(hgw,("Effect",4,3)) selectFunc = makePIDFilter(getPIDfromHandle(hgw)) hnr = findTopWindow(wantedText="Noise Reduction", wantedClass="TEffectWrapper",selectionFunction = selectFunc, maxWait=5, retryInterval=0.3) hpr = findControl(hnr,wantedText="Presets",wantedClass="TGroupBox") hcb = findControl(hpr,wantedClass="TComboBox") cl = getComboboxItems(hcb) selectComboboxItem(hcb,"Hiss removal") okButton = findControl(hnr,wantedText="OK",wantedClass="TButton") clickButton(okButton) waitToFinish(wantedText="Processing Noise Reduction",selectionFunction=selectFunc)
def selectFunc(x): if win32gui.GetClassName(x) != "ComboBox": return False if getComboboxItems(x) and getComboboxItems(x)[0] == "Wave (*.wav)": return True return False