Masonjar13's Library List

Post your working scripts, libraries and tools
User avatar
Masonjar13
Posts: 1514
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

Re: Masonjar13's Library List

30 Aug 2017, 03:06

Added getCurrentTime() and getUTCOffset() (both require urlDownloadToVar() and strToLower())

Both use http://www.timeanddate.com, which uses TLS 1.2. If you're receiving an error from urlDownloadToVar(), see this page.

Examples:

Code: Select all

country:="Canada"
region:="Ontario"
timezone:="IST"


cTime:=getCurrentTime(country,region)
if(!cTime)
    msgbox,,Error,Area not found
else
    msgbox,,Time,% "Current time in " . (region?region . ", ":"") . country . ":`n`n" . cTime.hour . ":" . cTime.minute . cTime.ampm . ", " . cTime.date

tTime:=getCurrentTime(timezone,,1)
if(!tTime)
    msgbox,,Error,Timezone not found
else
    msgbox,,Time,% "Current time in " . timezone . ":`n`n" . tTime.hour . ":" . tTime.minute . tTime.ampm . ", " . tTime.date
exitApp

Code: Select all

timezone:="IST"


UTCOffset:=getUTCOffset(timezone)
if(!UTCOffset)
    msgbox,,Error,Timezone not found
else
    msgbox,,UTC Offset,% "Offset for " . timezone . ": " . UTCOffset.sign . UTCOffset.hour . ":" . UTCOffset.minute
exitApp
The reason for getting the UTC offset is to allow client-side math to be performed to a_nowUTC for an active clock. Much more efficient than having to query the server constantly.

Code: Select all

timezone:="EDT"

UTCO:=getUTCOffset(timezone)
if(!UTCO)
    msgbox,,Error,Timezone not found
else
    setTimer,activeClock,100
return

activeClock:
cStamp:=a_nowUTC
if(UTCO.sign="+")
    cStamp+=UTCO.hour * 10000 + UTCO.minute * 100
else if(UTCO.sign="-")
    cStamp-=UTCO.hour * 10000 + UTCO.minute * 100
else{
    setTimer,activeClock,off
    msgbox,,Error,Sign could not be retrieved
}
formatTime,timezoneCTime,% cStamp,h:mmtt
tool(timezone . ": " . timezoneCTime)
return

esc::exitApp
OS: Windows 10 Pro | Editor: Notepad++
My Personal Function Library | Old Build - New Build
User avatar
Masonjar13
Posts: 1514
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

Re: Masonjar13's Library List

25 Jan 2018, 21:14

Important update!

With the release of AutoHotkey 1.1.27.00, Min() has been added as a native function. This function does not operate the same, so I've renamed all related functions (see newest commit).
OS: Windows 10 Pro | Editor: Notepad++
My Personal Function Library | Old Build - New Build
User avatar
Masonjar13
Posts: 1514
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

Re: Masonjar13's Library List

14 Feb 2018, 22:28

Update!

Fixed exec[A]Func in threadMan class. I hadn't actually used it, so I never really knew if it worked or not (and nobody mentioned anything). Both allow up to 10 parameters. If there's a way to do a dynamic call so hard-coded exceptions aren't needed, please let me know!
OS: Windows 10 Pro | Editor: Notepad++
My Personal Function Library | Old Build - New Build
pneumatic
Posts: 299
Joined: 05 Dec 2016, 01:51

Re: Masonjar13's Library List

06 Mar 2018, 19:20

Hi Masonjar

Came across a post of yours here regarding animated cursors not being restored after hiding them
https://autohotkey.com/board/topic/5727 ... ntry654705

Not sure if you had seen the fix, and I couldn't find it in your library, but it seems the animations can be restored by the example here
https://autohotkey.com/board/topic/3260 ... em-cursor/

Code: Select all

SPI_SETCURSORS := 0x57
DllCall( "SystemParametersInfo", UInt,SPI_SETCURSORS, UInt,0, UInt,0, UInt,0 ) ; Reload the system cursors
It seems to work. Even if I change to different cursors in the windows mouse control panel, they are restored to those cursors and with animations. However this is on Windows 7.

I wanted this feature for the borderless full screen mode issue when the mouse cursor gets displayed on top of the game window. The Borderless Gaming app has this fix, and I wanted it in my own as well, and restoring the cursor properly with full animations.
User avatar
Masonjar13
Posts: 1514
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

