例如
#m::send !m{enter 5}!s
f4::send #m
如上面这样的code,结果是我按下#m是有想要的结果,但我按f4键却没有反应这是为什么呢?请各位帮忙
自定义热键如何再用 Topic is solved
Moderators: tmplinshi, arcticir
Re: 自定义热键如何再用
(i used google translate to understand it)
Code: Select all
#m::send !m{enter 5}!s
~f4::send #m
Re: 自定义热键如何再用
thx for Qysh's concern, but I have add ~ before f4, it still doesn't work
Re: 自定义热键如何再用
My aim is to define a hotkey for an action, like #m for the action of !m{enter 5}!s
and when I need to use this action (i.e. !m{enter 5}!s), I don't need to rewrite the code (i.e. !m{enter 5}!s)
I hope to simply write #m, like f4::send #m, rather than f4::send !m{enter 5}!s
and when I need to use this action (i.e. !m{enter 5}!s), I don't need to rewrite the code (i.e. !m{enter 5}!s)
I hope to simply write #m, like f4::send #m, rather than f4::send !m{enter 5}!s
Re: 自定义热键如何再用
THX you but it still doesn't workQysh wrote:(i used google translate to understand it)
Code: Select all
#m::send !m{enter 5}!s ~f4::send #m
Re: 自定义热键如何再用
用函数。
action1 是函数名称,可以随便取。
Code: Select all
f4::action1()
action1()
{
send !m{enter 5}!s
}
Re: 自定义热键如何再用
我明白了,是用自建函数代替我想要的功能,但这自定函数是否只能在这ahk档用上,有没有可以将所有ahk档都能用这自定函数tmplinshi wrote:用函数。action1 是函数名称,可以随便取。Code: Select all
f4::action1() action1() { send !m{enter 5}!s }
Re: 自定义热键如何再用
你可以把函数代码保存到一个文件中,比如 functions.ahk,然后把这个文件放在 AutoHotkey安装目录\Lib\ 目录下。之后你每个脚本都能直接调用里面的函数。
如果不放在 Lib\ 目录下的话,那你需要在每个脚本中用 #Include D:\test\functions.ahk 命令引用这个文件。
如果不放在 Lib\ 目录下的话,那你需要在每个脚本中用 #Include D:\test\functions.ahk 命令引用这个文件。
Re: 自定义热键如何再用 Topic is solved
谢你的指引我试试!tmplinshi wrote:你可以把函数代码保存到一个文件中,比如 functions.ahk,然后把这个文件放在 AutoHotkey安装目录\Lib\ 目录下。之后你每个脚本都能直接调用里面的函数。
如果不放在 Lib\ 目录下的话,那你需要在每个脚本中用 #Include D:\test\functions.ahk 命令引用这个文件。
Re: 自定义热键如何再用
我在autohotkey里scite/tools和scite/toolbar和scite/tools/gendocs都找到lib,我应该放那一个tmplinshi wrote:你可以把函数代码保存到一个文件中,比如 functions.ahk,然后把这个文件放在 AutoHotkey安装目录\Lib\ 目录下。之后你每个脚本都能直接调用里面的函数。
如果不放在 Lib\ 目录下的话,那你需要在每个脚本中用 #Include D:\test\functions.ahk 命令引用这个文件。
Re: 自定义热键如何再用
我在autohotkey里scite/tools和scite/toolbar和scite/tools/gendocs都找到lib,我应该放那一个tmplinshi wrote:你可以把函数代码保存到一个文件中,比如 functions.ahk,然后把这个文件放在 AutoHotkey安装目录\Lib\ 目录下。之后你每个脚本都能直接调用里面的函数。
如果不放在 Lib\ 目录下的话,那你需要在每个脚本中用 #Include D:\test\functions.ahk 命令引用这个文件。
Re: 自定义热键如何再用
放在 AutoHotkey 的安装目录,即 AutoHotkey.exe 所在文件夹。
比如安装目录是 C:\Program Files\AutoHotkey
则 Lib 目录为 C:\Program Files\AutoHotkey\Lib\
比如安装目录是 C:\Program Files\AutoHotkey
则 Lib 目录为 C:\Program Files\AutoHotkey\Lib\
Re: 自定义热键如何再用
我会不会是安装了sciTE AUOTOHOTKEY后这个lib会消失tmplinshi wrote:放在 AutoHotkey 的安装目录,即 AutoHotkey.exe 所在文件夹。
比如安装目录是 C:\Program Files\AutoHotkey
则 Lib 目录为 C:\Program Files\AutoHotkey\Lib\
Re: 自定义热键如何再用
我记得默认是没有这个Lib目录的,自己创建一个即可。
Re: 自定义热键如何再用
我再试试tmplinshi wrote:我记得默认是没有这个Lib目录的,自己创建一个即可。
Re: 自定义热键如何再用
不好意思,说错了。tmplinshi wrote:你可以把函数代码保存到一个文件中,比如 functions.ahk,然后把这个文件放在 AutoHotkey安装目录\Lib\ 目录下。之后你每个脚本都能直接调用里面的函数。
如果不放在 Lib\ 目录下的话,那你需要在每个脚本中用 #Include D:\test\functions.ahk 命令引用这个文件。
如果想直接调用 functions.ahk 里面的函数,函数名要与文件名相同(即函数名为 functions),或者前缀相同(比如函数名为 functions_a, functions_xxx ...)。这两者都不符的话还是需要用 #Include。
https://wyagd001.github.io/zh-cn/docs/Functions.htm#lib
Who is online
Users browsing this forum: No registered users and 34 guests