Page 1 of 2

Masonjar13's Library List

Posted: 24 May 2016, 18:17
by Masonjar13
I'm always making new functions, so I decided to post a decent amount of them here. Several are modified functions of others' and should be noted as such. If they derived from someone elses code and isn't noted as such, please let me know, thanks.

Note: some are just commands turned into functions. You may also notice syntax style varies, which is due to some being written as long as 3 years ago.

The library has been moved to Github.

Re: Masonjar13's Library List

Posted: 26 May 2016, 12:23
by florisvos
Interesting! I very often turn to google to find the exact way of typing certain AHK functions, or I turn to previous scripts to find some code-lines I need (instead of writing it again from scratch).

I suppose it is very helpfull to have a list of functions stored somewhere where you can always turn to when making a new script... No need to turn to google or other scripts all the time! Not sure if I will ever need to convert an hours to milliseconds or something like that - but I really like the concept of a list like this :)

Re: Masonjar13's Library List

Posted: 26 May 2016, 12:29
by Masonjar13
florisvos wrote:I suppose it is very helpfull to have a list of functions stored somewhere where you can always turn to when making a new script.
You can save these to your standard library, so you won't ever need to include them. Check here.

Re: Masonjar13's Library List

Posted: 26 May 2016, 12:49
by florisvos
Masonjar13 wrote:
florisvos wrote:I suppose it is very helpfull to have a list of functions stored somewhere where you can always turn to when making a new script.
You can save these to your standard library, so you won't ever need to include them. Check here.
Thanks so much! Never knew that! So simple but so helpful, I'm sure!

Re: Masonjar13's Library List

Posted: 12 Jul 2016, 21:14
by joedf
Nice collection :)
However, you should use one of the following to get the Ip for less bandwidth usage. ;)

http://dazzlepod.com/ip/me.json
http://checkip.dyndns.org

Re: Masonjar13's Library List

Posted: 12 Jul 2016, 21:40
by Masonjar13
Thank you :)
Had I known this existed.. I'll update it soon. It'll be pretty quick, seeing as I don't have to work with any HTML shenanigans. Thanks a lot for this! :thumbup:

Re: Masonjar13's Library List

Posted: 12 Jul 2016, 21:58
by joedf
@Masonjar13 No problem, my friend! :D

Re: Masonjar13's Library List

Posted: 12 Jul 2016, 23:07
by Masonjar13
It has been updated. The fact that the "ISP" portion is much longer slightly annoys me, but it works and tells the information it needs to. I implemented a seemingly sound method to get rid of the excess. It's consistent across the IP's I've tested with, anyway. I've also kept the old version in the post as well, noted as such.

Using an old bandwidth monitor I wrote, the difference is quite significant: old method hits (in Kb) from 42-148, where the new method is 3-6. That's 1400-2466 percent less bandwidth used ;)

P.S. If someone has a problem with my excess ridding method for the organization/ISP string (cutting off too much or too little), post the string and I'll see if I can fix it.

Re: Masonjar13's Library List

Posted: 12 Jul 2016, 23:52
by Guest
Using a JSON lib instead of RegEx. ;)

Code: Select all

IPInfo := externalIP()
MsgBox, % IPInfo.ip "`n"
    . IPInfo.prefix "`n"
    . IPInfo.country_code "`n"
    . IPInfo.asn "`n"
    . IPInfo.city "`n"
    . IPInfo.country "`n"
    . IPInfo.region "`n"
    . IPInfo.hostname "`n"
    . IPInfo.longitude "`n"
    . IPInfo.latitude "`n"
    . IPInfo.organization

externalIP(){
    static URL := "http://dazzlepod.com/ip/me.json"
    return json_toobj(urlDownloadToVar(URL)) ; https://autohotkey.com/board/topic/96244-func-convert-objects-tofrom-json-like-strings/
}

Re: Masonjar13's Library List

Posted: 13 Jul 2016, 02:30
by Masonjar13
Seems like more of a hassle than it's worth for just one file. :roll: If you already use the library, that makes perfect sense, but I'd prefer to: A) keep it simple. B) keep claimed copyright out of my library. I also have no need to work with JSON files, this would be the first and possibly last.
To each their own; I won't be adding that to the first post.

