Keysharp - the resurrection of IronAHK

Talk about things KeySharp, some related to AutoHotkey or C#
burque505
Posts: 1731
Joined: 22 Jan 2017, 19:37

Re: Keysharp - the resurrection of IronAHK

29 Sep 2021, 15:33

Thank you, that's great!
User avatar
mfeemster
Posts: 104
Joined: 24 Apr 2020, 18:30

Re: Keysharp - the resurrection of IronAHK

11 Oct 2021, 00:37

StrGet(), StrPut(), CallbackCreate() are done. StrPtr() won't be implemented because you can't really get a pointer to the underlying buffer of a String object in C#. Hopefully this isn't a problem.

Function objects and bound function objects are done.

for-in loops are done. However, I'm unsure if I'll be able to implement the custom enumerator objects shown at the end of the for-in documentation examples. People I've chatted with say they aren't really used in any examples they've seen.

One part I realized I had missed when implementing loops earlier, was that you can place an else statement after them which will get executed if the loop did zero iterations. I've now implemented that with while, loop and for-in.

All of these are unit tested.

I will continue wrapping up all of the remaining items under the Misc section, then probably work on timers after that.

I can definitely see the light at the end of the tunnel, and I'm guessing I'll get there around the middle to end of December. I know I said I was shooting for October earlier in the year, but some of these last few pieces are proving to be time consuming.
User avatar
mfeemster
Posts: 104
Joined: 24 Apr 2020, 18:30

Re: Keysharp - the resurrection of IronAHK

17 Oct 2021, 00:22

BoundFunc, Download(), Edit(), HasMethod(), GetBase(), GetMethod(), OutputDebug() and Persistent() are done and unit tested. I have to hold off on HasProp() for a bit until I implement dynamically adding properties. That may be a while because I don't intend for this initial release to support parsing classes. That will be a major effort down the road.

Is*() functions are done and unit tested.

The main window GUI has been made to look mostly like AHK's main window, with a few enhancements. ListVars is done and shows up properly on the main window.

ListLines will not be implemented because there is no way in C# to get the corresponding source code for the executable code you are running (that I know of).

OutputDebug() writes to a debugging text box in the main window (not present in AHK), as well as to a debugger that might be listening.

SetTimer() is done and unit tested. I've omitted some of the threading specifics, such as what can interrupt what. I will implement that later after I decide on what the threading model will be. I've also made it so that the FuncObj the timer is calling is passed to the timer event handler, so that the caller can easily access it there, such as for shutting it off.

I'll probably be focusing on threading, hotkeys/hotstrings (which are mostly done already), and finally COM next.
burque505
Posts: 1731
Joined: 22 Jan 2017, 19:37

Re: Keysharp - the resurrection of IronAHK

17 Oct 2021, 16:55

Thanks as always for the update.

Is there a chance we might we be getting C#-like string interpolation and string literals? That would be very nice indeed. Or even just AHK_1-like continuation sections, where variables are expanded like the code below?

Code: Select all

myvar := "This is a test."
expansion = 
(
%myvar%
This is only a test.
"I can add quote stuff without jumping through hoops."
And add $, \n and so forth (but not ``n or ``r) without worrying what will happen when the variable is expanded.
)
msgbox %expansion%
It would be nice to be able to write

Code: Select all

 myvar := @"First line,
 second line,
 third line."
Or even add interpolation like

Code: Select all

firstvar := "City"
secondvar := " Hall"
newvar = $@"Where are you going?
{firstvar}{secondvar}
"
I know it's a lot to ask, and string literals plus interpolation is not a templating solution all itself, but I use templates a lot. In AHK I struggle with them. I'm always looking for ways to make it easier on myself.

Python-like capability would be really nice, but again that's really asking a lot.
Like f-strings:

Code: Select all

>>> import datetime
>>> name = 'Fred'
>>> age = 50
>>> anniversary = datetime.date(1991, 10, 12)
>>> f'My name is {name}, my age next year is {age+1}, my anniversary is {anniversary:%A, %B %d, %Y}.'
'My name is Fred, my age next year is 51, my anniversary is Saturday, October 12, 1991.'
>>> f'He said his name is {name!r}.'
"He said his name is 'Fred'."
>>>
Or something like Python triple-quoting:

Code: Select all

AHK = """
This is a really long comment that can make
the code look ugly and uncomfortable to read on
a small screen so it needs to be broken into
multi-line strings using double triple-quotes
"""
print(AHK)
Again, I know this is a huge ask and I don't mean to sidetrack you from approaching the finish line. :D

Regards,
burque505
User avatar
mfeemster
Posts: 104
Joined: 24 Apr 2020, 18:30

Re: Keysharp - the resurrection of IronAHK

