Пример #1
0
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)
Пример #2
0
def main(filename):
	pid = startGoldwave()
	print "goldwave started with pid %d to process file %s" % (pid,filename)
	selectionFunc = makePIDFilter(pid)
	hgw = findTopWindow(wantedText="GoldWave", wantedClass="TMainForm", selectionFunction = selectionFunc, maxWait = 5, retryInterval = 0.3)
	activateMenuItem(hgw,("File",1))
	hos = findTopWindow(wantedText="Open Sound", wantedClass="#32770",selectionFunction=selectionFunc,maxWait=5,retryInterval=0.3)
	editArea = findControl(hos,wantedClass="Edit")
	setEditText(editArea,filename)
	selectfunc = lambda x: winGuiAuto._normaliseText(win32gui.GetWindowText(x)) == "open"	
	openButton = findControl(hos,wantedText="&Open",wantedClass="Button", selectionFunction = selectfunc)
	clickButton(openButton)

	time.sleep(5)
	while True:
		try:
			c = findControl(hgw, wantedText = os.path.basename(filename), wantedClass = "TWaveView", maxWait=1, retryInterval=1)
			break
		except winGuiAuto.WinGuiAutoError, err:
			if str(err).startswith("No control found for"):
				print "waiting for file to load.. sleeping for 5 seconds"
				time.sleep(5)
				#make this more robust by making sure the Audio decompression progress bar thingie is still on ?
				pass
			else:
				raise
Пример #3
0
    def upload_photo(self, imgpath):
        u'''
        @处理图片上传WINDOWS窗口问题

        @使用方法:传入图片路,格式为:r'X:\XX\XX.XXX'
        '''

        driver = self.driver

        if not os.path.exists(imgpath):
            return False

        if driver.name == 'chrome':
            title = u'打开'
        elif driver.name == 'Firefox':
            title = u'文件上传'
        elif driver.name == 'internet explorer':
            title = u'打开'
        else:
            title = u'打开'
        try:
            #form=findTopWindow(wantedClass="#32770")
            form=findTopWindow(wantedText=title.encode("gb2312"))
            button=findControl(form,wantedText=u'打开'.encode("gb2312"))
            editbox=findControl(form,wantedClass='Edit')
            setEditText(editbox,[imgpath])
            clickButton(button)
        except:
            print traceback.format_exc()
            return False
        else:
            return True
Пример #4
0
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)
Пример #5
0
def quitGoldwave(hgw):
	activateMenuItem(hgw,("File",10))
	hc = findTopWindow(wantedText="Confirm",wantedClass="TMessageForm",selectionFunction=makePIDFilter(getPIDfromHandle(hgw)), maxWait=5, retryInterval=0.3)
	noButton = findControl(hc,wantedText="No",wantedClass="TButton",maxWait=5, retryInterval=0.3)
	clickButton(noButton)