Introducing AHKEZ
Introducing AHKEZ
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
Reason: broken img
Re: Introducing AHKEZ
Thank you!
I was thinking of starting something similar but this looks way better. Even has wrappers for making GUIs, nice.
I was thinking of starting something similar but this looks way better. Even has wrappers for making GUIs, nice.
Re: Introducing AHKEZ
@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)
Re: Introducing AHKEZ
@iPhilip: Thank you - very nice improvement!
This is what I intend to change to - all tests pass but let me know if you see any issues.
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
}
Re: Introducing AHKEZ
@Chunjee - Thank you for your kind words!
Re: Introducing AHKEZ
Testing continues...
I edited the OP with the link to the latest release v0.1.4
I edited the OP with the link to the latest release v0.1.4
- Fixed MsgBox() to work as expected.
- Added Text_MsgBox.ahk
Re: Introducing AHKEZ
@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?jasc2v8 wrote: ↑06 Mar 2021, 01:10@iPhilip: Thank you - very nice improvement!
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 }
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
}
I hope this helps.
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)
Re: Introducing AHKEZ
@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
I removed the test for "array" and updated the OP for GitHub release v0.1.5
-
- Posts: 935
- Joined: 30 Sep 2017, 03:59
- Location: Romania
- Contact:
Re: Introducing AHKEZ
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.
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.
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
Re: Introducing AHKEZ
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.
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.
Re: Introducing AHKEZ
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:
attachment=0]GuiDemoTab2_Input.png[/attachment]
Added a GuiDemo to test my AHKEZ Library!
See all the screenshots here: GuiDemo screen shots
Here are a few samples:
attachment=0]GuiDemoTab2_Input.png[/attachment]
- Attachments
-
- Tab2
- GuiDemoTab2_Input.png (31.67 KiB) Viewed 3268 times
Re: Introducing AHKEZ
@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.
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.
-
- Posts: 935
- Joined: 30 Sep 2017, 03:59
- Location: Romania
- Contact:
Re: Introducing AHKEZ
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.
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.
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
Re: Introducing AHKEZ
AHKEZ v1.0.0 Released!
GitHub Release: v1.0.0
Bugs, Comments, and Suggestions can be submitted via GitHub Discussions
GitHub Release: v1.0.0
Bugs, Comments, and Suggestions can be submitted via GitHub Discussions
Re: Introducing AHKEZ
Trying to get comfortable with these tests and don't think I will be able to.
One test for IfIn looks like this:
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:
That's when I learned IfIn returns true or nothing, which seems like a less than obvious choice.
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)
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))
Re: Introducing AHKEZ
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")?
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")?
Re: Introducing AHKEZ
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.
When the position is needed I reach for a tool like InStr in an indexOf-like function.
Re: Introducing AHKEZ
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!
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!
Re: Introducing AHKEZ
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