17 Oct 2021, 19:39

There is some continuation statement functionality already implemented. I don't think adding what you want will be too much trouble. But just like many other requests, it's going to have to wait until *after* I do an initial release, and we get all of the bugs ironed out (of which I assume there are at least 100+). After that, we can play with the "nice to haves".

As for string formatting though, I am following the C# string.Format() rules. This makes it very easy, I just pass the format string directly and don't do any parsing myself. I just let string.Format() handle it.
burque505
Posts: 1731
Joined: 22 Jan 2017, 19:37

Re: Keysharp - the resurrection of IronAHK

18 Oct 2021, 07:36

Thanks very much, @mfeemster. Greatly appreciated.
Regards,
burque505
User avatar
mfeemster
Posts: 104
Joined: 24 Apr 2020, 18:30

Re: Keysharp - the resurrection of IronAHK

08 Nov 2021, 23:23

I've spent the last week and a half working on implementing multi-line statements, and strings enclosed in single quotes, plus fixing various parsing issues.
Implementing multi-line required many parsing changes, which subsequently broke most of my unit tests.
I've gone through every one and gotten them working again.
That was a major derailment, but now I am back on track.

In addition to the above work, I came across an oddity in a code example someone showed me: ternaries with multiple statements per branch. I took a look at implementing them and realized it would be extremely hard and I'd have to butcher a ton of delicate parsing code that already works. Further, all it would do is translate it under the hood to an if/else statement, since C# does not natively support multi-statement ternary expressions. So I am going going to omit support for those. If you need them, just use an if/else statement.

I am now going to work on hotstring/keys, then threads, and maybe COM.

I still think I'm on track to release an initial preview in late December.
SOTE
Posts: 1426
Joined: 15 Jun 2015, 06:21

Re: Keysharp - the resurrection of IronAHK

10 Nov 2021, 19:50

@mfeemster

If you could make the release prior to 12/25, that would be one hell of a Christmas gift to the AHK community. But no pressure... Whenever it's ready (when it's time, it's time), as will be great to see it.
szamanr
Posts: 2
Joined: 21 Nov 2021, 08:56

szamanr

21 Nov 2021, 08:59

thanks for your work and the updates, @mfeemster. do you perhaps have a github repository which we could watch to be notified of releases?
User avatar
mfeemster
Posts: 104
Joined: 24 Apr 2020, 18:30

Re: Keysharp - the resurrection of IronAHK

18 Dec 2021, 00:59

When it came time to do the keyboard/mouse stuff, which is the whole point of AHK, I spent some time scrutinizing the existing code in these files:

https://github.com/Lexikos/AutoHotkey_L/blob/master/source/hook.cpp
https://github.com/Lexikos/AutoHotkey_L/blob/master/source/keyboard_mouse.cpp
https://github.com/Lexikos/AutoHotkey_L/blob/master/source/hotkey.cpp

In total they were around 11,000 lines of code including the very verbose comments. It was clear that it would be counterproductive to try to write my own keyboard and mouse processing code. Mainly because the existing code contains 20 years of accumulated wisdom that accounts for every conceivable key combo, keyboard layout and language corner case. Plus it accounted for all sorts of oddities within the Windows message loop. So there was no way I would have the same knowledge myself, and thus it would do me no good to throw it all away and start over.

So I have ported all of that code into C#, and have thus retained the 20 years of accumulated wisdom of AHK.

Right now there is some structure in place to make this code cross platform, but at the moment it's very Windows specific. After we get things working on Windows, I'll revisit this code in linux (using Mono) and figure out what parts are generic and which are OS specific.

With all of this core code now in place, I am going to work on implementing all of the functions under the Mouse and Keyboard section in the help file.

I hate to do this to you all again, but I need to push the release date back. I hadn't realized those files were so massive, so that chewed up a month of my time. We're looking at a Jan/Feb time frame now.

The code will be posted on Bitbucket when the time comes, then we'll move over to there for bug/feature reporting.

Hang in there with me, we're getting close to an initial prototype release.
Last edited by mfeemster on 18 Dec 2021, 03:59, edited 3 times in total.
User avatar
joedf
Posts: 8937
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: Keysharp - the resurrection of IronAHK

18 Dec 2021, 15:28

Very neat, looking forward to it. :dance:
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
burque505
Posts: 1731
Joined: 22 Jan 2017, 19:37

Re: Keysharp - the resurrection of IronAHK

19 Dec 2021, 09:55

Have a great holiday @mfeemster! Thanks once again for all your incredibly hard work on this project.
szamanr
Posts: 2
Joined: 21 Nov 2021, 08:56

Re: Keysharp - the resurrection of IronAHK

08 Mar 2022, 03:52

