如何将autohotkey文件加载到另一个autohotkey文件(.ahk)

问题描述:

我正在研究一个autohotkey脚本,该脚本允许我选择文本/代码tomy剪贴板并敲击键盘组合,然后将它作为新条目发布在我帐户下的pastbin.com网站上,并将新pastebin.com条目的URL返回到我的剪贴板。如何将autohotkey文件加载到另一个autohotkey文件(.ahk)

到目前为止,我有它工作很好,1例外。下面是我的AutoHotkey代码...

; ******* 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文件上面。

是不是有某种方法可以将该文件包含进去,而不会将所有代码混入我自己的文件中?

我似乎都在致力于通过包括其他文件中像这样

#include HTTPQuery.ahk 

我不知道你能做到这一点

+0

是的 - 看到的#include在AutoHotkey的帮助。 – TrueWill

+0

谢谢,我用Run,seconScript.ahk。但是,这创建了autohotkey的第二个实例,它们都运行一个脚本,效率很低。 –

+0

如果您正在使用很多包含文件,并且一个脚本依赖于另一个脚本,但您需要确保已包含依赖项,那么可以这样做:将其放置在所需脚本中:'loaded_myotherscript:= true' - 现在,将其放置在脚本中,以确保myotherscript已加载(注意在此注释表单中删除的回车符丢失): 'if(!loaded_myotherscript) #include c:\ scripts \ myotherscript。 ahk' – bgmCoder