Created
September 6, 2021 12:02
-
-
Save zfhrp6/ff0a71c12aad52081c34e2eba872a39e to your computer and use it in GitHub Desktop.
toggle listeinng line-in device.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Main: | |
def toggle(self, *args, **kwargs): | |
from pywinauto import Desktop, Application | |
Application().start('Rundll32.exe Shell32.dll,Control_RunDLL Mmsys.cpl,,1') | |
app = Application(backend='uia').connect(path='rundll32.exe', title='サウンド') | |
sound = app.window() | |
children = sound.child_window( | |
title='次のオーディオ録音デバイスがインストールされています:', control_type='List' | |
) | |
# line_in = list(filter(lambda e: 'Line In' in e.window_text(), children))[0] | |
line_in = sound.child_window( | |
title='Line In', control_type='ListItem' | |
) | |
line_in.click_input(double=True) | |
prop = sound.child_window( | |
title='Line Inのプロパティ', control_type='Window' | |
) | |
prop.child_window( | |
title='聴く', control_type='TabItem' | |
).click_input() | |
prop.child_window( | |
title='このデバイスを聴く', control_type='CheckBox' | |
).click_input() | |
prop.child_window( | |
title='OK', control_type='Button' | |
).click_input() | |
sound.child_window( | |
title='OK', control_type='Button' | |
).click_input() | |
if __name__ == '__main__': | |
Main().toggle() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment