I was inspired to do this project, because I've been working a lot with JavaScript lately, which (in modern browsers like Chrome) has an excellent way of representing any type of object or other value in the console.
In AHK, when you try to display any object whatsoever, you just get a blank string.
This is obviously quite frustrating and not a good solution.
While implementing such a feature in AHK itself would probably be a better solution, I think my toStr() function serves its purpose quite well!
How It Works
It couldn't be more simple: You pass any value you want to show on the screen to toStr() and out comes the string representation!
Here is an example:
Code: Select all
obj := {an: "object", just_for: ["testing", "!"]}
msgbox obj ; this shows an empty message box :(
msgbox toStr(obj) ; this shows: {"an": "object", "just_for": ["testing", "!"]} (just as you would expect it!)
Keep in mind that toStr() only works in AHK v2, v1 is currently not supported and I, personally, have no plans on porting the script.
Download
Here it is: The GitHub Page
From there you can clone the entire repository, or just download toStr.ahk – it is the only file you need.
Installation
First, download toStr.ahk as explained above.
When you have the file ready, best copy it into your Lib folder. Then you can include it with #include <toStr> in any script you run in the future!
Alternatively, you can copy the file anywhere you like and then use the normal #include to include it in your scripts.
Note
toStr.ahk is licensed under the GNU General Public License v3 and it has to stay that way.
Feel free to use the source code however you like for anything private – I'm not going to hunt you down, even if you you may violate the license terms a bit here and there.
When you want to publish code that makes use of toStr.ahk, however, please do follow what is said in the license.
You can find a fairly easy explanation to the license text here: TLDRlegal.com
In any way, I always get happy when people use my code, so why not just write me a little forum PM or a comment or whatnot if you are using toStr.ahk? It would definitely make me happy! :3
Also – this goes without saying – tell me about any bugs or suggestions!
You can always just open up an Issue or Pull Request on GitHub, but also just comment under this thread. It is very appreciated!
Thank you for your time, I hope you like this script!