上的任意键AutoHotkey的运行程序 [英] AutoHotKey run program on any key

查看:482
本文介绍了上的任意键AutoHotkey的运行程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想运行一个程序时,任何键都在AutoHotkey pssed $ P $

是这样的:

 任意键::运行,D:\\我的\\程序\\到\\运行\\上\\任何\\ key.bat

EDIT2:
这code为正常使用:

  #InstallKeybdHookSetTimer的,任意键pressed,100任意键pressed:
    如果(A_TimeIdlePhysical&小于100){
        运行D:\\我的\\程序\\到\\运行\\上\\任何\\ key.bat
}^!P ::暂停


解决方案

一个简单的解决方案:

  #InstallKeybdHook;这必须在你的脚本开始被称为任意键pressed();返回1,如果任何键盘按键为pressed,否则返回0
{
    如果(A_TimeIdlePhysicalα25)
        返回1返回0
}

请注意这个函数将返回1,如果任何键pressed或被不放,所以更改code正确。

会发生什么事;在 #InstallKeybdHook A_TimeIdlePhysical 的行为改为只寻找键盘事件。

I'd like to run a program when any key is pressed with AutoHotKey

Something like:

AnyKey::Run, D:\my\program\to\run\on\any\key.bat

EDIT2: This code is working perfectly:

 #InstallKeybdHook

SetTimer, AnyKeyPressed, 100

AnyKeyPressed:
    if( A_TimeIdlePhysical < 100 ){
        Run, D:\my\program\to\run\on\any\key.bat
}

^!p::pause

解决方案

A simple solution:

#InstallKeybdHook  ; this MUST be called at the start of your script

AnyKeyPressed() ; returns a 1 if any keyboard key is pressed, else returns 0
{
    if( A_TimeIdlePhysical < 25 )
        return 1

return 0
}

Note this function will return 1 if any key is pressed OR being held down, so change your code appropriately.

What happens is; the #InstallKeybdHook will change the behaviour of A_TimeIdlePhysical to only look for keyboard events.

这篇关于上的任意键AutoHotkey的运行程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