Combine different scripts into one? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
M4verick
Posts: 193
Joined: 03 Nov 2020, 12:00

Combine different scripts into one?

21 Apr 2021, 16:02

I've written several scripts that launch based off different hotkeys.
AHK tray.png
AHK tray.png (39.02 KiB) Viewed 518 times
It just occurred to me that I should combine them into 1 single script. Will it work? For example:

Code: Select all

F8::
script...blah blah
^F9::
script 2...blah blah
F10::
script 3.... blah blah
Return
User avatar
boiler
Posts: 17047
Joined: 21 Dec 2014, 02:44

Re: Combine different scripts into one?  Topic is solved

21 Apr 2021, 17:16

Generally, yes. You need to put Return at the end of each one:

Code: Select all

F8::
script...blah blah
Return

^F9::
script 2...blah blah
Return

F10::
script 3.... blah blah
Return

You need to be careful about things like conflicting variable names. You could alleviate potential issues like that by using functions for each so they’re not sharing the global namespace.
M4verick
Posts: 193
Joined: 03 Nov 2020, 12:00

Re: Combine different scripts into one?

21 Apr 2021, 19:00

OK thanks. Right now all of my scripts are pretty simple & straight forward with no variable names used so I don't expect any complications.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Chunjee, Joey5 and 274 guests