Keysharp - the resurrection of IronAHK

Talk about things KeySharp, some related to AutoHotkey or C#
User avatar
thelegend
Posts: 13
Joined: 23 Mar 2021, 15:29

Re: Keysharp - the resurrection of IronAHK

Post by thelegend » 11 Jun 2021, 11:28

:bravo: Watching from the sidelines and applauding your efforts, @mfeemster!

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

Re: Keysharp - the resurrection of IronAHK

Post by mfeemster » 17 Jun 2021, 00:49

Thanks @thelegend, I am trying to get this done as quickly as I can, but it's going to take a while.

I have finished FileOpen() and the File object and have written unit tests for them.

I will now continue on with other miscellaneous areas of functionality. I'll report back when I have something significant.

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

Re: Keysharp - the resurrection of IronAHK

Post by mfeemster » 10 Jul 2021, 00:15

I am happy to report that I've implemented all of the functions under Window section of the help file:

https://lexikos.github.io/v2/docs/commands/Win.htm

That includes all of the Window, Window Groups and Controls functions, except ControlSend() and ControlSendText() because I will do those functions later after implementing all of the keyboard functionality.

Minus those last two, that's 89 functions in total under the Window section.

I've finished up the various classes/functionality under the Object Types section as well.

I am omitting some of the more obscure/esoteric object design with the Any prototype and such related functionality. I will be using the C# object model because this is a C# program.

Most of the work under the Misc section is done, and I will revisit the remaining parts later. Some may end up not applying to this design, and will thus be omitted.

So what remains at this point? Here is a rough outline:

1) #directives
2) Most control flow is done, but a few more remain, such as the "until" construct and try/catch
3) The External Libraries section, including DllCall(). I am unsure if I will implement COM, I will have to evaluate.
4) The Mouse and Keyboard and Hotkeys and Hotstrings sections. This was partially done by IronAHK, and I have verified it works, so I am not starting from scratch. However, it will need a lot of work to be compatible with AHK, particularly with regard to AHK's pseudo "threads" which allow one hotkey to interrupt another despite being on the same actual thread. I may end up just using real threads to implement this. I will have to evaluate.
5) Fill in any remaining holes such as ControlSend() and ControlSendText() mentioned above.

I think I will work on them in that order. If I am able to complete them, then I will be very happy to say that an initial cut of the program will be ready for people to start testing in limited fashion. At that point, I will begin soliciting help for testing, as well as writing unit tests.

Keep in mind this is only on Windows for the time being, but some design framework is in place for running on Linux. We will only move to Linux after we get Windows running solidly.

Thanks for being patient, we are getting close.

burque505
Posts: 1731
Joined: 22 Jan 2017, 19:37

Re: Keysharp - the resurrection of IronAHK

Post by burque505 » 10 Jul 2021, 07:08

@mfeemster, thanks so much for the update. Regarding COM support, I would certainly love to see it!
Regards,
burque505

SOTE
Posts: 1426
Joined: 15 Jun 2015, 06:21

Re: Keysharp - the resurrection of IronAHK

Post by SOTE » 11 Jul 2021, 03:30

mfeemster wrote:
10 Jul 2021, 00:15
I am omitting some of the more obscure/esoteric object design with the Any prototype and such related functionality. I will be using the C# object model because this is a C# program.
I would like to offer a little push back on this or to at least get greater clarification, because a power of prototypes is in allowing the use of objects without Classes. In scripting languages where this has been implemented, it has been seen as a plus. JavaScript and Lua are 2 notable examples, along with AutoHotkey, as it allows for more choice (to either use objects with Classes or not) and greater simplification of programs.

There is also a trend of various new languages to bypass Class-based OOP all together, such as Go and Vlang (V is a new open-source programming language that has similarities to Go and builds on its concepts further). Hybrid languages such as Object Pascal creates choice by use of Records, where it can be used as an alternative to Classes. C# introduced Records in later versions, to also be an alternative to Classes and Structs, but this type of usage is less common in the language and implemented a bit differently.

Arguably, if Class-based object usage is forced, it might cause problems in terms of freedom of programming style. This might also raise a red flag in terms of porting various code over to Keysharp from AutoHotkey, where objects are used differently or at least various workarounds might be needed. Maybe this isn't anything to worry too much about and of course it's your decision, in terms of which direction things will go. The community applauds your efforts. However, I'm intrigued on your thoughts about this subject.

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

Re: Keysharp - the resurrection of IronAHK

Post by mfeemster » 11 Jul 2021, 20:26

I don't understand the concept of "objects without classes". Can you explain it?

Since it's a C# program, I'll just use the C# object model.

