通过ahk的uia库可以很简单实现:
以下是适配qq音乐 21.21.3025.0324 版本的脚本
uia库(v1)可以从网上找到
#Include lib\UIA_Interface.ahk
SetTitleMatchMode, 2
global UIA := UIA_Interface()
run "C:\Program Files (x86)\Tencent\QQMusic\QQMusic.exe"
winwait,ahk_class TXGuiFoundation ahk_exe QQMusic.exe,,桌面歌词
WinActivate,ahk_class TXGuiFoundation ahk_exe QQMusic.exe,,桌面歌词
WinWaitActive,ahk_class TXGuiFoundation ahk_exe QQMusic.exe,,桌面歌词
el := WinExist("ahk_class TXGuiFoundation ahk_exe QQMusic.exe",,"桌面歌词")
el := UI(el)
Do_Click(el)
ExitApp
UI(el){
WinActivate, ahk_id %el%
WinWaitActive, ahk_id %el%
el := UIA.ElementFromHandle(el)
return el
}
Do_Click(el){
loop, 10
{
try {
el := el.waitelementexist("ControlType=Text AND Name='剌'",,2,,4000)
break
} catch e{
Sleep, 100
}
}
loop, 10
{
try {
el.ControlClick()
break
} catch e{
Sleep, 100
}
}
}