Python:获取主卷windows 7
我正在尝试构建一个应用程序,用户只需将鼠标滚动到windows声音图标上即可更改音量。Linux用户已经熟悉这一点。 我将问题分为以下几个步骤:Python:获取主卷windows 7,python,windows,audio,Python,Windows,Audio,我正在尝试构建一个应用程序,用户只需将鼠标滚动到windows声音图标上即可更改音量。Linux用户已经熟悉这一点。 我将问题分为以下几个步骤: 1.) Get current audio device list using a python api. 2.) Control the master voulme using the api. 3.) Attach a mouse event listener to it.(Sorry i am from Java background).
1.) Get current audio device list using a python api.
2.) Control the master voulme using the api.
3.) Attach a mouse event listener to it.(Sorry i am from Java background).
4.) Get mouse event listener method to do my work .
请推荐一个合适的python API来完成我的任务
这是解决问题的正确方法还是有更好的方法。为此,您可以使用PyWin32或ctypes。 你的方法很好。 下面是一个使用pywin32的鼠标的简单示例:
import win32api
import win32con
def click(x,y):
win32api.SetCursorPos((x,y))
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x,y,0,0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,x,y,0,0)
click(10,10)
这里有一个类似的ctypes:
import ctypes
ctypes.windll.user32.SetCursorPos(10, 10)
ctypes.windll.user32.mouse_event(2, 0, 0, 0,0)
ctypes.windll.user32.mouse_event(4, 0, 0, 0,0)
Ctypes有时比较难理解,在MSDN上调试需要花费大量时间,但速度惊人。请说明此问题被否决的原因。