python3语音控制电脑_python语音控制电脑_uusee全屏

# -*- coding: utf-8 -*-

import time

import speech

import subprocess

import win32com.client

from zoomUUSee import zoomUUSee

"""author:alex8224 天气冷了,全屏麻烦,随后写的,方便偷懒"""

cmdDict=None

wsh=win32com.client.Dispatch("WScript.Shell")

def voiceCallBack(phrase,listene):

funcptr=cmdDict[phrase]

if funcptr:

funcptr()

def goodbye(listener):

listener.stoplistening()

def listenSong():

#subprocess.Popen("D:\Program Files\KuGou\KuGou2010\KuGoo.exe")

pass

def stopSong():

"""发送ctrl+alt+s"""

wsh.SendKeys("^%{F5}")

def nextSong():

"""发送ctrl+alt+right"""

wsh.SendKeys("^%{RIGHT}")

def prevSong():

"""发送ctrl+alt+left"""

wsh.SendKeys("^%{LEFT}")

def plusSound():

"""发送ctrl+alt+up"""

for i in range(5):

wsh.SendKeys("^%{UP}")

time.sleep(.5)

def jianSound():

"""发送ctrl+alt+down"""

for i in range(5):

wsh.SendKeys("^%{DOWN}")

time.sleep(.5)

def shutdownPC():

stopSong()

subprocess.Popen("shutdown -s -t 180")

def cancelshutdown():

subprocess.Popen("shutdown -a")

def myPC():

subprocess.Popen("explorer c:\\")

if __name__ == "__main__":

global cmdDict

cmdDict={u'全屏播放':zoomUUSee,u'再见':goodbye,u'听歌':listenSong,u'睡觉啦':shutdownPC,u'大点':plusSound,u'小点':jianSound,u'下':nextSong,\

u'上':prevSong,u'取消':cancelshutdown,u'不听':stopSong}

listener=speech.listenfor(cmdDict.keys(),voiceCallBack)

while listener.islistening():

time.sleep(1)

# -*- coding: utf-8 -*-

import win32api,win32gui,win32con,time

def zoomUUSee():

title=u"UUSee网络电视2008".encode("gbk")

handle=win32gui.FindWindow(None,title)

if handle:

win32gui.SetForegroundWindow(handle)

time.sleep(1)

(left,top,right,bottom)=win32gui.GetWindowRect(handle)

(leftPos,topPos)=(right-left)/2+left,top+200

win32api.SetCursorPos((leftPos,topPos))

win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0,0,0)

time.sleep(.5)

win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0,0,0)

win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0,0,0)

time.sleep(.5)

win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0,0,0)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值