如何在AutoHotkey2中当热键不符合条件时发送热键自身

huangapple go评论44阅读模式
英文:

How to send hotkey self when hotkey doesn't qualify in autohotkey2

问题

这段代码的默认操作是在未满足任何条件时发送特定的热键。如果没有任何条件匹配,代码会执行以下操作:

^p:: {
    appName := GetappName()
    switch appName {
        case "Code":
            Send "^+p"
        default:
            Send "^p"
    }
    return
}

^n:: {
    appName := GetappName()
    switch appName {
        case "Obsidian":
            Send "!n"
        case "Code":
            Send "^!#n"
        default:
            Send "^n"
    }
    return
}

在这两个快捷键绑定中,如果应用程序的名称既不是"Code"也不是"Obsidian",那么会执行"default"部分,它会发送"^p"和"^n"这两个默认的热键。

英文:

I want to send the hot when the conditions are met, and send the hotkey itself when none of the conditions are met,like this:

^p:: {
    appName := GetappName()
    switch appName {
        case "Code":
            Send "^+p"
        default:
            Send "^p"
    }
    return
}

^n:: {
    appName := GetappName()
    switch appName {
        case "Obsidian":
            Send "!n"
        case "Code":
            Send "^!#n"
        default:
            Send "^n"
    }
    return
}

How is this code in default?

答案1

得分: 0

已解决,可以通过切换回 #hotif 来使用,之前无法使用是因为我用 Powertoys 交换了 Ctrl 和 Caps 键,现在可以使用 $ 或 #hotif,谢谢。

英文:

It has been solved, it can be used by switching back to #hotif, it didn't work because I swapped ctrl and caps with powertoys,now i can use $ or #hotif ,thanks

huangapple
  • 本文由 发表于 2023年3月15日 19:03:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/75743853.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定