小编aap*_*art的帖子

autohotkey 如何检测您在哪个虚拟桌面上?

嗨,我是自动热键(以及一般编程)的新手,我想编写一个脚本,让我可以方便地切换到特定桌面。例如,在我的脚本中 Capslock+3 切换到桌面 3。

正如您所看到的,或者如果您尝试一下,它并不是很健壮。该脚本只知道一个与真实桌面号码不同的桌面号码。例如,如果您在桌面 4 上运行脚本,脚本仍然以桌面设置为 1 开始,您必须按 Caps+4 然后按 Caps+1 以将其设置为正确的方向。如果另一个桌面上有一个闪烁的窗口并且您单击它,它会切换到该桌面,而脚本仍然认为您在前一个桌面。

我已经搜索了 autohotkey 可以检测您在哪个桌面上的方法,但找不到任何方法。

任何人都可以提供有关如何改进它的任何提示吗?谢谢!:D

SetCapsLockState, AlwaysOff
desktop = 1

Switch(d)
{
    global

    ;Determine how far away the desired desktop is from current one
    press := (d-desktop)

    desktop = %d%

    ;Determine which direction to switch desktops and stop script if already on current desktop
    If press < 0
        direction = Left
    else if press > 0
        direction = Right
    else
        return

    press := Abs(press)

    Loop, %press%
    {
        SendInput, …
Run Code Online (Sandbox Code Playgroud)

desktop autohotkey

3
推荐指数
1
解决办法
1216
查看次数

标签 统计

autohotkey ×1

desktop ×1