Introducing AHKEZ

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
jasc2v8
Posts: 59
Joined: 10 Dec 2020, 12:24
Contact:

Introducing AHKEZ

05 Mar 2021, 16:38

Image

AutoHotkey EZ is a free and open source Library for AutoHotkey_L_v1.1.33.02

GitHub Release: v1.0.0

Objectives

1. Promote the use of Autohotkey for programmers of all skill levels and languages
2. Make Autohotkey Easy, Effective, and Fun to use
3. Minimize the confusion when to use percent signs: `variable` or `%variable%` ?
4. For AHK_L_v1.1 only, I have no plans to update for the forthcoming AHL_L_v2

Links

AHKEZ Lib and Doc

AHKEZ Differences from AHK_L

1. Most commands have Function() wrappers that minimize the confusion of using percent signs (%var%)
2. Most Gui commands have Gui() wrappers intended for quick creation of simple Guis
3. AHKEZ adds several functions, see the Doc for details

AHKEZ Featured Items

1. AHKScripts - checkout the \Gui_Templates and the \Tools
2. Doc - notes and manuals
3. Lib - the AKEZ.ahk and other library scripts, especially AHKEZ_Debug.ahk
3. UnitTest - checkout Run_Tests.ahk for tests and examples

Why AHKEZ?

In summary, this is my 2020-2021 COVID-19 Pandemic Quarantine Project to pass the time until the world can get back to work.

I've often had the need to automate tasks and keyboard shortcuts for my day job. I have a hobbyist background programming in Visual Basic and Pascal. The first scripting language I used was AutoIT which was very powerful but I found difficult to use and struggled with the syntax.

Recently I tried AutoHotkey and fell in love with it. However, as a hobbyist, I don't write code every day so when I want to write an AHK script I get stuck trying to figure out when to use the percent signs for variables or %variables%. I have the same issue with MSDOS.

I love AHK but I want to use it to write code without trying to remember the syntax and use of percent signs. AHKEZ solves this problem -- Now I can just write code and enjoy this amazing language!
Last edited by joedf on 23 Mar 2021, 09:18, edited 14 times in total.
Reason: broken img
User avatar
Chunjee
Posts: 1487
Joined: 18 Apr 2014, 19:05
Contact:

Re: Introducing AHKEZ

05 Mar 2021, 17:53

Thank you!

I was thinking of starting something similar but this looks way better. Even has wrappers for making GUIs, nice.
iPhilip
Posts: 831
Joined: 02 Oct 2013, 12:21

Re: Introducing AHKEZ

05 Mar 2021, 21:34

jasc2v8 wrote:
05 Mar 2021, 16:38
Get Involved

If anyone would like to get involved to help with Alpha testing please let me know.
@jasc2v8, I would like to contribute the following changes to the IsType function:

Code: Select all

IsType(ByRef var, type) {
   if (type = "object")
      return IsObject(var)
   if (type = "string")
      return ObjGetCapacity([var], 1) != ""  ; https://www.autohotkey.com/docs/objects/Object.htm#GetCapacity
   if var is %type%
      return true
   return false
}
Notes
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)
User avatar
jasc2v8
Posts: 59
Joined: 10 Dec 2020, 12:24
Contact:

Re: Introducing AHKEZ

06 Mar 2021, 01:10

@iPhilip: Thank you - very nice improvement! :bravo:

This is what I intend to change to - all tests pass but let me know if you see any issues.

Code: Select all

IsType(ByRef var, type) {
   if (type = "object")
      Return IsObject(var)
   if (type = "array") 
      Return (var.Length() >= 0)
   if (type = "string")
      Return ObjGetCapacity([var], 1) != ""
   if var is %type%
      Return true
   Return false
}
User avatar
jasc2v8
Posts: 59
Joined: 10 Dec 2020, 12:24
Contact:

Re: Introducing AHKEZ

06 Mar 2021, 02:29

@Chunjee - Thank you for your kind words!
User avatar
jasc2v8
Posts: 59
Joined: 10 Dec 2020, 12:24
Contact:

Re: Introducing AHKEZ

07 Mar 2021, 18:55

Testing continues...
I edited the OP with the link to the latest release v0.1.4
  • Fixed MsgBox() to work as expected.
  • Added Text_MsgBox.ahk
iPhilip
Posts: 831
Joined: 02 Oct 2013, 12:21

Re: Introducing AHKEZ

08 Mar 2021, 14:49

jasc2v8 wrote:
06 Mar 2021, 01:10
@iPhilip: Thank you - very nice improvement! :bravo:

This is what I intend to change to - all tests pass but let me know if you see any issues.

Code: Select all

IsType(ByRef var, type) {
   if (type = "object")
      Return IsObject(var)
   if (type = "array") 
      Return (var.Length() >= 0)
   if (type = "string")
      Return ObjGetCapacity([var], 1) != ""
   if var is %type%
      Return true
   Return false
}
@jasc2v8, In AutoHotkey v1, there is no way to distinguish an object and an array using the tests you implemented it in the above function. In other words, for every object (including linear/associative arrays as well as class instances), var.Length() >= 0. Thus, I recommend that you remove the test for the "array" type as it's likely to create confusion, i.e. what is an array?

If you wanted to test for arrays that have consecutive integer keys, you could use the following function

Code: Select all

IsLinear(arr) {
   i := 0
   for k, v in arr
      if (k != ++i)
         return false
   return true
}
but please note that the objects [1, 2, 3] and {1:1, 2:2, 3:3} would both return true.

I hope this helps.
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)
User avatar
jasc2v8
Posts: 59
Joined: 10 Dec 2020, 12:24
Contact:

Re: Introducing AHKEZ

09 Mar 2021, 11:13