Re: Masonjar13's Library List

06 Mar 2018, 20:22

I stopped trying to do it, because I came up with a solution more fitted. My problem was when the cursor would be visible over videos, especially when using VLC. So I made a 1x1 gui with WinSet,Transparent, locked the mouse buttons/mouse movement, and placed the gui to the cursor coordinates.

Glad to see there's a proper way to restore cursors though; thanks for letting me know!
OS: Windows 10 Pro | Editor: Notepad++
My Personal Function Library | Old Build - New Build
User avatar
Masonjar13
Posts: 1514
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

Re: Masonjar13's Library List

08 Mar 2018, 01:15

Turns out that Dazzlepod is blocking some VPN servers, some of which I happen to be using. If anyone knows of an alternative site that uses minimal bandwidth (such as a single json file) (location necessary), please let me know!
OS: Windows 10 Pro | Editor: Notepad++
My Personal Function Library | Old Build - New Build
burque505
Posts: 1282
Joined: 22 Jan 2017, 19:37

Re: Masonjar13's Library List

16 Mar 2018, 13:46

Hi Masonjar13, maybe it's too resource-heavy for your purposes, but this one works well for me through a VPN.
Regards,
burque505
User avatar
Masonjar13
Posts: 1514
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

Re: Masonjar13's Library List

17 Mar 2018, 11:51

That's actually not bad at 60kb, but still pretty heavy. Fortunately, I found what I was looking for: https://ipapi.co/json/. I'll implement this as a secondary to Dazzlepod, because it appears to be in beta and may not always be free to use.

For those interested, visit the main site to see what all their API can do. It's quite nice!

Edit: I lied. Kept the old stuff in comments, but since this also supports v6, and the other one I had in there for v6 has limited queries per IP, I've just replaced it entirely.

On that note, externalIP() has been updated. Returning object changed slightly (info in comments).
OS: Windows 10 Pro | Editor: Notepad++
My Personal Function Library | Old Build - New Build
burque505
Posts: 1282
Joined: 22 Jan 2017, 19:37

Re: Masonjar13's Library List

17 Mar 2018, 16:42

Thanks for that link! Now that's what I call lightweight. Just tested it through the VPN, works fine.
User avatar
Masonjar13
Posts: 1514
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

Re: Masonjar13's Library List

14 Apr 2018, 14:42

Seems like Dazzlepod is now working through my VPN now. Still keeping the new one, of course, but at least I can use their nmap scan with it again :)

Update!
Added stringify(obj)
Added addScript and addFile methods to threadMan class

Since stringify seems kind of ambiguous, I'll explain why I wrote it. Objects can't be set to DLL threads via ahkassign, so I needed a workaround. I could be wrong, since I don't actually look at the change logs for _H, but the addScript and addFile functions seem to be new, or I at least didn't notice them in the help file prior. By making an object a string, you can effectively give it an object by adding it as code.

Code: Select all

#include <threadMan>

testObj:={key1:"content for key1"}
testThread:=new threadMan("AutoHotkey.dll")
testThread.newFromFile("example2.ahk")
testThread.addScript("testObj:=" . stringify(testObj),1)
while(testThread.status())
    sleep 100
testThread:=
exitApp

Code: Select all

while(!isObject(testObj))
    sleep 10
for i,a in testObj
    msgbox % "key: " . i . "`nvalue: " . a
exitApp
OS: Windows 10 Pro | Editor: Notepad++
My Personal Function Library | Old Build - New Build
User avatar
Masonjar13
Posts: 1514
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

Re: Masonjar13's Library List

17 Apr 2018, 12:30

Updated the readme. Each function/class now shows required other functions/libraries (if applicable) and a short description. Doesn't look all that pretty, but at least there's more info!
OS: Windows 10 Pro | Editor: Notepad++
My Personal Function Library | Old Build - New Build
User avatar
Masonjar13
Posts: 1514
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

Re: Masonjar13's Library List

11 Aug 2018, 19:15

Update!
Changed the readme; all functions and descriptions are now in a table.
I ripped out the guts from PinAuth/PIN class to make a base class for a db. PIN will now be an extended class of the db class.

Check the commit for more details!
OS: Windows 10 Pro | Editor: Notepad++
My Personal Function Library | Old Build - New Build
CyL0N
Posts: 211
Joined: 27 Sep 2018, 09:58