It's a question of why people use AHK. Do they use it to do obscure, esoteric object tinkering? Or do they use it to automate various desktop tasks? My impression was that it was for the latter. If they want to see how quirky they can get their object designs, then Lua or any other others you mentioned is probably a better choice.

SOTE
Posts: 1426
Joined: 15 Jun 2015, 06:21

Re: Keysharp - the resurrection of IronAHK

Post by SOTE » 11 Jul 2021, 21:36

mfeemster wrote:
11 Jul 2021, 20:26
I don't understand the concept of "objects without classes". Can you explain it?

Since it's a C# program, I'll just use the C# object model.

It's a question of why people use AHK. Do they use it to do obscure, esoteric object tinkering? Or do they use it to automate various desktop tasks?
Prototype-based object use is quite pervasive in AutoHotkey, it might not seem so on the surface because object use is so simplified (a credit to its design). Many AHKers can just be thinking of associative arrays, and not making the distinction that there is a bit more going on. I'm bringing this up, as it's not clear how the C# Class-based object model would mesh with the Prototype-based AutoHotkey model. I'm sure there are all kinds of workarounds, but maybe it's something to look at. Since there is no published Alpha of Keysharp yet, just kind of curious how it would be handled.

Wikipedia (https://en.wikipedia.org/wiki/Prototype-based_programming) does a good job in explaining the distinction between Prototype-Based OOP versus Class-Based OOP.

"Objects inherit directly from other objects through a prototype property." --Wikipedia
"An object is a prototype or base if another object derives from it." --AutoHotkey v1 documentation (https://www.autohotkey.com/docs/Objects.htm)

In AutoHotkey (or JavaScript), if you simply wanted to create an object, you just need to use {}, thus thing := {}.

The properties and/or methods don't have to be defined within a Class, but simply assigned to the variable.

For properties or values, you simply need to do- thing.foo := "bar"

Instead of doing the assignments vertically, you can kind of do this all in one go and horizontally, such as- thing := {KeyA: ValueA, KeyB: ValueB}

The methods (functions) assigned don't have to be contained within a Class, but can be derived from anywhere in the script, thus- thing.test := Func("thing_test")

Combined, you would have something like this:

Code: Select all

thing := {}
thing.foo := "bar"
thing.test := Func("thing_test")
thing.test()

thing_test(this) 
{
    MsgBox % this.foo
}
Inheritance is dynamic and simplified. We simply use assignment.

Code: Select all

other := {}
other := thing
other.test()
This simplified use of objects and as extensible associate arrays allows for scripts with code like below:

Code: Select all

Data := MouseGetPos()
MsgBox, % Data.X " " Data.Y " " Data.Win " " Data.Ctrl


MouseGetPos(Options := 3) 
{
	MouseGetPos, X, Y, Win, Ctrl, % Options
	Return {X: X, Y: Y, Win: Win, Ctrl: Ctrl}
}

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

Re: Keysharp - the resurrection of IronAHK

Post by mfeemster » 11 Jul 2021, 22:46

Ok thanks, I'll look into that.

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

Re: Keysharp - the resurrection of IronAHK

Post by mfeemster » 18 Jul 2021, 17:37

I am happy to announce that I have try/catch/tryelse/finally/throw/OnError() working.

I will work on the remaining missing control flow items next.

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

Re: Keysharp - the resurrection of IronAHK

Post by mfeemster » 28 Jul 2021, 17:08

I am happy to announce switch/case/default is done. The only part of that which I have not implemented is defining labels within a case statement, then using goto from another case to jump to it. The reason is that I have not fully and properly implemented labels yet. Once I do, I will come back to this part.

burque505
Posts: 1731
Joined: 22 Jan 2017, 19:37

Re: Keysharp - the resurrection of IronAHK

Post by burque505 » 28 Jul 2021, 17:13

Thanks for the update, @mfeemster, like many others I'm really looking forward to seeing the first release.
Regards,
burque505

BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Keysharp - the resurrection of IronAHK

Post by BoBo » 31 Jul 2021, 14:20

:thumbup:

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

Re: Keysharp - the resurrection of IronAHK

Post by mfeemster » 15 Aug 2021, 01:28

The logical right shift operators >>> and >>>= are done. So are RegExMatch() and RegExReplace(). I made the latter return an object with the replaced string and count, rather than having to pass count as a ref param. The object has an implicit string operator, so it can be used just like a string.

I've done other miscellaneous improvements and unit testing.

I realized I forgot to implement the for/in loop, so I will need to squeeze that in as well.

BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Keysharp - the resurrection of IronAHK

Post by BoBo » 29 Aug 2021, 17:10

I took a month and a half off from this project, so it took me a while, but I've finished the Screen function. ImageSearch() was the hardest one
@mfeemster - coincidently I've stumbled over FindText yesterday. Probably of interest as an alternative for ImageSearch(), or its functionality can be incorporated into it (sooner or later?)?? :shh:
Anyway, thx for your effort :thumbup:

User avatar
boiler
Posts: 16705
Joined: 21 Dec 2014, 02:44

Re: Keysharp - the resurrection of IronAHK

Post by boiler » 30 Aug 2021, 06:39

BoBo wrote: @mfeemster - coincidently I've stumbled over FindText yesterday. Probably of interest as an alternative for ImageSearch(), or its functionality can be incorporated into it (sooner or later?)?? :shh:
The goal should be to make it as close to AHK as possible, not to add bloat and coding effort by building in people's various favorite tools.

serg
Posts: 56
Joined: 21 Mar 2015, 05:33

Re: Keysharp - the resurrection of IronAHK

Post by serg » 05 Sep 2021, 06:26

Will KeySharp scripts (at least compiled one) run much faster than current AHK ones? Forgive me my ignorance :)

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

Re: Keysharp - the resurrection of IronAHK

Post by mfeemster » 06 Sep 2021, 22:27

serg wrote:
05 Sep 2021, 06:26
Will KeySharp scripts (at least compiled one) run much faster than current AHK ones? Forgive me my ignorance :)
Not sure, it'll depend on the specific part you're benchmarking. In my guesstimation, it'll probably run a little bit slower.

