小编Sup*_*der的帖子

在未聚焦时将键盘输入发送到 Spotify

我有一个 AHK 脚本(如下),它在后台向 Spotify 桌面应用程序全局发送各种命令以执行各种操作,但是我玩了一个 MMO,它具有始终运行的反作弊功能,当它检测到 AHK 时会关闭游戏,因为人们可以将它用于宏等。

; "CTRL + Alt + UP"  Increase the volume.
^!Up::
DetectHiddenWindows, On
WinGet, winInfo, List, ahk_exe Spotify.exe
Loop, %winInfo%
{
    thisID := winInfo%A_Index%
    ControlFocus , , ahk_id %thisID%
    ControlSend, , ^{up}, ahk_id %thisID%
}
return
Run Code Online (Sandbox Code Playgroud)

反作弊不会检测/关心 C# 程序/应用程序,因此我将代码移植到 C# 并找到了一种方法将命令发送到 Spotify 应用程序以通过SendMessage执行我想要的大部分内容:

private const int WM_KEYDOWN = 0x0100;
private const int WM_KEYUP = 0x0101; //Tried using these to no avail
private const int WM_KEYSYS = 0x0104;
private const int WM_ACTIVATEAPP …
Run Code Online (Sandbox Code Playgroud)

c# autohotkey sendkeys spotify

6
推荐指数
1
解决办法
513
查看次数

标签 统计

autohotkey ×1

c# ×1

sendkeys ×1

spotify ×1