Skip to content

Instantly share code, notes, and snippets.

@zfhrp6
Created September 6, 2021 12:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zfhrp6/ff0a71c12aad52081c34e2eba872a39e to your computer and use it in GitHub Desktop.
Save zfhrp6/ff0a71c12aad52081c34e2eba872a39e to your computer and use it in GitHub Desktop.
toggle listeinng line-in device.
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