Shared function.

Share your favorite FastKeys commands
Post Reply
Kertifonis
Posts: 2
Joined: Feb 25th, ’23, 21:32

Post by Kertifonis » Feb 25th, ’23, 22:00

Good morning,
Sorry, is there a way to use the same function from different scripts, similar to the #include in C and the AutoHotKey?)
(Sorry for the Google translation, my English is bad)
Thanks in advance for any response and congratulations for the SW.
User avatar
Tom
Posts: 917
Joined: Nov 24th, ’15, 23:39

Post by Tom » Feb 26th, ’23, 11:12

If you create a function in one command it will in principle be available in all other commands as well.
Kertifonis
Posts: 2
Joined: Feb 25th, ’23, 21:32

Post by Kertifonis » Mar 4th, ’23, 10:01

Thank you very much for the answer.
nmax
Posts: 3
Joined: Nov 27th, ’23, 16:23

Post by nmax » Nov 27th, ’23, 16:42

Tom wrote: Feb 26th, ’23, 11:12 If you create a function in one command it will in principle be available in all other commands as well.
Unfortunately, when trying to create a Shortcut with Command

Code: Select all

ToolTipTest("hi",,,5000)
it says:

Code: Select all

Error:  Call to nonexistent function.

Specifically: ToolTipTest("hi",,,5000)

	Line#
	004: Return
	005: Return
--->	007: ToolTipTest("hi",,,5000)  
	008: Return
	009: Return
	010: {
	011: Return
	012: }
	013: Exit

The program will exit.
even there is another Shortcut exists and works with Command text:

Code: Select all

ToolTipTest("hi",,,5000)

ToolTipTest(S, X="", Y="", msec=1000) {
    SetTimer, Off, %msec%
    ToolTip, %S%, %X%, %Y%
    return
    
    Off:
    ToolTip
    SetTimer, Off, Off
    return
}
I even tried place the same code chunk into Tools > Startup script - no success.

I just purchased the license and it's is kinda a show stopper for me.


Can you help?

Or if there are no options so far, then I suggest add feature to have some folder like "Includes" where can be stored .ahk files with functions that are loaded and globally accessible in any command.
Thank you.
Last edited by nmax on Nov 28th, ’23, 08:31, edited 1 time in total.
User avatar
Marko
Posts: 1919
Joined: Mar 2nd, ’13, 21:02

Post by Marko » Nov 27th, ’23, 19:01

Thanks for reporting. You are right, currently it is only possible to set a procedure and not a function in the Startup Script.
We will resolve this in the next release. ;)
nmax
Posts: 3
Joined: Nov 27th, ’23, 16:23

Post by nmax » Nov 28th, ’23, 08:34

Marko wrote: Nov 27th, ’23, 19:01 Thanks for reporting. You are right, currently it is only possible to set a procedure and not a function in the Startup Script.
We will resolve this in the next release. ;)
Great, thanks! Can't wait.
icue
Posts: 2
Joined: Dec 12th, ’25, 16:40

Post by icue » Dec 12th, ’25, 16:50

Marko wrote: Nov 27th, ’23, 19:01 Thanks for reporting. You are right, currently it is only possible to set a procedure and not a function in the Startup Script.
We will resolve this in the next release. ;)
From https://www.fastkeysautomation.com/foru ... php?t=2367, I see that "Startup script can now contain functions and subroutines", so I take it that we should be able to define a function in startup script and re-use it in a text expander command.

But when I try to do that, I keep encountering the "Call to nonexistent function" error, as if the problem reported above was never resolved. I'm on the latest version of fastkeys.

Could you maybe give me a simple example of how a function can be defined in startup script and then re-used? This is not mentioned in the documentation as of now.

Thanks!
User avatar
Marko
Posts: 1919
Joined: Mar 2nd, ’13, 21:02

Post by Marko » Dec 16th, ’25, 22:01

We are aware of this issue and it has not been resolved yet. It is stillonly possible to set a procedure and not a function in the Startup Script.

We will try to resolve it asap.
icue
Posts: 2
Joined: Dec 12th, ’25, 16:40

Post by icue » Jan 12th, ’26, 12:49

Marko wrote: Dec 16th, ’25, 22:01 We are aware of this issue and it has not been resolved yet. It is stillonly possible to set a procedure and not a function in the Startup Script.

We will try to resolve it asap.
Well in that case can you please let me know once the issue is resolved? I do monitor this thread, as well as the release notes, so I'd appreciate it if you could mention the fix in either place once it happens.

Being able to use function in the Startup Script would save me a lot of duplicate code, so I really look forward to the fix. Thanks!
User avatar
Marko
Posts: 1919
Joined: Mar 2nd, ’13, 21:02

Post by Marko » Jan 13th, ’26, 18:12

I confirm this now works in version 6.05.
Post Reply