用autoIt对应的python库AutoItLibrary操作键盘很方便,记录一下,备忘。模拟Ctrl+f的操作,使windows Media Player自动播放下一首歌曲
from win32con import *
from win32com.client import Dispatch
def enter_game():
AutoItX = Dispatch( "AutoItX3.Control" )
# Block All Input
AutoItX.BlockInput( 1 )
AutoItX.WinActivate( 'Windows Media Player','')
AutoItX.Send( "{CTRLDOWN}b{CTRLUP}" )
AutoItX.Send( "{LWINDOWN}{DOWN}{LWINUP}" )
# Unblock input
AutoItX.BlockInput( 0 )
if __name__ == "__main__":
#mouse_event (MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0 )
next_music()