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.
Array
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
Example:
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
array.removeDuplicates()
base64
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)
Control
Wrapper for "Control" Commands
Counter
example from the documention on how to use timers in a class
CSV
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
ExplorerInfo
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
functions
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
fileCreateDir(pathToFile)
JSON
Json class written by Cocobelgica
NetRequest
Allows us to requests data from the web via WinHttp or Browser
String
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)
Window
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
Collection of useful libraries
Collection of useful libraries
Last edited by dcazrael on 13 Nov 2019, 03:54, edited 2 times in total.
Re: Collection of useful libraries
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.
Thanks
I'm still very inexperienced in regards of code.
If anybody has tips on how to make these libraries better, please let me know.
Thanks
Re: Collection of useful libraries
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
that way people less skilled than yourself can work out how to use them
||-------[-HP-ML350E-G8-]-------||-[-32-core-xeon-]-||--[-48gb-ECC-]--||
||----[-Dell-Poweredge-r610-]---||-[-16-core-xeon-]-||--[-16gb-ECC-]--||
||-[-Lenovo-ThinkPad-x201-tab-]-||---[-4-core-i7-]--||-[-8gb-nonECC-]-||
||---------------------------[-shack--img-]---------------------------||
Re: Collection of useful libraries
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 ).
Regards,
burque505
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 ).
Regards,
burque505
Re: Collection of useful libraries
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
I added some small examples for typical use cases.
Also fixed the typo for the NetRequest link.
Thank you again
Re: Collection of useful libraries
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.
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.
Re: Collection of useful libraries
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;
Telegram is the best way to reach me
https://t.me/ttnnkkrr
If you have forum suggestions please submit a
Check Out WebWriter
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
Telegram is the best way to reach me
https://t.me/ttnnkkrr
If you have forum suggestions please submit a
Check Out WebWriter
Re: Collection of useful libraries
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.
Re: Collection of useful libraries
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
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
Re: Collection of useful libraries
@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.
Regards,
burque505
Regards,
burque505
Return to “Scripts and Functions (v1)”
Who is online
Users browsing this forum: No registered users and 223 guests