Re: Masonjar13's Library List

15 Oct 2018, 23:05

Sup dude,Awesome lib.

externalIP() returns ipInfo instead of ipInfoList,just thought you'd want to fix that...
live ? long & prosper : regards
User avatar
Masonjar13
Posts: 1514
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

Re: Masonjar13's Library List

15 Oct 2018, 23:41

CyL0N wrote:
15 Oct 2018, 23:05
Sup dude,Awesome lib.
Thanks, glad you like it!
CyL0N wrote:
15 Oct 2018, 23:05
externalIP() returns ipInfo instead of ipInfoList,just thought you'd want to fix that...
:eh: Strange.. My local copy is correct. Thanks for pointing that out, fixed :thumbup:
OS: Windows 10 Pro | Editor: Notepad++
My Personal Function Library | Old Build - New Build
New_ahk_kid
Posts: 2
Joined: 14 Apr 2020, 23:41
Facebook: snevisions

Re: Masonjar13's Library List

14 Apr 2020, 23:55

Hi,
I am new to ahk, and I saw some code that I was interested in using, then started reading this post. Sorry for such a newb question, but what is all this for, the ip and and string and pointing to a file "lib" or web page ?? >> USES? Is useful for what exactly? Am a bit confused

Thanks
User avatar
Masonjar13
Posts: 1514
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

Re: Masonjar13's Library List

15 Apr 2020, 18:33

@New_ahk_kid I'm not sure what you're asking. This is a forum post regarding my library that is on Github. What from my library were you wondering about? There are quite a few functions in there. The descriptions provided should accurately tell you what each one is used for, though I don't have the parameters for all of them super well documented. You can find the Github link on the first post.
OS: Windows 10 Pro | Editor: Notepad++
My Personal Function Library | Old Build - New Build
User avatar
hasantr
Posts: 496
Joined: 05 Apr 2016, 14:18
Location: İstanbul

Re: Masonjar13's Library List

19 Apr 2020, 01:26

Thanks for this useful Class and Functions. Do you have any case study on using ThreadMan?
https://github.com/Masonjar13/AHK-Library/blob/master/Lib/threadMan.ahk
User avatar
Masonjar13
Posts: 1514
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

Re: Masonjar13's Library List

19 Apr 2020, 12:17

I'm going to assume you meant example. Generally, if you're going to be using multi-threading, you probably already have a reason and general understanding of it. Therefore, the method names are very informative.

If you scroll up 8 posts, you'll see an example of sending an object to a new thread, inclusive of creating and using the thread. That should be enough to get you started.

If you want an extremely exhaustive example, see ScriptUp 1.0.0.1 or earlier.
OS: Windows 10 Pro | Editor: Notepad++
My Personal Function Library | Old Build - New Build
User avatar
hasantr
Posts: 496
Joined: 05 Apr 2016, 14:18
Location: İstanbul

Re: Masonjar13's Library List

19 Apr 2020, 13:52

Masonjar13 wrote:
19 Apr 2020, 12:17
I'm going to assume you meant example. Generally, if you're going to be using multi-threading, you probably already have a reason and general understanding of it. Therefore, the method names are very informative.

If you scroll up 8 posts, you'll see an example of sending an object to a new thread, inclusive of creating and using the thread. That should be enough to get you started.

If you want an extremely exhaustive example, see ScriptUp 1.0.0.1 or earlier.
As a noob, I find these kinds of things complicated. What I am trying to do is find and read the files in the specific extension from the disk with the loop. I thought of starting a different task for some different folders and speeding reading. But for now I understand that I can not do this. Thank you.
User avatar
Masonjar13
Posts: 1514
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

Re: Masonjar13's Library List

11 Jun 2020, 18:39

Update! It's been nearly a year since my last commit, wow. But I've got some new patchwork: functionalAHK!

Simple enough, it just wraps all AHK commands in functions. This is literally just a patch to v1.1 while I'm waiting for v2 to be officially stable. At that point, I'll be converting everything (that needs to be) on the repo to v2, keeping v1.1 versions of course.

They should all work, but I certainly haven't tested every one of them, so let me know either here or on Github if something is broken.
OS: Windows 10 Pro | Editor: Notepad++
My Personal Function Library | Old Build - New Build

Return to “Scripts and Functions”

Who is online

Users browsing this forum: Blackholyman and 62 guests