Call a Library Without Using a Include? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
vSky
Posts: 80
Joined: 30 May 2022, 10:13

Call a Library Without Using a Include?

Post by vSky » 01 Jul 2022, 15:44

Hi,

I downloaded the content on this topic and noticed that their code does not include the "#incule *.lib" command used to invoke the library, but calls the library. How can this be?

Topic Link;
viewtopic.php?t=87139

.ahk Content;

Code: Select all

#SingleInstance Force
SetBatchLines, -1
CoordMode, ToolTip, Screen
loop, 360
{
	Angle:=(A_Index-1)*3
	gosub, GetStyles
	btt("Configuration. Please wait..",700,580,3,OwnStyle3)
	Sleep, 10
}
ExitApp

GetStyles:
; On white background, FontRender = 4 better than 5
OwnStyle3 := {BorderColor:0x00ffffff
						, TextColorLinearGradientStart:0xff00b4db
						, TextColorLinearGradientEnd:0xff004360
						, TextColorLinearGradientAngle:Angle
						, TextColorLinearGradientMode:80
						, BackgroundColor:0x00ffffff
						, FontSize:25
						, FontRender:2
						, FontStyle:"Bold"}
return
The ahk code above does not work without the library.

User avatar
boiler
Posts: 16926
Joined: 21 Dec 2014, 02:44

Re: Call a Library Without Using a Include?  Topic is solved

Post by boiler » 01 Jul 2022, 16:02

From the documentation:
Libraries of Functions: Standard Library and User Library wrote:A script may call a function in an external file without having to use #Include. For this to work, a file of the same name as the function must exist in one of the following library directories:

%A_ScriptDir%\Lib\ ; Local library - requires [v1.0.90+].
%A_MyDocuments%\AutoHotkey\Lib\ ; User library.
directory-of-the-currently-running-AutoHotkey.exe\Lib\ ; Standard library.

User avatar
vSky
Posts: 80
Joined: 30 May 2022, 10:13

Re: Call a Library Without Using a Include?

Post by vSky » 01 Jul 2022, 17:47

boiler wrote:
01 Jul 2022, 16:02
From the documentation:
Libraries of Functions: Standard Library and User Library wrote:A script may call a function in an external file without having to use #Include. For this to work, a file of the same name as the function must exist in one of the following library directories:

%A_ScriptDir%\Lib\ ; Local library - requires [v1.0.90+].
%A_MyDocuments%\AutoHotkey\Lib\ ; User library.
directory-of-the-currently-running-AutoHotkey.exe\Lib\ ; Standard library.
Thanks, but I did not understand the difference between this document and Include use. Is there a reason why I would prefer this instead of #include?

User avatar
boiler
Posts: 16926
Joined: 21 Dec 2014, 02:44

Re: Call a Library Without Using a Include?

Post by boiler » 01 Jul 2022, 19:30

I think you are misunderstanding. You don't put what I posted in your script. It is telling you the location where you put the file that contains the function so that you don't have to put anything in your script to include it. It will automatically find the function in the library location. That's what you were asking about -- how that script didn't use #Include but still called the function. It's up to you whether you prefer that approach or not.

Post Reply

Return to “Ask for Help (v1)”