However, the point of both of these languages is not speed.

That said, it will be interesting to benchmark. Maybe you can start writing some benchmarking scripts/tests which we can integrate into our test suite after we release an initial version for testing.

Btw, I stopped working on it for about a week and a half because I got busy on other things. Will get back on it soon.

serg
Posts: 56
Joined: 21 Mar 2015, 05:33

Re: Keysharp - the resurrection of IronAHK

Post by serg » 07 Sep 2021, 06:19

@mfeemster

Thanks! I would be glad to test speed of Key# (although I'm not much of a coder).

Regarding performance, the guy who was developing IronAHK mentioned once that in his tests IronAHK was able to do math operations 30-40 times faster than AHK, as I understand he was talking about compiled scripts, since IronAHK was compiling to machine code, unlike AHK. And since your project is similar and based on IronAHK, I'm curious as to why Key# would differ in that regard from IronAHK.
(KeySharp) can also show the C# code that gets generated from the AHK code
So it would be possible to see C# equivalent of AHK script and modify/optimize it? I'm asking coz although AHK speed is more than enough >99% of the time for me, there are few performance-sensitive functions that I'm trying to deal with.

In any case, thank you for your valuable work mfeemster, AHK for Linux is what many of us have been waiting for a long time :thumbup:

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

Re: Keysharp - the resurrection of IronAHK

Post by mfeemster » 07 Sep 2021, 08:30

serg wrote:
07 Sep 2021, 06:19
@mfeemster

Thanks! I would be glad to test speed of Key# (although I'm not much of a coder).

Regarding performance, the guy who was developing IronAHK mentioned once that in his tests IronAHK was able to do math operations 30-40 times faster than AHK, as I understand he was talking about compiled scripts, since IronAHK was compiling to machine code, unlike AHK. And since your project is similar and based on IronAHK, I'm curious as to why Key# would differ in that regard from IronAHK.
(KeySharp) can also show the C# code that gets generated from the AHK code
So it would be possible to see C# equivalent of AHK script and modify/optimize it? I'm asking coz although AHK speed is more than enough >99% of the time for me, there are few performance-sensitive functions that I'm trying to deal with.

In any case, thank you for your valuable work mfeemster, AHK for Linux is what many of us have been waiting for a long time :thumbup:
Thanks for the background info. Yes, Keysharp takes in AHK script code, generates C# code, compiles and runs it. You'll be able to see the code, but optimization won't do you much good. The bulk of the execution time will be spent within the Keysharp library. The code that gets generated just mostly calls library functions. Regardless, you'll be able to see it if you want.

I can't make any performance claims yet, but if you have specific areas that require performance, then perhaps you can write some benchmark scripts that test the parts you are concerned with. It'll be a few months before I am ready to accept such tests.

serg
Posts: 56
Joined: 21 Mar 2015, 05:33

Re: Keysharp - the resurrection of IronAHK

Post by serg » 07 Sep 2021, 10:42

@mfeemster

Thanks for clarification! Functions that I need better performance for are mostly math calculations.

Keep up the good work mfeemster, I'll be watching your progress from the fence in the meanwhile :)

Post Reply

Return to “KeySharp”