Collection of useful libraries

Post your working scripts, libraries and tools
Posts: 5
Joined: 21 Jul 2019, 23:02

Collection of useful libraries

01 Sep 2019, 21:19

Hey everyone,

I'm Az, a very new and inexperienced coder.

Over the last couple months I have written several scripts to make my work easier and relied a lot on scripts and functions from other people to get things done.
While learning I realized I enjoy the OOP based approach and thus try to write and use everything as class when possible.

I have collected some very useful libraries and adapted them to be classes.
Some functions I wrote by myself, but most code was written by others.

extends functionality for arrays and Objects on the base object
This allows the use of additional methods on the array itself, rather than calling a function and passing the array

Let's say you have a function to remove duplicates from an array.
Usually you do something like this newArray := removeDuplicates(oldArray)
Extending the base object allows us to add methods to the array itself

base64 decoder and varZ compression (written by SKAN) to save binary data to png files

Example use:
saveImage(base64Code, fileName){
Bytes := Base64Dec( BIN, base64Code )
VarZ_Save( BIN, Bytes, fileName )
VarSetcapacity( base64Code, 0 )
saveImage(yourBase64Code, flower.png)

Wrapper for "Control" Commands

example from the documention on how to use timers in a class

reads csv and loads data in arrays
can be used to specifically read columns or rows

flowers := new CSV(flowerCsv.csv)
flowerName := flowers.readCol(4, 1, true) ; reads 4th column of data, Row 1 is a header, skip headers

retrieves info from a specific explorer window

explorer := new ExplorerInfo()
path := explorer.getPath() ; get path for currently active explorer window
fileCreateDir(path . "\system32")
fileCopy("C:\Windows\system32\*.*", path . "\") ; copies system32 contents to current window

Wrapper for several Commands to make scripts more uniform

AHK 1 still has functionality split between legacy Commands and new functions
FileCreateDir, %pathToFile%
The wrapper simulates a function syntax

Json class written by Cocobelgica

Allows us to requests data from the web via WinHttp or Browser

Allows us to interact upon strings similar to objects

More syntax unification
Instead of
test := Instr(testVar, "Lucky", 0, 1)
I like to use
test := testVar.inStr("Lucky", 0, 1)

Wrapper for "Window" Commands

Everywhere I remembered where I got it from, I put a @Source tag in the documentation.
If you find something I forgot to document or put the source, please let me know, So I can update it.

The repository will be maintained on Github.

Thank you
Last edited by dcazrael on 13 Nov 2019, 03:54, edited 2 times in total.
Posts: 5
Joined: 21 Jul 2019, 23:02

Re: Collection of useful libraries

28 Oct 2019, 21:30

Updated some of the libraries.

I'm still very inexperienced in regards of code.
If anybody has tips on how to make these libraries better, please let me know.

User avatar
Posts: 62
Joined: 30 Sep 2013, 10:01

Re: Collection of useful libraries

28 Oct 2019, 21:37

i would suggest a basic usage example at the top of each one (or perhaps served seperately but i personally prefer it together)

that way people less skilled than yourself can work out how to use them :)

[14/10/2019][03:06:09] <@tidbit> so, 8 years old. thats way too young for a human centipede.
[29/10/2019][01:48:42] <@tidbit> it should be a cloaca
[6/12/2019][01:53:34] <+Budgii> tidbit: how did you come up with your name?
[6/12/2019][01:53:59] <@tidbit> Budgii: I slapped a goat and phonetically spelt the sound it made
[15/1/2020][17:51:08] <@tidbit> b-b-b-bbaka!
[15/1/2020][17:59:42] <@tidbit> bugz knows his otakunese guys!
[28/2/2020][21:09:36] <@tidbit> find an eagle with some damn self control?
[07/3/2020][00:28:48] <@tidbit> maybe someone was fapping too close to heaven, so god sent a warning
Posts: 1158
Joined: 22 Jan 2017, 19:37

Re: Collection of useful libraries

30 Oct 2019, 08:01

Thanks for these! Just FYI, the NetRequests link in the OP has a typo, or the name of the library on GitHub does ("NetRequest.ahk").
Really useful stuff. Like @Bugz000, I think examples at the top of each library or in the OP would be very helpful indeed (but that's a lot of examples to put in one post :D ).
Posts: 5
Joined: 21 Jul 2019, 23:02

Re: Collection of useful libraries

13 Nov 2019, 03:55

Thank you for the feedback.
I added some small examples for typical use cases.
Also fixed the typo for the NetRequest link.

Thank you again
Posts: 5
Joined: 21 Jul 2019, 23:02

Re: Collection of useful libraries

23 Dec 2019, 19:27

I made some small adjustments to the functions, adding a floorMod function similar to JAVA.
If you simply use "%" your results will be less or equal to the quotient
Via "/" you will get a return of an "integer closest to 0".

Depending on your application this can make a big difference in your outcomes.
User avatar
Posts: 2824
Joined: 28 Sep 2013, 22:15
Facebook: charlie.simmons.7334
Google: ttnnkkrr
GitHub: ttnnkkrr
Location: Irving TX

Re: Collection of useful libraries

23 Dec 2019, 21:38

Nice work
We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
If you have forum suggestions please submit a pull request
Check Out WebWriter
Thanks Tank :thumbup:
User avatar
Posts: 43
Joined: 08 Sep 2018, 18:35
GitHub: Onimuru

Re: Collection of useful libraries

28 Dec 2019, 23:05

Here's a some additional array methods that you can use for your array library, just be aware they're written with the same functionality as JS array.prototype in mind as well as 0 base indexing. I actually dropped this on Reddit awhile ago but no one was overly interested.
Posts: 5
Joined: 21 Jul 2019, 23:02

Re: Collection of useful libraries

07 Jan 2020, 19:17

Hey Onimuru,

actually some of the methods I have added in the Array lib I provided are from the JS array.prototypes. I didn't see a use for everything since AHK already implements a lot of them.
I will go over it when I get time and add the ones, that aren't provided by AHK natively.

Thank you
Posts: 1158
Joined: 22 Jan 2017, 19:37

Re: Collection of useful libraries

08 Jan 2020, 12:35

@dcazrael, thanks for your updates. @Onimuru, somehow I missed your linked post. Nice work as well, lots of useful stuff. By the way, I'd love to see some examples of your GDIp code if you have some.

Return to “Scripts and Functions”

Who is online

Users browsing this forum: vepman and 55 guests