@iPhilip: Thank you for your sound reasoning, excellent explanation, and tenacity to help!
I removed the test for "array" and updated the OP for GitHub release v0.1.5
iPhilip
Posts: 831
Joined: 02 Oct 2013, 12:21

Re: Introducing AHKEZ

09 Mar 2021, 15:43

jasc2v8 wrote:
09 Mar 2021, 11:13
@iPhilip: Thank you for your sound reasoning, excellent explanation, and tenacity to help!
I removed the test for "array" and updated the OP for GitHub release v0.1.5
You are welcome. :)
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)
robodesign
Posts: 935
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

Re: Introducing AHKEZ

09 Mar 2021, 16:51

Hello!

Very nice work. Are there any plans to cover all of the "commands" found in ahk v1.1? I find them gross and I'd use a library which wraps them as functions. As far as I can tell, they are not all wrapped...

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
User avatar
jasc2v8
Posts: 59
Joined: 10 Dec 2020, 12:24
Contact:

Re: Introducing AHKEZ

09 Mar 2021, 17:09

Hi Marius,

Yes, virtually all the commands have function wrappers, including Gui commands.
Please see the docs: AHKEZ Lib and Doc
Let me know if anything is not explained well so I can improve the docs.
Thank you for your interest.
User avatar
jasc2v8
Posts: 59
Joined: 10 Dec 2020, 12:24
Contact:

Re: Introducing AHKEZ

09 Mar 2021, 17:22

Update: GitHub Release: v0.1.6

Added a GuiDemo to test my AHKEZ Library!
See all the screenshots here: GuiDemo screen shots
Here are a few samples:
GuiDemoTab1_About.png
Tab1
GuiDemoTab1_About.png (40.01 KiB) Viewed 3268 times
attachment=0]GuiDemoTab2_Input.png[/attachment]
GuiDemoTab3_List.png
Tab3
GuiDemoTab3_List.png (50.49 KiB) Viewed 3268 times
Attachments
GuiDemoTab2_Input.png
Tab2
GuiDemoTab2_Input.png (31.67 KiB) Viewed 3268 times
User avatar
jasc2v8
Posts: 59
Joined: 10 Dec 2020, 12:24
Contact:

Re: Introducing AHKEZ

09 Mar 2021, 17:29

@robodesign marius:

All the function wrappers are in the AHKEZ.ahk library script.
I should explain that the AHKEZ Docs only show the Functions added.
No need to document as the wrappers work the same as AHK_L_1.1 commands
The online docs for AHK_L are excellent so no need to duplicate.
There are a few differences, for example the Gui() wrapper returns the HWND.
Please refer to the Original Post (OP) for links.
robodesign
Posts: 935
Joined: 30 Sep 2017, 03:59
Location: Romania
Contact:

Re: Introducing AHKEZ

09 Mar 2021, 18:34

Thank you for your reply. Good to hear this. I apologize for not having looked deeper into it in the first place.

I'll look at it tomorrow and probably integrate it into my project, the image viewer.

Thanks again.

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
User avatar
jasc2v8
Posts: 59
Joined: 10 Dec 2020, 12:24
Contact:

Re: Introducing AHKEZ

15 Mar 2021, 16:14

AHKEZ v1.0.0 Released!

GitHub Release: v1.0.0

Bugs, Comments, and Suggestions can be submitted via GitHub Discussions
User avatar
Chunjee
Posts: 1487
Joined: 18 Apr 2014, 19:05
Contact:

Re: Introducing AHKEZ

17 Mar 2021, 12:31

Trying to get comfortable with these tests and don't think I will be able to.

One test for IfIn looks like this:

Code: Select all

  MatchList := "Apple,Banana,Cherry,Date,Fruit,Fruit2,Grape,Grapefruit,Pineapple"

Test_IfIn:

  ;is not in - IS false SB false
  var := "Frui"
  IS := IfIn(var, MatchList) ? True : False
  T.Assert(A_ScriptName, A_Linenumber, IS, False)
This is kinda hard to follow as is spans multiple lines, a ternary, and the answer is in a variable "IS"



I rewrote this as the following:

Code: Select all

  MatchList := "Apple,Banana,Cherry,Date,Fruit,Fruit2,Grape,Grapefruit,Pineapple"
  assert.false(A_ScriptName, A_Linenumber, IfIn("Frui", MatchList))
That's when I learned IfIn returns true or nothing, which seems like a less than obvious choice.
User avatar
jasc2v8
Posts: 59
Joined: 10 Dec 2020, 12:24
Contact:

Re: Introducing AHKEZ

17 Mar 2021, 16:43

Yes, good feedback.
I've become exhausted with writing and testing the Test_ scripts so they are not optimized.
Maybe I could do more during the next quarantine (just kidding, I have a day job so limited time).

What would be a more obvious choice for the return value of IfIn?
Are you thinking the position in the string (position 26 in the example above with "Frui")?
User avatar
Chunjee
Posts: 1487
Joined: 18 Apr 2014, 19:05
Contact:

Re: Introducing AHKEZ

17 Mar 2021, 18:55

Well I think just false would match my expectation.

When the position is needed I reach for a tool like InStr in an indexOf-like function.
User avatar
jasc2v8
Posts: 59
Joined: 10 Dec 2020, 12:24
Contact:

Re: Introducing AHKEZ

17 Mar 2021, 20:24

Oh, yes, of course.
Return zero (0), which is false, or non-zero (1) if true.
I have many other functions to update with this convention.
Thanks for your help again!
:smile:
User avatar
Chunjee
Posts: 1487
Joined: 18 Apr 2014, 19:05
Contact:

Re: Introducing AHKEZ

24 Mar 2021, 12:30

IfBetween() also returns true or blank. I tried to make a pull request but github won't let me have two different forks I guess.

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: Special-Niewbie and 72 guests