Page 1 of 11

Keysharp - the resurrection of IronAHK

Posted: 13 Jun 2020, 00:15
by mfeemster
Download the latest test builds here: https://bitbucket.org/mfeemster/keysharp/downloads/

_________________________________________________________________________________


I am a senior developer myself with mostly Windows experience, a little bit of Linux, and no Mac OS experience.

From about 2010 to 2015, several people here worked on a project called Iron AutoHotKey which was a complete re-write of AHK in C# with the aim of being cross platform.

Sadly, the project was discontinued and the author is nowhere to be found.

The good news is that his source code is available in an archived repo on github.

I've downloaded it, upgraded the project files to Visual Studio 2019, reorganized and cleaned up a bunch of the code, started a new project based on it, and have it successfully building running on Windows and am able to debug it.

He did a ton of work which I am grateful for, I wouldn't have known where to begin had I started from scratch on my own.

With that baseline code, I can see where he implemented some basic code for doing things on Linux, but have not run that part yet, so I don't know if it will work. I am focusing on Windows for now.

I can also see a lot of empty parts that were left blank.

I am going to spend time inspecting and documenting just how much of the full AHK spec he implemented.

Once I get it all working on Windows, I will try Linux, then maybe Mac if I can get some assistance from Mac developers. IronAHK has already set up a good design for this. I will need to enlist help from volunteers for the latter two OSes.

I think now would be an ideal time to do it because Microsoft is really pushing hard to have C# be a dominant language for all major OSes.

Also, C# is an ideal language for implementing another scrpting language like AHK. C# supports runtime code generation which is very exciting. The AHK script code will get compiled into a new executable at runtime. That executable can also be saved and ran on its own for scripts which seldom change. It can also show the C# code that gets generated from the AHK code, for those who are interested in seeing it.

IronAHK used mono for its development work because mono has always been a cross platform version of .NET.

In recent times, Microsoft has made huge strides in being cross platform. Their .NET core, and .NET 5 release coming later this year, attempt to be cross platform. Sadly, in order to achieve that, they took a "lowest common denominator" approach and left out huge parts of the functionality of the regular .NET framework. IronAHK makes heavy use of those parts, such as the Keys enum, the Application object and various GUI components. The bad news is that since .NET core does not support these features, it can't be used for this project on non-Windows OSes. The good news is that mono implements these features. That provides the rather compelling scenario of writing GUI code in C# on linux.

For Windows, if one wants to use .NET (core) 5 but also have access to the standard libraries mentioned above, Microsoft supports making a hybrid sort of project. I'll be taking this approach for the windows release.

So to summarize:

Windows: .NET (core) 5 + Winforms

Linux/Mac: mono

During this development effort, I don't want to let the perfect be the enemy of the good. Just because some obscure feature might not work on one OS, doesn't mean we shouldn't work on the project at all. We will do our best.

I estimate the initial phase of the project will be a minimum of two years' worth of work. I'm three months into it so far.

The project will be hosted here:

https://bitbucket.org/mfeemster/keysharp/src/master/

Most of the discussion regarding bugs/features will be on the repo instead of this forum, because it offers better bug/feature traceability.

Thanks,
Matt

Re: Keysharp - the resurrection of IronAHK

Posted: 02 Jul 2020, 14:52
by burque505
:bravo: Really looking forward to it.
Regards,
burque505

Re: Keysharp - the resurrection of IronAHK

Posted: 05 Jul 2020, 19:56
by mfeemster
Still chugging along @burque505. I work on it almost daily. My process is such, starting with the most basic parts:

-Take a very simple, isolated part of the language as specified in the AHK help file, such as an assignment operator, multiply operator, creating and concatenating strings...

-Write a small script which uses that part of the language.

-Write a unit test which loads the script, compiles, and runs it and returns whether it passed or failed.

-Add this to my collection of unit tests.