hi @mfeemster, any news on the progress of works?
User avatar
mfeemster
Posts: 104
Joined: 24 Apr 2020, 18:30

Re: Keysharp - the resurrection of IronAHK

12 Mar 2022, 11:43

I've stopped development for a few months because I've gotten extremely busy with other things. I'll report back here when I resume development in a few months.

I wish there were more hours in a day!
User avatar
joedf
Posts: 8937
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: Keysharp - the resurrection of IronAHK

12 Mar 2022, 17:53

mfeemster wrote:
12 Mar 2022, 11:43
[...] I wish there were more hours in a day!
Oh boy, that sure echoes with me! :D
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Keysharp - the resurrection of IronAHK

15 Mar 2022, 12:08

@mfeemster - Thx for your feedback :thumbup:
License Question

Re: Keysharp - the resurrection of IronAHK

17 Mar 2022, 16:11

I see the KeySharp license is much like a MIT license https://bitbucket.org/mfeemster/keysharp/src/master/license.txt which is super cool.

AutoHotKey is a GPL 2 license. But I saw on the keysharp repo https://bitbucket.org/mfeemster/keysharp/src/master/ it said keysharp is "A C# port and enhancement of AutoHotkey." A port normally means that one is converting the lines of code from one language to another. And I think it may be common for such work to be considered a derivative work which would mean that it would have to be under a GPL 2 License like the original source. But maybe the term "Port" is being used loosely here and the code for KeySharp is not a conversion of C++ to C# but rather a recreation of the software in C# without actually usign/converting _any_ code from AutoHotKey.

I ask because I can't link my code to GPL code but I could Link it to MIT licensed code. So I'm just trying to figure out if Keysharp is legitimately MIT Licensed code (IE not really a conversion of GPL code to c# but rather a recreation from scratch of the same functionality) or not.

Thoughts?
User avatar
mfeemster
Posts: 104
Joined: 24 Apr 2020, 18:30

Re: Keysharp - the resurrection of IronAHK

19 Mar 2022, 01:36

I haven't given any thought to the license. Whatever is in there is what I copied from the original IronAHK repo. The IronAHK starting point plus much of what I've written are from scratch in C#. However, there are several thousand lines which are direct ports from AHK C++ to C#.

TBH, I don't care either way. I always found the endless "debates" about licenses to be a form of academic masturbation.

The question is: do the people who do care have enough money for lawyers to enforce it one way or another?

The going rate for talented lawyers in the United States is $300-$500/hr.
SOTE
Posts: 1426
Joined: 15 Jun 2015, 06:21

Re: Keysharp - the resurrection of IronAHK

20 Mar 2022, 12:01

License Question wrote:
17 Mar 2022, 16:11
I see the KeySharp license is much like a MIT license...

...Thoughts?
I hope it doesn't cause too much controversy, but do think the license is important to some people. The GPL can be a source of drama, so various people using open-source software at their job, business, or school might take issue with it or have experienced issues because of it. Thus such can prefer if the software to be used is not GPL, where in other cases it doesn't matter. It's true that it is very expensive to bring such issues to trial, but it doesn't mean it's impossible or can't happen, thus some want to avoid any risk. In the case of the author of the original version of AHK, Chris Mallett, he gave the impression (in previous public posts) that people are free to do whatever they like (including commercial use) and that he would not take any actions against such. However, there were issues about the AutoIt parts and those contributors and developers that came afterwards.

When it comes to code in a different programming language, whether it is derivative or not, is likely something that can truly only be decided in court (if the situation got that extreme). My understanding is that it would not be, and can stand on its own as an original work. Partly, this is because much of AHK (including AutoIt), relies on the WinAPI. A derivative work is when portions of code is used nearly unchanged from the original, in the new work, and that such must rely on it in order to function.

This precedent was set in U.S. law, in the case of Galoob v. Nintendo. Nintendo sued Galoob for copyright infringement and lost.

"[a] derivative work must incorporate a protected work in some concrete or permanent form."

If the program takes portions of AHK source code directly, as is (C++), and relied on it to function then it could be argued as a derivative work. If something is created of similar functionality, in another programming language, to access the same WinAPI then it likely will not be seen as derivative.

There are other factors involved as well, which is if the original author objects and wants to fight it out in court (extremely expensive and time consuming) or if those portions of code are put under the license of the original author and giving attribution in the way the license describes. An example of this is already in the AHK source code, where those portions which come directly from AutoIt (C++) are defined as being so, uses its license, and gives attribution. However, automation programs that contain some similar functionality are still free to be licensed how the author chooses. Some examples, but under different licenses and/or languages; Pywinauto is under BSD-3 or WinAutoKey which is under LGPL.

Return to “KeySharp”

Who is online

Users browsing this forum: No registered users and 2 guests