New mcode generator with some cool features

Post your working scripts, libraries and tools.
marton
Posts: 6
Joined: 14 Dec 2023, 10:14

New mcode generator with some cool features

14 Dec 2023, 15:13

I don't know if this goes against the subforum's rules but this is a question about an existing app; I'd like to know if there's any interest in it.

I wrote it for myself while hacking away at a "fuzzy" imagesearch implementation, because I missed features from the old app that no longer seems maintained. Despite that, it's pretty robust and usable. I got carried away having furn with AHK v2, it's really a nice language to use now.

Anyway, if there's interest, I'll clean up the code a bit and make the repo public.

https://github.com/martona/ahkmcodegen [Link to repo added by moderator from OP’s later post.]

1.png
1.png (55.52 KiB) Viewed 1488 times
2.png
2.png (52.82 KiB) Viewed 1488 times
3.png
3.png (43.68 KiB) Viewed 1488 times
User avatar
boiler
Posts: 17404
Joined: 21 Dec 2014, 02:44

Re: New mcode generator with some cool features

14 Dec 2023, 15:43

I’d be interested, and you really need to have the source code public for the thread to stay on this sub-forum.
marton
Posts: 6
Joined: 14 Dec 2023, 10:14

Re: New mcode generator with some cool features

14 Dec 2023, 16:26

Alright! I'll clean up the code and see if I can edit the github link into the OP. Should be done by tomorrow.
marton
Posts: 6
Joined: 14 Dec 2023, 10:14

Re: New mcode generator with some cool features

15 Dec 2023, 04:55

Github repo:

https://github.com/martona/ahkmcodegen

I don't seem to be able to edit the OP and put the link there.
Marium0505
Posts: 43
Joined: 11 May 2020, 20:45

Re: New mcode generator with some cool features

15 Dec 2023, 06:39

marton wrote:
15 Dec 2023, 04:55
Github repo:

https://github.com/martona/ahkmcodegen

I don't seem to be able to edit the OP and put the link there.
Nice, I see you mention creating DLLs, that's something I've been interested in, but haven't found a guide guide on creating one that can be used with AHK, do you know about one?
User avatar
boiler
Posts: 17404
Joined: 21 Dec 2014, 02:44

Re: New mcode generator with some cool features

15 Dec 2023, 08:23

marton wrote: I don't seem to be able to edit the OP and put the link there.
I added it. You will be able to edit your posts after you move past “new member” status (when you have 10 or so posts).
marton
Posts: 6
Joined: 14 Dec 2023, 10:14

Re: New mcode generator with some cool features

15 Dec 2023, 11:41

boiler wrote:
15 Dec 2023, 08:23
I added it. You will be able to edit your posts after you move past “new member” status (when you have 10 or so posts).
Thank you sir!
marton
Posts: 6
Joined: 14 Dec 2023, 10:14

Re: New mcode generator with some cool features

15 Dec 2023, 11:51

Marium0505 wrote:
15 Dec 2023, 06:39
Nice, I see you mention creating DLLs, that's something I've been interested in, but haven't found a guide guide on creating one that can be used with AHK, do you know about one?
I haven't made one for AHK but it should be as simple as grabbing Visual Studio Express (what a misnomer, it's a snail of an app), making sure it installs the C/C++ devtools, creating a new DLL project, adding a function to it with and then calling it from AHK with DllCall.

.net DLLs are a different animal, you can't call them with DllCall. You can access them through COM though, and I'm pretty sure I saw COM interoperability stuff on this forum. The reason I'm bringing that up is because it's potentially a much less frustrating experience than dealing with C/C++ code in DLLs, especially if you're new.
geek
Posts: 1055
Joined: 02 Oct 2013, 22:13
Location: GeekDude
Contact:

Re: New mcode generator with some cool features

16 Dec 2023, 14:43

Have you looked any at the work we're doing on the MCL Machine Code Library for AHK? A brief feature set:

* Supports C and C++ (and includes some very trimmed down hand-written replacements for some of the standard headers)
* Supports 32 and 64 bit
* Includes an AutoHotkey-based Linker
* Allows exporting multiple functions to AutoHotkey
* Allows exporting multiple global variables to AutoHotkey
* Generates a wrapper with all the DllCalls/NumGet/NumPut calls pre-bound with the offsets and types
* Allows importing functions from external DLLs into the C/C++ code, such as from the Windows API or any other DLL you have laying around
* Generates standalone AutoHotkey script with the compiled machine code and wrappers, so you can include compiled code without including the MCL library.

There's a demo of MCL available on the Wiki, where you can compile and run C/C++ code entirely in the browser without having to install your own compiler:

The goal of the project is to allow you to build whatever C/C++ integrations into AHK that you want, but without ever having to provide a separate DLL from your script file. As an example, the cJson library was written via MCL. It uses AHK's objects' COM interfaces to read and write AutoHotkey objects from the machine code blobs, with a high level of performance. COM and mcode can live together in harmony :)
marton
Posts: 6
Joined: 14 Dec 2023, 10:14

Re: New mcode generator with some cool features

16 Dec 2023, 20:19

I haven't seen it, but it's awesome. I'll be spending some time with.

Just out of curiosity, is there a reason you guys process relocations? I know it sounds like a hack, but wouldn't removing the .section statements from the intermediary .s file get you the same results? Unless ofc you're working with multiple object files, but are you?
geek
Posts: 1055
Joined: 02 Oct 2013, 22:13
Location: GeekDude
Contact:

Re: New mcode generator with some cool features

16 Dec 2023, 22:03

According to Cloaker, who wrote the code for linking and relocations, "clever solutions are too easy and not enough fun" and "I think I did want multiple object files originally before I realized that those objects are better off as dynamic objects".

Also, just a heads up: the README, examples, and tests in the v2 library's repository are not up to date. The wiki page has functional examples for the v2 library.

Return to “Scripts and Functions (v2)”

Who is online

Users browsing this forum: No registered users and 54 guests