Skip to content
Eruyome edited this page Dec 26, 2017 · 15 revisions

The Custom Macros folder in %USERPROFILE%\Documents\PoE-TradeMacro\ is a place for you to add your own macros/code. It will never be removed/overwritten or modified by TradeMacro. All .txtand .ahk files in this folder will be appended to TradeMacro after AdditionalMacros.ahk.

The file customMacros_example.txt not only has some examples and instructions on how to add your own code and reassign previously assigned hotkeys, but also is an important file to actually use yourself.

Executing your own code

The reason is a bit technical. AHK has two ways to execute code, the "normal" way by simply writing it down in the script or via function/label call. AdditionalMacros and all custom macros are included in ItemInfo/TradeMacro after at least one Return was written in the script. This means that "normal" code execution is not possible anymore. All code after this point has to be executed via label/function call.
Labels can only be called in two ways. Via hotkey or from inside other labels/functions. This means you either have to add your own hotkeys or add your code inside a label that is being called by TradeMacro/AdditionalMacros. Such a label exists in this example file.

This label is called CM_ExecuteCustomMacrosCode_Label:

; Label gets executed by AdditionalMacros at script start.
CM_ExecuteCustomMacrosCode_Label:

Return

Remember: All code that you want to be executed at script start has to be placed here.

Assigning / reassigning hotkeys

Every hotkey assigned in AdditionalMacros will be assigned no matter if it's set to ON or OFF. It simply won't be triggered if it's off. If you want to use one of those hotkeys for your own macro you have to reassign it via the Hotkey command. Use the CM_ExecuteCustomMacrosCode_Label label in the example file for this.

Examples

Declaring a global variable for further use in your macros

To avoid any conflicts with global variables defined elsewhere it is suggested to prefix your variable, for example cm.

CM_ExecuteCustomMacrosCode_Label:
	global cmMyVar1 := false
	global cmMyVar2 := "false"
Return

Reassigning the F4 hotkey that is already assigned in AdditionalMacros

F4 is already being used in the script but you want to use it for something else.

CM_ExecuteCustomMacrosCode_Label:
	Hotkey, F4, CM_MyHotkey_Label
Return

CM_MyHotkey_Label:
	SendInput {Ctrl Down}{Enter}{Ctrl Up}Thx, have a nice day.{Enter}	
Return

Hotkey, created without the Hotkey command

Overwriting previously assigned hotkeys is not possible this way, resulting in a "duplicate key" error.

CM_ExecuteCustomMacrosCode_Label:

Return

F2::SendInput {Ctrl Down}{Enter}{Ctrl Up}Thx, have a nice day.{Enter}

AutoHotkey IDE's and Editor setups (NotePad++, Sublime, Vim):
https://github.com/ahkscript/awesome-AutoHotkey#integrated-development-environment

Curated list of awesome AHK libs, lib distributions, scripts, tools and resources:
https://github.com/ahkscript/awesome-AutoHotkey