【问题标题】:How to load an autohotkey file into another autohotkey file (.ahk) [duplicate]如何将自动热键文件加载到另一个自动热键文件(.ahk)[重复]
【发布时间】:2011-09-05 01:40:53
【问题描述】:

我正在编写一个自动热键脚本,它允许我选择文本/代码到我的剪贴板并点击键盘组合,然后它将它作为新条目发布在我的帐户下的 pastbin.com 网站上并返回 URL将新的 pastebin.com 条目添加到我的剪贴板。

到目前为止,除了 1 个例外,我的效果很好。下面是我的自动热键代码...

; ******* INFO *******
; < Pastebin.com copy/paste> - Instantly share your code on pastebin.com
; SCRIPT FUNCTION: Press hotkey (ctrl+shift+c) to save selected text to  pastebin.com


; ******* Initiate script *******
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#SingleInstance, Force


; ******* Hotkeys - Post Code and Get URL *******
^+c::
Send ^c
ClipWait
pastestring:=ClipBoard

api_user_key:="cd25-CHANGED-7c0158bgg06a91e617"
api_dev_key:="24-CHANGED-eecedghb97f35"
URL:="http://pastebin.com/api/api_post.php"

POSTDATA := "api_paste_code=" pastestring "&api_user_key=" api_user_key "&api_paste_name=" filename "&api_paste_private=1&api_paste_format=php&api_dev_key=" api_dev_key "&api_option=paste"

html := httpQUERY(URL,POSTDATA)
Clipboard:=html
TrayTip, AHKClipper, Added %Html%, 2, 1

真正的魔法发生在

httpQUERY(URL,POSTDATA)的函数调用

该函数的代码位于此处的文件中... http://pastebin.com/Bcb3ELPE 我把它贴在那里是因为它有 200 多行,并不真正需要回答这个问题。

现在问题是我上面的脚本可以工作,我必须将 httpquery.ahk 文件的内容包含到我自己的上面的 .ahk 文件中。

难道没有什么方法可以将该文件包含在其中,而不会将所有代码都放入我自己的文件中吗?

【问题讨论】:

    标签: autohotkey


    【解决方案1】:

    我似乎可以通过像这样包含其他文件来让它工作

    #include HTTPQuery.ahk
    

    我不知道你能做到这一点

    【讨论】:

    • 是的 - 请参阅 AutoHotkey 帮助中的#Include。
    • 谢谢,我使用了 Run,seconScript.ahk。但这会创建第二个 autohotkey 实例,两者都运行一个脚本,效率低下。
    • 如果你使用了很多包含文件,并且一个脚本依赖于另一个,但是你需要确保你已经包含了依赖,你可以这样做: 把它放在所需的脚本中: loaded_myotherscript := true - 现在,将其放在需要确保加载 myotherscript 的脚本中(注意此评论表单中删除的缺少的回车):if(!loaded_myotherscript) #include c:\scripts\myotherscript.ahk
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-21
    • 2012-11-16
    • 2013-03-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多