So I am methodically going through and verifying what parts of the language IronAHK implemented, and which ones they did not. If I run into bugs (I've ran into many), I attempt to fix them, and then move on to the next part.

By keeping a large number of unit tests, I am able to ensure that any changes I make, don't lead to other bugs elsewhere. For every change, I run all unit tests.

So to give an idea of where I'm at. I've tested/improved all operators (= == := + - * / // | || & && and not or between >> << . etc...), some were broken.

I've fixed a lot of problems with hotstrings, and have optimized a few things. There are more optimizations I'll revisit later.

I've done some basic function testing.

Today I got associative arrays (dictionaries) working (IronAHK did not allow using variables as keys).

Arrays appear to work, but there is no support for the methods used on them, such as InsertAt() etc..., so that is my next target.

I also got sidetracked for a week trying to figure out which type of .NET I am going to use. I really, really want to use the latest, as I mentioned in my original post. But the .NET core used in .NET 5 does *not* support Winforms, which is crucial to IronAHK/Keysharp. You can't even do basic keyboard stuff (the entire point of this program) without Winforms. So after battling for a week, I realized you can make hybrid .NET core + Winforms projects very easily in Visual Studio 2019. Then of course, I tested a quick Mono project in Linux, and that worked ok. So I am happy about those decisions and am very relieved.

So that's where I'm at. Please sit tight, we have a long, long way to go. But rest assured I'm working on it almost daily.

Re: Keysharp - the resurrection of IronAHK

Posted: 05 Jul 2020, 21:20
by joedf
Share your code? make it open to pull-requests?

Re: Keysharp - the resurrection of IronAHK

Posted: 05 Jul 2020, 22:11
by mfeemster
Hi Joe,

I am going to post it here:

https://bitbucket.org/mfeemster/keysharp/src/master/

Once I have it working reasonably well. Posting it before then won't do any good.

I'll announce here when I post it, which will be in another few months, but hopefully not more than six.

After that, we'll all collaborate there on fixing bugs and adding features.
joedf wrote:
05 Jul 2020, 21:20
Share your code? make it open to pull-requests?

Re: Keysharp - the resurrection of IronAHK

Posted: 06 Jul 2020, 09:26
by joedf
I see, best wishes! :+1:

Re: Keysharp - the resurrection of IronAHK

Posted: 12 Jul 2020, 06:27
by Chunjee
I applaud this effort. :thumbup:

Re: Keysharp - the resurrection of IronAHK

Posted: 10 Aug 2020, 22:37
by mfeemster
About 5 months has passed since I started working on this project, so I figured I'd post an update.

I've been able to dedicate more time than I usually would due to still working from home due to the lockdowns. I save about 2 hours each day by not having to commute, and I put those 2 hours plus much more into Keysharp, plus weekends.

This has allowed me to make more progress than I otherwise would have.

As noted before, I started with the IronAHK codebase and began modifying it. I am systematically going through the AHK documentation and implementing it in Keysharp one section at a time.

To implement a single piece of functionality, I write the code in C# (usually starting from what IronAHK did), then write a unit test using NUnit which verifies that functionality can be compiled in a script, executed, and return an expected result.

With that said, thus far, I have:

-Fixed many bugs
-Created an icon
-Decided to use the V2 syntax and function names
-Implemented:
-all operators
-arrays and their associated member functions
-associative arrays and their associated member functions
-default function arguments
-hotstrings (some work remains)
-flow control: if, for, while (until is not implemented), and all of the loop xxx functions
-environment functions
-math functions (added some hyperbolic functions which were missing)
-special character built in variables, space and tab
-script properties built in variables
-date time built in variables
-script settings built in variables
-loop built in variables
-string functions
-a main window which keeps the program running


I hope that gives watchers of this thread some reassurance that good progress is being made. I think my next target will be the file functions.

Re: Keysharp - the resurrection of IronAHK

Posted: 11 Aug 2020, 05:03
by Chunjee
Good :clap:

Re: Keysharp - the resurrection of IronAHK

Posted: 11 Aug 2020, 06:55
by SOTE
This is excellent news. :dance:
Greatly appreciate the update.
mfeemster wrote:
10 Aug 2020, 22:37
-Decided to use the V2 syntax and function names
On this one, a bit concerned, as AHK v2 is still alpha and changing. Wondering if this might create a perpetual moving target scenario. Though even if V1 syntax were used, not sure how much it would match as well. In addition, most AHK users are not using V2 syntax, which might cause problems with people trying to convert over existing AHK v1 scripts with Keysharp. Though that remains to be seen, V2 syntax might help with future-proofing. Clearly people will be highly enthusiastic with the resurrection and ability to use on Linux, which will help mitigate many issues, but thought it should be mentioned.

Re: Keysharp - the resurrection of IronAHK

Posted: 11 Aug 2020, 07:11
by Chunjee
I don't see that as a big problem. v1 syntax leaves much to be desired and the function names are sometimes a bit dated or inconsistent.

Re: Keysharp - the resurrection of IronAHK

Posted: 11 Aug 2020, 07:14
by mfeemster
Thanks for the concerns SOTE. I've thought about that too, and I think the pros outweigh the cons. From a programming perspective, it makes far more sense to do something like:


retval := func(x, y)

than

func(ref retval, x, y)

That latter syntax peeves me. So I'm going with V2 where most functions have the former syntax.

Re: Keysharp - the resurrection of IronAHK

Posted: 11 Aug 2020, 07:18
by Chunjee
mfeemster wrote:
11 Aug 2020, 07:14
it makes far more sense to do something like:
retval := func(x, y)

than

func(ref retval, x, y)
jc thank you. I call that output as arguments and it needs to go away forever.

Re: Keysharp - the resurrection of IronAHK

Posted: 14 Aug 2020, 00:29
by BoBo
:clap: (watching from the sideline) :thumbup:

Re: Keysharp - the resurrection of IronAHK

Posted: 16 Aug 2020, 21:31
by mfeemster
BoBo wrote:
14 Aug 2020, 00:29
:clap: (watching from the sideline) :thumbup:
Glad you are watching. I am making my way through the folders/files functions now. I am about 2/3 done with them. Some were already written in IronAHK to begin with, so that helped push me a little farther down the road. I am just having to change them into the design that I am using, and write unit tests for each one. Some of them were not implemented though, so I had to start from scratch there.

I find that I can implement about 3 functions per day on average, but I don't work on it every day.

So with maybe 150 functions to go, it'll likely be some time near the end of the year that I will have all of them implemented.

Hope that provides some clarity.

Re: Keysharp - the resurrection of IronAHK

Posted: 17 Aug 2020, 08:04
by burque505
@mfeemster, that's tremendous progress. Gives me another reason to look forward to the end of 2020. :D
Regards,
burque505

Re: Keysharp - the resurrection of IronAHK

Posted: 19 Aug 2020, 01:42
by kyuuuri
I wish I had that motivation for my projects ahahha. Thank you for everything you are doing!

Re: Keysharp - the resurrection of IronAHK

Posted: 27 Aug 2020, 11:22
by Chunjee
I don't see this covered in the OP but will Keysharp be 0 indexed? That would be my preference.

Re: Keysharp - the resurrection of IronAHK

Posted: 27 Aug 2020, 11:25
by boiler
Given the goal of making it as much like AHK as possible, it would make the most sense for array indexing to be the same as it is in AHK.

Re: Keysharp - the resurrection of IronAHK

Posted: 27 Aug 2020, 12:12
by Chunjee
I agree but I am also a little tired of ahk's unique arrangement with the index.