This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;* RandomNormal(Mean, Deviation) | |
;* Description: | |
;* https://en.wikipedia.org/wiki/Ziggurat_algorithm | |
RandomNormal(vMean := 0, vDeviation := 1.0) { | |
Static __K := (v := __RandomNormal()).k, __W := v.w, __F := v.f ;* Populate the lookup tables. | |
Loop { | |
u := RandomUniform(-0x80000000, 0x7FFFFFFF), i := (u & 0xFF) + 1 | |
If (Abs(u) < __K[i]) { ;* Rectangle. This will be the case for 99.33% of values (512 rectangles would be 99.64%). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i, v in [0x0200, 0x02A3, 0x02A1, 0x0201, 0x0202, 0x0203, 0x0204, 0x0205, 0x0206, 0x0207, 0x0208, 0x0209, 0x020A, 0x020E] { | |
OnMessage(v, "MsgHandler") | |
} | |
Exit | |
TrackMouseEvent(hWNDTrack, dwFlags := 0x00000002, dwHoverTime := 400) { ;: https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-trackmouseevent | |
Static cbSize := 8 + (A_PtrSize*2) | |
VarSetCapacity(sEventTrack, cbSize, 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Class Timer { | |
Static Instances := [] | |
__New(callback, interval := 0, priority := 0) { | |
Local | |
instance := {"Callback": callback, "Interval": interval, "Priority": priority | |
, "State": -1 | |
, "Base": this.__Timer} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;* PostMessage(msg, (wParam), (lParam), (winTitle), (excludeTitle), (detectHiddenWindows)) | |
PostMessage(msg, wParam := 0, lParam := 0, winTitle := "", excludeTitle := "", detectHiddenWindows := "") { | |
if (!(detectHiddenWindows == "") && !(detectHiddenWindows == (detect := A_DetectHiddenWindows))) { | |
DetectHiddenWindows, % detectHiddenWindows ;~ No error handling. | |
} | |
PostMessage, msg, wParam, lParam, , % winTitle, , % excludeTitle | |
if (detect) { | |
DetectHiddenWindows, % detect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mouseHook := SetWindowsHookEx(14, "LowLevelMouseProc") | |
, keyboardHook := SetWindowsHookEx(13, "LowLevelKeyboardProc") | |
exit | |
SetWindowsHookEx(idHook, callback) { | |
if (!hHook := DllCall(Format("SetWindowsHookEx{}", (A_IsUnicode) ? ("W") : ("A")), "Int", idHook, "Ptr", RegisterCallback(callback, "Fast"), "Ptr", DllCall("GetModuleHandle", "UInt", 0, "Ptr"), "UInt", 0, "Ptr")) { | |
throw (Exception(Format("0x{:X}", A_LastError), -1, FormatMessage(A_LastError))) | |
} |