Closed gitbork closed 3 years ago
This is indeed a bug. It should be fixed in the next release (v1.0.2.0). Wich is planned to be released coming weeks.
I looked more closely at the bug. I can not fix it properly because of the AutoHotkey.Interop library. The library doesn't support multithreading with AHK. There is an alternative fix. But it creates too much instability. Therefore I won't roll this out into the main release. currently, I will mark this as "won't fix" until the AutoHotkey.Interop is updated to support AHKThreading or a better solution presents itself.
There will be a new release of MultiBoard (v1.0.1.8) that can resolve your issue. In version, v1.0.1.8 is it possible the declare a global function that can be used within MultiBoard keys and invoked without the duplicate error (#30).
If you want to try out the new preload system. you just add your calculator function in the "preload.ahk" file. The preload.ahk file can be located at "%appdata%/MultiBoard" or just navigate to setting > info > open save file.
And bind a key to this AHK code:
Describe the bug Simple AHK scrip causes a "Duplicate Function Definition Error" and will not run when bound to hotkey. I have a simple AHK test script that is meant to launch calculator. This script will run fine if I right click and "Run Script". It will also run fine using the shortcut key that I have defined in Multiboard - however it will only do so one time. After the first time the hotkey launches the calculator application the first time it will no longer work. The subsequent times I try to use the defined shortcut key I get the following error:
This same sort of error happens for any AHK script that has any kind of function defined.
Here is the code I am using to launch the calculator:
`Calculator(){ Run Calc.exe return }
Calculator()`
To Reproduce
Expected behavior The calculator should launch when pushing the defined shortcut key. (Really any AHK script with a function defined in it should work)
Log
--DEBUG STARTED-- Construction main done COM ports scan mode 2 --comports-- comports: COM1 comports: COM3 --scan results-- COM1 result: NONE COM3 result: 9ba53aba-246d-4b26-9d7d-df2a61e74adb loading boards loading: C:\Users\choke\AppData\Roaming\MultiBoard\saves\9ba53aba-246d-4b26-9d7d-df2a61e74adb.mkb loading keyboard 9ba53aba-246d-4b26-9d7d-df2a61e74adb try check valid connection from COM3 attempt 0 valid connection on COM3
Screenshots Here is the Multiboard config
Here is the "Run Script" method that will work all the time
Here is the AHK Code again:
Here is the crappy error:
Additional Info (please complete the following information):
Additional context I can get calculator to launch by doing it this way, but that doesn't help me figure out the bigger problem about why any AAHK script that uses the "define function" method doesn't work...