Keysharp - the resurrection of IronAHK

Talk about things C#, some related to AutoHotkey
mfeemster
Posts: 24
Joined: 24 Apr 2020, 18:30

Keysharp - the resurrection of IronAHK

13 Jun 2020, 00:15

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.

There is currently nothing at that repo other than a readme because I just wanted to reserve the catchy name ahead of time. I will wait until I have something working reasonably well before uploading my code.

Thanks,
Matt
burque505
Posts: 1375
Joined: 22 Jan 2017, 19:37

Re: Keysharp - the resurrection of IronAHK

02 Jul 2020, 14:52

:bravo: Really looking forward to it.
Regards,
burque505
mfeemster
Posts: 24
Joined: 24 Apr 2020, 18:30

Re: Keysharp - the resurrection of IronAHK

05 Jul 2020, 19:56

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.
Last edited by mfeemster on 05 Jul 2020, 22:16, edited 2 times in total.
User avatar
joedf
Posts: 7770
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada
Contact:

Re: Keysharp - the resurrection of IronAHK

05 Jul 2020, 21:20

Share your code? make it open to pull-requests?
mfeemster
Posts: 24
Joined: 24 Apr 2020, 18:30

Re: Keysharp - the resurrection of IronAHK

05 Jul 2020, 22:11

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?
User avatar
joedf
Posts: 7770
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada
Contact:

Re: Keysharp - the resurrection of IronAHK

06 Jul 2020, 09:26

I see, best wishes! :+1:
mfeemster
Posts: 24
Joined: 24 Apr 2020, 18:30

Re: Keysharp - the resurrection of IronAHK

10 Aug 2020, 22:37

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.
SOTE
Posts: 1086
Joined: 15 Jun 2015, 06:21

Re: Keysharp - the resurrection of IronAHK

11 Aug 2020, 06:55

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.
User avatar
Chunjee
Posts: 695
Joined: 18 Apr 2014, 19:05
GitHub: Chunjee

Re: Keysharp - the resurrection of IronAHK

11 Aug 2020, 07:11

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.
mfeemster
Posts: 24
Joined: 24 Apr 2020, 18:30

Re: Keysharp - the resurrection of IronAHK

11 Aug 2020, 07:14

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.
User avatar
Chunjee
Posts: 695
Joined: 18 Apr 2014, 19:05
GitHub: Chunjee

Re: Keysharp - the resurrection of IronAHK

11 Aug 2020, 07:18

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.
BoBo
Posts: 3766
Joined: 13 May 2014, 17:15

Re: Keysharp - the resurrection of IronAHK

14 Aug 2020, 00:29

:clap: (watching from the sideline) :thumbup:
mfeemster
Posts: 24
Joined: 24 Apr 2020, 18:30

Re: Keysharp - the resurrection of IronAHK

16 Aug 2020, 21:31

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.
Last edited by mfeemster on 17 Aug 2020, 16:43, edited 1 time in total.
burque505
Posts: 1375
Joined: 22 Jan 2017, 19:37

Re: Keysharp - the resurrection of IronAHK

17 Aug 2020, 08:04

@mfeemster, that's tremendous progress. Gives me another reason to look forward to the end of 2020. :D
Regards,
burque505
kyuuuri
Posts: 327
Joined: 09 Jan 2016, 19:20

Re: Keysharp - the resurrection of IronAHK

19 Aug 2020, 01:42

I wish I had that motivation for my projects ahahha. Thank you for everything you are doing!
User avatar
Chunjee
Posts: 695
Joined: 18 Apr 2014, 19:05
GitHub: Chunjee

Re: Keysharp - the resurrection of IronAHK

27 Aug 2020, 11:22

I don't see this covered in the OP but will Keysharp be 0 indexed? That would be my preference.
User avatar
boiler
Posts: 6199
Joined: 21 Dec 2014, 02:44

Re: Keysharp - the resurrection of IronAHK

27 Aug 2020, 11:25

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.
User avatar
Chunjee
Posts: 695
Joined: 18 Apr 2014, 19:05
GitHub: Chunjee

Re: Keysharp - the resurrection of IronAHK

27 Aug 2020, 12:12

I agree but I am also a little tired of ahk's unique arrangement with the index.

Return to “C#”

Who is online

Users browsing this forum: No registered users and 3 guests