Re: Masonjar13's Library List

Posted: 13 Jul 2016, 08:51
by joedf
I thought of the same thing Masonjar13 :)

Re: Masonjar13's Library List

Posted: 13 Jul 2016, 11:16
by Guest
I prefer the JSON lib to regex, but that's just me.
permDel
Delete highlighted files (does not recycle)
Doesn't Shift+Delete do this already?

@joedf You thought the same thing as who?

Re: Masonjar13's Library List

Posted: 13 Jul 2016, 11:41
by Guest

Code: Select all

for i, v in externalIP()
    Msg .= """" i """: """ v """`n"
MsgBox, % Msg
return

externalIP() {
    ipInfo := {}
    for i, v in StrSplit(Trim(urlDownloadToVar("http://dazzlepod.com/ip/me.json"), " {}`r`n"), "`n", "`r") {
        s := StrSplit(v, ":", " ,""")
        ipInfo[s.1] := s.2
    }
    return ipInfo
}

Re: Masonjar13's Library List

Posted: 13 Jul 2016, 11:53
by Guest
Another version. This might be better than using StrSplit to split the line at ":", since that could fail if the second part contains a ":".

Code: Select all

externalIP() {
    ipInfo := {}
    for i, v in StrSplit(Trim(urlDownloadToVar("http://dazzlepod.com/ip/me.json"), " {}`r`n"), "`n", "`r")        
        ipInfo[Trim(SubStr(v, 1, (p := InStr(v, ":")) - 1), " """)] := Trim(SubStr(v, p + 1), " , """)
    return ipInfo
}

Re: Masonjar13's Library List

Posted: 13 Jul 2016, 13:21
by Masonjar13
Guest wrote:
permDel
Delete highlighted files (does not recycle)
Doesn't Shift+Delete do this already?
Correct, but it prompts the user. Maybe there's a way to remove the prompt though? I didn't bother with doing so at the time.

For everyone else writing variants of externalIP(): by all means, continue to do so if you feel like it :thumbup: but I won't be changing my version, as I made an exception for "organization" to be "ISP," and also trimmed it. My computer doesn't notice a difference using RegEx; the one I'm using now is virtually instant. Just tested using a_tickCount and my for-loop is less than one tick.

Re: Masonjar13's Library List

Posted: 14 Jul 2016, 10:08
by joedf
Guest wrote:@joedf You thought the same thing as who?
I thought of utilizing the json, but then I told myself it's going a little overboard for a small self-contained/independent function. :mrgreen:

Re: Masonjar13's Library List

Posted: 29 Jul 2016, 02:41
by Masonjar13
The library has been moved to Github (link on first post). It'll be easier for me to maintain it this way ;)
I'll still post updates here, probably.
  • Added strI()
  • Added regExMatchI()
  • Added regExReplaceI()
  • Added strReplaceI()
  • Added mtos()
  • Updated randStr() - will likely have another update very soon

Re: Masonjar13's Library List

Posted: 29 Jun 2017, 19:24
by Masonjar13
Update!

Finally, I've pushed an update to my git rep. :thumbup: Below are the additions and edits.
  • Updates:
    • externalIP - Fixed ISP (dazzlepod updated their ISP value a while back), added extra values to the returning object, and condensed the code.
    • urlDownloadToVar - Added raw option.
  • New functions:
    • audioRouter (class)
    • fileUnblock
    • getImageSize
    • getSelected
    • invertCaseChr
    • invertCaseStr
    • mouseOverWin
    • strToLower
    • strToUpper
I probably should have put invertCaseChr inside invertCaseStr, seeing as it supersedes it.. :think: I'll have to go and make sure it doesn't break anything I already have, though.

Edit: Added "ip" parameter to externalIP to allow look-up of other IP addresses.

Re: Masonjar13's Library List

Posted: 01 Jul 2017, 00:53
by vasili111
Masonjar13
Nice library :thumbup: Thank you :)

Re: Masonjar13's Library List

Posted: 16 Jul 2017, 05:59
by Masonjar13
vasili111 wrote:Masonjar13
Nice library :thumbup: Thank you :)
No problem, glad you like it!
  • Added toolSpeak() (similar to tool(), but uses SAPI.SpVoice to vocalize the given string)