├── LICENSE ├── README.md └── src ├── Clipboard Functions ├── CloseClipboard.ahk ├── EmptyClipboard.ahk └── OpenClipboard.ahk ├── Cursor Functions ├── GetCursorInfo.ahk ├── GetCursorPos.ahk ├── GetPhysicalCursorPos.ahk ├── SetCursorPos.ahk └── SetPhysicalCursorPos.ahk ├── Directory Management Functions ├── CreateDirectory.ahk ├── RemoveDirectory.ahk └── SetCurrentDirectory.ahk ├── Disk Management Functions ├── GetDiskFreeSpace.ahk └── GetDiskFreeSpaceEx.ahk ├── Error Handling Functions ├── Beep.ahk ├── FormatMessage.ahk └── GetLastError.ahk ├── File Management Functions ├── CopyFile.ahk ├── DeleteFile.ahk ├── GetFileAttributes.ahk ├── GetFileSize.ahk ├── GetFileSizeEx.ahk ├── GetTempPath.ahk ├── MoveFile.ahk └── MoveFileEx.ahk ├── IP Helper Functions ├── GetIpStatistics.ahk ├── GetIpStatisticsEx.ahk ├── GetTcpStatistics.ahk ├── GetTcpStatisticsEx.ahk ├── GetUdpStatistics.ahk └── GetUdpStatisticsEx.ahk ├── Keyboard Input Functions ├── BlockInput.ahk ├── GetKBCodePage.ahk └── GetKeyboardLayout.ahk ├── Memory Management Functions ├── GetPhysicallyInstalledSystemMemory.ahk └── GlobalMemoryStatusEx.ahk ├── Mouse Input Functions ├── ClipCursor.ahk ├── GetCapture.ahk ├── GetDoubleClickTime.ahk ├── ReleaseCapture.ahk ├── SetDoubleClickTime.ahk └── SwapMouseButton.ahk ├── Multimedia Functions └── timeGetTime.ahk ├── National Language Support Functions └── GetDurationFormat.ahk ├── Others └── ZwDelayExecution.ahk ├── PSAPI Functions ├── GetModuleFileNameEx.ahk └── GetProcessMemoryInfo.ahk ├── Process and Thread Functions ├── GetActiveProcessorCount.ahk ├── GetActiveProcessorGroupCount.ahk ├── GetCommandLine.ahk ├── GetCurrentProcess.ahk ├── GetCurrentProcessId.ahk ├── GetCurrentProcessorNumber.ahk ├── GetCurrentThread.ahk ├── GetCurrentThreadId.ahk ├── GetMaximumProcessorCount.ahk ├── GetMaximumProcessorGroupCount.ahk ├── GetProcessVersion.ahk ├── Sleep.ahk └── SleepEx.ahk ├── String Functions ├── CharLower.ahk ├── CharLowerBuff.ahk ├── CharUpper.ahk └── CharUpperBuff.ahk ├── System Information Functions ├── GetComputerName.ahk ├── GetProductInfo.ahk ├── GetSystemDirectory.ahk ├── GetSystemRegistryQuota.ahk ├── GetSystemWindowsDirectory.ahk ├── GetSystemWow64Directory.ahk ├── GetUserName.ahk ├── GetUserNameEx.ahk ├── GetVersion.ahk ├── GetVersionEx.ahk ├── GetWindowsDirectory.ahk ├── QueryPerformanceCounter.ahk └── QueryPerformanceFrequency.ahk ├── System Shutdown Functions └── LockWorkStation.ahk ├── Time Functions ├── GetLocalTime.ahk ├── GetSystemTime.ahk ├── GetTickCount.ahk ├── GetTickCount64.ahk ├── SetLocalTime.ahk └── SetSystemTime.ahk └── Volume Management Functions └── GetDriveType.ahk /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AutoHotkey, WinAPI & DllCall's by jNizM 2 | AHK --> DllCall --> WinAPI 3 | 4 | ## Current 5 | 6 | ### Clipboard Functions 7 | * [CloseClipboard](src/Clipboard Functions/CloseClipboard.ahk) 8 | * [EmptyClipboard](src/Clipboard Functions/EmptyClipboard.ahk) 9 | * [OpenClipboard](src/Clipboard Functions/OpenClipboard.ahk) 10 | 11 | ### Cursor Functions 12 | * [GetCursorInfo](src/Cursor Functions/GetCursorInfo.ahk) 13 | * [GetCursorPos](src/Cursor Functions/GetCursorPos.ahk) 14 | * [GetPhysicalCursorPos](src/Cursor Functions/GetPhysicalCursorPos.ahk) 15 | * [SetCursorPos](src/Cursor Functions/SetCursorPos.ahk) 16 | * [SetPhysicalCursorPos](src/Cursor Functions/SetPhysicalCursorPos.ahk) 17 | 18 | ### Directory Management Functions 19 | * [CreateDirectory](src/Directory Management Functions/CreateDirectory.ahk) 20 | * [RemoveDirectory](src/Directory Management Functions/RemoveDirectory.ahk) 21 | * [SetCurrentDirectory](src/Directory Management Functions/SetCurrentDirectory.ahk) 22 | 23 | ### Disk Management Functions 24 | * [GetDiskFreeSpace](src/Disk Management Functions/GetDiskFreeSpace.ahk) 25 | * [GetDiskFreeSpaceEx](src/Disk Management Functions/GetDiskFreeSpaceEx.ahk) 26 | 27 | ### Error Handling Functions 28 | * [Beep](src/Error Handling Functions/Beep.ahk) 29 | * [FormatMessage](src/Error Handling Functions/FormatMessage.ahk) 30 | * [GetLastError](src/Error Handling Functions/GetLastError.ahk) 31 | 32 | ### File Management Functions 33 | * [CopyFile](src/File Management Functions/CopyFile.ahk) 34 | * [DeleteFile](src/File Management Functions/DeleteFile.ahk) 35 | * [GetFileAttributes](src/File Management Functions/GetFileAttributes.ahk) 36 | * [GetFileSize](src/File Management Functions/GetFileSize.ahk) 37 | * [GetFileSizeEx](src/File Management Functions/GetFileSizeEx.ahk) 38 | * [GetTempPath](src/File Management Functions/GetTempPath.ahk) 39 | * [MoveFile](src/File Management Functions/MoveFile.ahk) 40 | * [MoveFileEx](src/File Management Functions/MoveFileEx.ahk) 41 | 42 | ### IP Helper Functions 43 | * [GetIpStatistics](src/IP Helper Functions/GetIpStatistics.ahk) 44 | * [GetIpStatisticsEx](src/IP Helper Functions/GetIpStatisticsEx.ahk) 45 | * [GetTcpStatistics](src/IP Helper Functions/GetTcpStatistics.ahk) 46 | * [GetTcpStatisticsEx](src/IP Helper Functions/GetTcpStatisticsEx.ahk) 47 | * [GetUdpStatistics](src/IP Helper Functions/GetUdpStatistics.ahk) 48 | * [GetUdpStatisticsEx](src/IP Helper Functions/GetUdpStatisticsEx.ahk) 49 | 50 | ### Keyboard Input Functions 51 | * [BlockInput](src/Keyboard Input Functions/BlockInput.ahk) 52 | * [GetKBCodePage](src/Keyboard Input Functions/GetKBCodePage.ahk) 53 | * [GetKeyboardLayout](src/Keyboard Input Functions/GetKeyboardLayout.ahk) 54 | 55 | ### Memory Management Functions 56 | * [GetPhysicallyInstalledSystemMemory](src/Memory Management Functions/GetPhysicallyInstalledSystemMemory.ahk) 57 | * [GlobalMemoryStatusEx](src/Memory Management Functions/GlobalMemoryStatusEx.ahk) 58 | 59 | ### Mouse Input Functions 60 | * [ClipCursor](src/Mouse Input Functions/ClipCursor.ahk) 61 | * [GetCapture](src/Mouse Input Functions/GetCapture.ahk) 62 | * [GetDoubleClickTime](src/Mouse Input Functions/GetDoubleClickTime.ahk) 63 | * [ReleaseCapture](src/Mouse Input Functions/ReleaseCapture.ahk) 64 | * [SetDoubleClickTime](src/Mouse Input Functions/SetDoubleClickTime.ahk) 65 | * [SwapMouseButton](src/Mouse Input Functions/SwapMouseButton.ahk) 66 | 67 | ### Multimedia Functions 68 | * [timeGetTime](src/Multimedia Functions/timeGetTime.ahk) 69 | 70 | ### National Language Support Functions 71 | * [GetDurationFormat](src/National Language Support Functions/GetDurationFormat.ahk) 72 | 73 | ### Process and Thread Functions 74 | * [GetActiveProcessorCount](src/Process and Thread Functions/GetActiveProcessorCount.ahk) 75 | * [GetActiveProcessorGroupCount](src/Process and Thread Functions/GetActiveProcessorGroupCount.ahk) 76 | * [GetCommandLine](src/Process and Thread Functions/GetCommandLine.ahk) 77 | * [GetCurrentProcess](src/Process and Thread Functions/GetCurrentProcess.ahk) 78 | * [GetCurrentProcessId](src/Process and Thread Functions/GetCurrentProcessId.ahk) 79 | * [GetCurrentProcessorNumber](src/Process and Thread Functions/GetCurrentProcessorNumber.ahk) 80 | * [GetCurrentThread](src/Process and Thread Functions/GetCurrentThread.ahk) 81 | * [GetCurrentThreadId](src/Process and Thread Functions/GetCurrentThreadId.ahk) 82 | * [GetMaximumProcessorCount](src/Process and Thread Functions/GetMaximumProcessorCount.ahk) 83 | * [GetMaximumProcessorGroupCount](src/Process and Thread Functions/GetMaximumProcessorGroupCount.ahk) 84 | * [GetProcessVersion](src/Process and Thread Functions/GetProcessVersion.ahk) 85 | * [Sleep](src/Process and Thread Functions/Sleep.ahk) 86 | * [SleepEx](src/Process and Thread Functions/SleepEx.ahk) 87 | 88 | ### PSAPI Functions 89 | * [GetModuleFileNameEx](src/PSAPI Functions/GetModuleFileNameEx.ahk) 90 | * [GetProcessMemoryInfo](src/PSAPI Functions/GetProcessMemoryInfo.ahk) 91 | 92 | ### String Functions 93 | * [CharLower](src/String Functions/CharLower.ahk) 94 | * [CharLowerBuff](src/String Functions/CharLowerBuff.ahk) 95 | * [CharUpper](src/String Functions/CharUpper.ahk) 96 | * [CharUpperBuff](src/String Functions/CharUpperBuff.ahk) 97 | 98 | ### System Information Functions 99 | * [GetComputerName](src/System Information Functions/GetComputerName.ahk) 100 | * [GetProductInfo](src/System Information Functions/GetProductInfo.ahk) 101 | * [GetSystemDirectory](src/System Information Functions/GetSystemDirectory.ahk) 102 | * [GetSystemRegistryQuota](src/System Information Functions/GetSystemRegistryQuota.ahk) 103 | * [GetSystemWindowsDirectory](src/System Information Functions/GetSystemWindowsDirectory.ahk) 104 | * [GetSystemWow64Directory](src/System Information Functions/GetSystemWow64Directory.ahk) 105 | * [GetUserName](src/System Information Functions/GetUserName.ahk) 106 | * [GetUserNameEx](src/System Information Functions/GetUserNameEx.ahk) 107 | * [GetVersion](src/System Information Functions/GetVersion.ahk) 108 | * [GetVersionEx](src/System Information Functions/GetVersionEx.ahk) 109 | * [GetWindowsDirectory](src/System Information Functions/GetWindowsDirectory.ahk) 110 | * [QueryPerformanceCounter](src/System Information Functions/QueryPerformanceCounter.ahk) 111 | * [QueryPerformanceFrequency](src/System Information Functions/QueryPerformanceFrequency.ahk) 112 | 113 | ### System Shutdown Functions 114 | * [LockWorkStation](src/System Shutdown Functions/LockWorkStation.ahk) 115 | 116 | ### Time Functions 117 | * [GetLocalTime](src/Time Functions/GetLocalTime.ahk) 118 | * [GetSystemTime](src/Time Functions/GetSystemTime.ahk) 119 | * [GetTickCount](src/Time Functions/GetTickCount.ahk) 120 | * [GetTickCount64](src/Time Functions/GetTickCount64.ahk) 121 | * [SetLocalTime](src/Time Functions/SetLocalTime.ahk) 122 | * [SetSystemTime](src/Time Functions/SetSystemTime.ahk) 123 | 124 | ### Volume Management Functions 125 | * [GetDriveType](src/Volume Management Functions/GetDriveType.ahk) 126 | 127 | ### Others 128 | * [ZwDelayExecution](src/Others/ZwDelayExecution.ahk) 129 | 130 | 131 | ## Info 132 | * URL: [AHK Thread](http://ahkscript.org/boards/viewtopic.php?f=7&t=406) 133 | 134 | 135 | ## Contributing 136 | * thanks to AutoHotkey Community 137 | 138 | 139 | ## Copyright and License 140 | [Unlicense](LICENSE) -------------------------------------------------------------------------------- /src/Clipboard Functions/CloseClipboard.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: CloseClipboard 3 | ; DLL...........: User32.dll 4 | ; Library.......: User32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms649035.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms649035.aspx 10 | ; =============================================================================================================================== 11 | CloseClipboard() 12 | { 13 | if !(DllCall("user32.dll\CloseClipboard")) 14 | return DllCall("kernel32.dll\GetLastError") 15 | return 1 16 | } 17 | ; =============================================================================================================================== 18 | 19 | CloseClipboard() 20 | 21 | 22 | 23 | 24 | 25 | /* C++ ========================================================================================================================== 26 | BOOL WINAPI CloseClipboard(void); // UInt 27 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Clipboard Functions/EmptyClipboard.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: EmptyClipboard 3 | ; DLL...........: User32.dll 4 | ; Library.......: User32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms649037.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms649037.aspx 10 | ; =============================================================================================================================== 11 | EmptyClipboard() 12 | { 13 | if !(DllCall("user32.dll\EmptyClipboard")) 14 | return DllCall("kernel32.dll\GetLastError") 15 | return 1 16 | } 17 | ; =============================================================================================================================== 18 | 19 | OpenClipboard() 20 | EmptyClipboard() 21 | CloseClipboard() 22 | 23 | 24 | 25 | 26 | 27 | /* C++ ========================================================================================================================== 28 | BOOL WINAPI EmptyClipboard(void); // UInt 29 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Clipboard Functions/OpenClipboard.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: OpenClipboard 3 | ; DLL...........: User32.dll 4 | ; Library.......: User32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms649048.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms649048.aspx 10 | ; =============================================================================================================================== 11 | OpenClipboard(NewOwner = 0) 12 | { 13 | if !(DllCall("user32.dll\OpenClipboard", "Ptr", NewOwner)) 14 | return DllCall("kernel32.dll\GetLastError") 15 | return 1 16 | } 17 | ; =============================================================================================================================== 18 | 19 | OpenClipboard() 20 | 21 | 22 | 23 | 24 | 25 | /* C++ ========================================================================================================================== 26 | BOOL WINAPI OpenClipboard( // UInt 27 | _In_opt_ HWND hWndNewOwner // Ptr 28 | ); 29 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Cursor Functions/GetCursorInfo.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author ........: jNizM 3 | ; Released ......: 2015-03-11 4 | ; Modified ......: 2023-01-10 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: GetCursorInfo() 8 | ; 9 | ; Parameter(s)...: No parameters used 10 | ; 11 | ; Return ........: Retrieves information about the global cursor. 12 | ; ============================================================================================================================================================= 13 | 14 | #Requires AutoHotkey v2.0 15 | 16 | GetCursorInfo() 17 | { 18 | CURSORINFO := Buffer(16 + A_PtrSize, 0) 19 | NumPut("UInt", CURSORINFO.Size, CURSORINFO, 0) 20 | if (DllCall("user32\GetCursorInfo", "Ptr", CURSORINFO)) 21 | { 22 | tagCURSORINFO := Map() 23 | tagCURSORINFO["Flags"] := NumGet(CURSORINFO, 4, "UInt") 24 | tagCURSORINFO["hCursor"] := NumGet(CURSORINFO, 8, "Ptr") 25 | tagCURSORINFO["X"] := NumGet(CURSORINFO, 8 + A_PtrSize, "Int") 26 | tagCURSORINFO["Y"] := NumGet(CURSORINFO, 12 + A_PtrSize, "Int") 27 | return tagCURSORINFO 28 | } 29 | return false 30 | } 31 | 32 | 33 | ; ============================================================================================================================================================= 34 | ; Example 35 | ; ============================================================================================================================================================= 36 | 37 | CursorInfo := GetCursorInfo() 38 | MsgBox "Flags:`t`t" CursorInfo["Flags"] "`n" 39 | . "hCursor:`t`t" CursorInfo["hCursor"] "`n" 40 | . "x-coord:`t`t" CursorInfo["X"] "`n" 41 | . "y-coord:`t`t" CursorInfo["Y"] 42 | 43 | 44 | 45 | /* C++ ========================================================================================================================== 46 | BOOL GetCursorInfo( // Int 47 | [in, out] PCURSORINFO pci // Ptr 48 | ); 49 | 50 | 51 | typedef struct tagCURSORINFO { 52 | DWORD cbSize; // UInt 53 | DWORD flags; // UInt 54 | HCURSOR hCursor; // Ptr 55 | POINT ptScreenPos; // => POINT 56 | } CURSORINFO, *PCURSORINFO, *LPCURSORINFO; 57 | 58 | 59 | typedef struct tagPOINT { 60 | LONG x; // Int 61 | LONG y; // Int 62 | } POINT, *PPOINT, *NPPOINT, *LPPOINT; 63 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Cursor Functions/GetCursorPos.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetCursorPos 3 | ; DLL...........: User32.dll 4 | ; Library.......: User32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms648390.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/aa969464.aspx 10 | ; =============================================================================================================================== 11 | GetCursorPos() 12 | { 13 | static POINT, init := VarSetCapacity(POINT, 8, 0) && NumPut(8, POINT, "Int") 14 | if !(DllCall("user32.dll\GetCursorPos", "Ptr", &POINT)) 15 | return DllCall("kernel32.dll\GetLastError") 16 | return { 1 : NumGet(POINT, 0, "Int"), 2 : NumGet(POINT, 4, "Int") } 17 | } 18 | ; =============================================================================================================================== 19 | 20 | GetCursorPos := GetCursorPos() 21 | 22 | MsgBox % "GetCursorPos function`n" 23 | . "POINT structure`n`n" 24 | . "x-coordinate:`t`t" GetCursorPos[1] "`n" 25 | . "y-coordinate:`t`t" GetCursorPos[2] 26 | 27 | 28 | 29 | 30 | 31 | /* C++ ========================================================================================================================== 32 | BOOL WINAPI GetCursorPos( // UInt 33 | _Out_ LPPOINT lpPoint // Ptr (8) 34 | ); 35 | 36 | 37 | typedef struct tagPOINT { 38 | LONG x; // Int 4 => 0 39 | LONG y; // Int 4 => 4 40 | } POINT, *PPOINT; 41 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Cursor Functions/GetPhysicalCursorPos.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetPhysicalCursorPos 3 | ; DLL...........: User32.dll 4 | ; Library.......: User32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/aa969464.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/aa969464.aspx 10 | ; =============================================================================================================================== 11 | GetPhysicalCursorPos() 12 | { 13 | static POINT, init := VarSetCapacity(POINT, 8, 0) && NumPut(8, POINT, "Int") 14 | if !(DllCall("user32.dll\GetPhysicalCursorPos", "Ptr", &POINT)) 15 | return DllCall("kernel32.dll\GetLastError") 16 | return { 1 : NumGet(POINT, 0, "Int"), 2 : NumGet(POINT, 4, "Int") } 17 | } 18 | ; =============================================================================================================================== 19 | 20 | GetPhysicalCursorPos := GetPhysicalCursorPos() 21 | 22 | MsgBox % "GetPhysicalCursorPos function`n" 23 | . "POINT structure`n`n" 24 | . "x-coordinate:`t`t" GetPhysicalCursorPos[1] "`n" 25 | . "y-coordinate:`t`t" GetPhysicalCursorPos[2] 26 | 27 | 28 | 29 | 30 | 31 | /* C++ ========================================================================================================================== 32 | BOOL WINAPI GetPhysicalCursorPos( // UInt 33 | _Out_ LPPOINT lpPoint // Ptr (8) 34 | ); 35 | 36 | 37 | typedef struct tagPOINT { 38 | LONG x; // Int 4 => 0 39 | LONG y; // Int 4 => 4 40 | } POINT, *PPOINT; 41 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Cursor Functions/SetCursorPos.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: SetCursorPos 3 | ; DLL...........: User32.dll 4 | ; Library.......: User32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms648394.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms648394.aspx 10 | ; =============================================================================================================================== 11 | SetCursorPos(X, Y) 12 | { 13 | if !(DllCall("user32.dll\SetCursorPos", "Int", X, "Int", Y)) 14 | return DllCall("kernel32.dll\GetLastError") 15 | return 1 16 | } 17 | ; =============================================================================================================================== 18 | 19 | SetCursorPos(750, 500) 20 | 21 | 22 | 23 | 24 | 25 | /* C++ ========================================================================================================================== 26 | BOOL WINAPI SetCursorPos( // UInt 27 | _In_ int X, // Int 28 | _In_ int Y // Int 29 | ); 30 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Cursor Functions/SetPhysicalCursorPos.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: SetPhysicalCursorPos 3 | ; DLL...........: User32.dll 4 | ; Library.......: User32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/desktop/aa969465.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/aa969465.aspx 10 | ; =============================================================================================================================== 11 | SetPhysicalCursorPos(X, Y) 12 | { 13 | if !(DllCall("user32.dll\SetPhysicalCursorPos", "Int", X, "Int", Y)) 14 | return DllCall("kernel32.dll\GetLastError") 15 | return 1 16 | } 17 | ; =============================================================================================================================== 18 | 19 | SetPhysicalCursorPos(750, 500) 20 | 21 | 22 | 23 | 24 | 25 | /* C++ ========================================================================================================================== 26 | BOOL WINAPI SetPhysicalCursorPos( // UInt 27 | _In_ int X, // Int 28 | _In_ int Y // Int 29 | ); 30 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Directory Management Functions/CreateDirectory.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: CreateDirectory 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: CreateDirectoryW (Unicode) and CreateDirectoryA (ANSI) 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/aa363855.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/aa363855.aspx 10 | ; =============================================================================================================================== 11 | CreateDirectory(PathName) 12 | { 13 | if !(DllCall("kernel32.dll\CreateDirectory", "Str", PathName, "Ptr", 0)) 14 | return DllCall("kernel32.dll\GetLastError") 15 | return 1 16 | } 17 | ; =============================================================================================================================== 18 | 19 | CreateDirectory("C:\Temp\Directory") 20 | 21 | 22 | 23 | 24 | 25 | /* C++ ========================================================================================================================== 26 | BOOL WINAPI CreateDirectory( // UInt 27 | _In_ LPCTSTR lpPathName, // Str 28 | _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes // Ptr 29 | ); 30 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Directory Management Functions/RemoveDirectory.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: RemoveDirectory 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: RemoveDirectoryW (Unicode) and RemoveDirectoryA (ANSI) 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/aa365488.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/aa365488.aspx 10 | ; =============================================================================================================================== 11 | RemoveDirectory(PathName) 12 | { 13 | if !(DllCall("kernel32.dll\RemoveDirectory", "Str", PathName)) 14 | return DllCall("kernel32.dll\GetLastError") 15 | return 1 16 | } 17 | ; =============================================================================================================================== 18 | 19 | RemoveDirectory("C:\Temp\Directory") 20 | 21 | 22 | 23 | 24 | 25 | /* C++ ========================================================================================================================== 26 | BOOL WINAPI RemoveDirectory( // UInt 27 | _In_ LPCTSTR lpPathName // Str 28 | ); 29 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Directory Management Functions/SetCurrentDirectory.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: SetCurrentDirectory 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: SetCurrentDirectoryW (Unicode) and SetCurrentDirectoryA (ANSI) 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/aa365530.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/aa365530.aspx 10 | ; =============================================================================================================================== 11 | SetCurrentDirectory(PathName) 12 | { 13 | if !(DllCall("kernel32.dll\SetCurrentDirectory", "Str", PathName)) 14 | return DllCall("kernel32.dll\GetLastError") 15 | return 1 16 | } 17 | ; =============================================================================================================================== 18 | 19 | SetCurrentDirectory("C:\Temp\Directory") 20 | 21 | 22 | 23 | 24 | 25 | /* C++ ========================================================================================================================== 26 | BOOL WINAPI SetCurrentDirectory( // UInt 27 | _In_ LPCTSTR lpPathName // Str 28 | ); 29 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Disk Management Functions/GetDiskFreeSpace.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetDiskFreeSpace 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: GetDiskFreeSpaceW (Unicode) and GetDiskFreeSpaceA (ANSI) 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/aa364935.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/aa364935.aspx 10 | ; =============================================================================================================================== 11 | GetDiskFreeSpace(path) 12 | { 13 | if !(DllCall("kernel32.dll\GetDiskFreeSpace", "Str", path, "UInt*", sector, "UInt*", bytes, "UInt*", free, "UInt*", total)) 14 | return DllCall("kernel32.dll\GetLastError") 15 | return (sector * bytes * free) 16 | } 17 | ; =============================================================================================================================== 18 | 19 | MsgBox % GetDiskFreeSpace("C:\") " Bytes`n" 20 | . Round(GetDiskFreeSpace("C:\") / 1024, 2) " KB`n" 21 | . Round(GetDiskFreeSpace("C:\") / 1024**2, 2) " MB`n" 22 | . Round(GetDiskFreeSpace("C:\") / 1024**3, 2) " GB" 23 | 24 | 25 | 26 | 27 | 28 | /* C++ ========================================================================================================================== 29 | BOOL WINAPI GetDiskFreeSpace( // UInt 30 | _In_ LPCTSTR lpRootPathName, // Str 31 | _Out_ LPDWORD lpSectorsPerCluster, // UInt* 32 | _Out_ LPDWORD lpBytesPerSector, // UInt* 33 | _Out_ LPDWORD lpNumberOfFreeClusters, // UInt* 34 | _Out_ LPDWORD lpTotalNumberOfClusters // UInt* 35 | ); 36 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Disk Management Functions/GetDiskFreeSpaceEx.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetDiskFreeSpaceEx 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: GetDiskFreeSpaceExW (Unicode) and GetDiskFreeSpaceExA (ANSI) 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/aa364937.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/aa364937.aspx 10 | ; =============================================================================================================================== 11 | GetDiskFreeSpaceEx(directory) 12 | { 13 | static size := 8, init := VarSetCapacity(free, size, 0) && VarSetCapacity(total, size, 0) && VarSetCapacity(tfree, size, 0) 14 | if !(DllCall("kernel32.dll\GetDiskFreeSpaceEx", "Str", directory, "UInt64", &free, "UInt64", &total, "UInt64", &tfree)) 15 | return DllCall("kernel32.dll\GetLastError") 16 | return { 1 : NumGet(free, 0, "UInt64"), 2 : NumGet(total, 0, "UInt64"), 3 : NumGet(tfree, 0, "UInt64") } 17 | } 18 | ; =============================================================================================================================== 19 | 20 | GetDiskFreeSpaceEx := GetDiskFreeSpaceEx("C:\") 21 | 22 | MsgBox % "FreeBytesAvailable:`t`t" GetDiskFreeSpaceEx[1] " Bytes`n" 23 | . "TotalNumberOfBytes:`t" GetDiskFreeSpaceEx[2] " Bytes`n" 24 | . "TotalNumberOfFreeBytes:`t" GetDiskFreeSpaceEx[3] " Bytes" 25 | 26 | 27 | 28 | 29 | 30 | /* C++ ========================================================================================================================== 31 | BOOL WINAPI GetDiskFreeSpaceEx( // UInt 32 | _In_opt_ LPCTSTR lpDirectoryName, // Str 33 | _Out_opt_ PULARGE_INTEGER lpFreeBytesAvailable, // UInt64 34 | _Out_opt_ PULARGE_INTEGER lpTotalNumberOfBytes, // UInt64 35 | _Out_opt_ PULARGE_INTEGER lpTotalNumberOfFreeBytes // UInt64 36 | ); 37 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Error Handling Functions/Beep.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: Beep 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms679277.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms679277.aspx 10 | ; =============================================================================================================================== 11 | Beep(Freq, Duration) 12 | { 13 | if !(DllCall("kernel32.dll\Beep", "UInt", Freq, "UInt", Duration)) 14 | return DllCall("kernel32.dll\GetLastError") 15 | return 1 16 | } 17 | ; =============================================================================================================================== 18 | 19 | Beep(750, 300) 20 | 21 | 22 | 23 | 24 | 25 | /* C++ ========================================================================================================================== 26 | BOOL WINAPI Beep( // UInt 27 | _In_ DWORD dwFreq, // UInt 28 | _In_ DWORD dwDuration // UInt 29 | ); 30 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Error Handling Functions/FormatMessage.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: FormatMessage 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: FormatMessageW (Unicode) and FormatMessageA (ANSI) 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms679351.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms679351.aspx 10 | ; =============================================================================================================================== 11 | FormatMessage(MessageId) 12 | { 13 | static size := 2024, init := VarSetCapacity(buf, size) 14 | if !(DllCall("kernel32.dll\FormatMessage", "UInt", 0x1000, "Ptr", 0, "UInt", MessageId, "UInt", 0x0800, "Ptr", &buf, "UInt", size, "UInt*", 0)) 15 | return DllCall("kernel32.dll\GetLastError") 16 | return StrGet(&buf) 17 | } 18 | ; =============================================================================================================================== 19 | 20 | MsgBox % DeleteFile("C:\Temp\TestFile.txt") 21 | 22 | DeleteFile(FileName) 23 | { 24 | if !(DllCall("kernel32.dll\DeleteFile", "Str", FileName)) 25 | return FormatMessage(DllCall("kernel32.dll\GetLastError")) 26 | return 1 27 | } 28 | 29 | 30 | 31 | 32 | 33 | /* C++ ========================================================================================================================== 34 | DWORD WINAPI FormatMessage( // UInt 35 | _In_ DWORD dwFlags, // UInt 36 | _In_opt_ LPCVOID lpSource, // Ptr 37 | _In_ DWORD dwMessageId, // UInt 38 | _In_ DWORD dwLanguageId, // UInt 39 | _Out_ LPTSTR lpBuffer, // Ptr 40 | _In_ DWORD nSize, // UInt 41 | _In_opt_ va_list *Arguments // UInt 42 | ); 43 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Error Handling Functions/GetLastError.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetLastError 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms679360.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms679360.aspx 10 | ; =============================================================================================================================== 11 | GetLastError() 12 | { 13 | return DllCall("kernel32.dll\GetLastError") 14 | } 15 | 16 | ; =============================================================================================================================== 17 | 18 | MsgBox % DeleteFile("C:\Temp\TestFile.txt") 19 | 20 | DeleteFile(FileName) 21 | { 22 | if !(DllCall("kernel32.dll\DeleteFile", "Str", FileName)) 23 | return GetLastError() 24 | return 1 25 | } 26 | 27 | 28 | 29 | 30 | 31 | /* C++ ========================================================================================================================== 32 | DWORD WINAPI GetLastError(void); // UInt 33 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/File Management Functions/CopyFile.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: CopyFile 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: CopyFileW (Unicode) and CopyFileA (ANSI) 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/aa363851.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/aa363851.aspx 10 | ; =============================================================================================================================== 11 | CopyFile(ExistingFileName, NewFileName, FailIfExists) 12 | { 13 | if !(DllCall("kernel32.dll\CopyFile", "Str", ExistingFileName, "Str", NewFileName, "UInt", FailIfExists)) 14 | return DllCall("kernel32.dll\GetLastError") 15 | return 1 16 | } 17 | ; =============================================================================================================================== 18 | 19 | CopyFile("C:\Temp\TestFile.txt", "C:\Temp\TestFile_Copy.txt", 0) 20 | 21 | 22 | 23 | 24 | 25 | /* C++ ========================================================================================================================== 26 | BOOL WINAPI CopyFile( // UInt 27 | _In_ LPCTSTR lpExistingFileName, // Str 28 | _In_ LPCTSTR lpNewFileName, // Str 29 | _In_ BOOL bFailIfExists // UInt 30 | ); 31 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/File Management Functions/DeleteFile.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: DeleteFile 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: DeleteFileW (Unicode) and DeleteFileA (ANSI) 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/aa363915.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/aa363915.aspx 10 | ; =============================================================================================================================== 11 | DeleteFile(FileName) 12 | { 13 | if !(DllCall("kernel32.dll\DeleteFile", "Str", FileName)) 14 | return DllCall("kernel32.dll\GetLastError") 15 | return 1 16 | } 17 | ; =============================================================================================================================== 18 | 19 | DeleteFile("C:\Temp\TestFile.txt") 20 | 21 | 22 | 23 | 24 | 25 | /* C++ ========================================================================================================================== 26 | BOOL WINAPI DeleteFile( // UInt 27 | _In_ LPCTSTR lpFileName // Str 28 | ); 29 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/File Management Functions/GetFileAttributes.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetFileAttributes 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: GetFileAttributesW (Unicode) and GetFileAttributesA (ANSI) 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/aa364944.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/aa364944.aspx 10 | ; =============================================================================================================================== 11 | GetFileAttributes(FileName) 12 | { 13 | if ((ret := DllCall("kernel32.dll\GetFileAttributes", "Str", FileName)) = -1) 14 | return "*" DllCall("kernel32.dll\GetLastError") 15 | return ret 16 | } 17 | ; =============================================================================================================================== 18 | 19 | MsgBox % GetFileAttributes("C:\Windows\Notepad.exe") "`n" 20 | . GetFileAttributes("C:\Windows\") 21 | 22 | ; File Attribute Constants 23 | ; https://msdn.microsoft.com/en-us/library/gg258117.aspx 24 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/gg258117.aspx 25 | 26 | 27 | 28 | 29 | 30 | /* C++ ========================================================================================================================== 31 | DWORD WINAPI GetFileAttributes( // UInt 32 | _In_ LPCTSTR lpFileName // Str 33 | ); 34 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/File Management Functions/GetFileSize.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetFileSize 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/aa364955.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/aa364955.aspx 10 | ; =============================================================================================================================== 11 | GetFileSize(File) 12 | { 13 | if ((hFile := DllCall("kernel32.dll\CreateFile", "Str", File, "UInt", 0x80000000, "UInt", 1, "Ptr", 0, "UInt", 3, "UInt", 0, "Ptr", 0)) = -1 ) 14 | return DllCall("kernel32.dll\GetLastError") 15 | if !(ret := DllCall("kernel32.dll\GetFileSize", "UInt", hFile, "Ptr", 0)) 16 | return DllCall("kernel32.dll\GetLastError") 17 | DllCall("kernel32.dll\CloseHandle", "UInt", hFile) 18 | return ret 19 | } 20 | ; =============================================================================================================================== 21 | 22 | MsgBox % GetFileSize("C:\Windows\Notepad.exe") " Bytes" 23 | 24 | 25 | 26 | 27 | 28 | /* C++ ========================================================================================================================== 29 | DWORD WINAPI GetFileSize( // UInt 30 | _In_ HANDLE hFile, // UInt 31 | _Out_opt_ LPDWORD lpFileSizeHigh // Ptr 32 | ); 33 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/File Management Functions/GetFileSizeEx.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetFileSizeEx 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/windows/desktop/aa364957(v=vs.85).aspx 9 | ; =============================================================================================================================== 10 | GetFileSizeEx(File) 11 | { 12 | static FileSize, init := VarSetCapacity(FileSize, 1048576, 0) 13 | if ((hFile := DllCall("kernel32.dll\CreateFile", "Str", File, "UInt", 0x80000000, "UInt", 1, "Ptr", 0, "UInt", 3, "UInt", 0, "Ptr", 0)) = -1 ) 14 | return DllCall("kernel32.dll\GetLastError") 15 | if !(DllCall("kernel32.dll\GetFileSizeEx", "UInt", hFile, "UInt", &FileSize)) 16 | return DllCall("kernel32.dll\GetLastError") 17 | FileSize := NumGet(FileSize, 0, "Int64*") 18 | DllCall("kernel32.dll\CloseHandle", "UInt", hFile) 19 | return FileSize 20 | } 21 | ; =============================================================================================================================== 22 | 23 | MsgBox % GetFileSizeEx("C:\Windows\notepad.exe") " Bytes" 24 | 25 | 26 | 27 | 28 | 29 | /* C++ ========================================================================================================================== 30 | BOOL WINAPI GetFileSizeEx( // UInt 31 | _In_ HANDLE hFile, // UInt 32 | _Out_ PLARGE_INTEGER lpFileSize // Int64* 33 | ); 34 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/File Management Functions/GetTempPath.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetTempPath 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: GetTempPathW (Unicode) and GetTempPathA (ANSI) 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/aa364992.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/aa364992.aspx 10 | ; =============================================================================================================================== 11 | GetTempPath() 12 | { 13 | static len := 260 + 1, init := VarSetCapacity(buf, len * (A_IsUnicode ? 2 : 1)) 14 | if !(DllCall("kernel32.dll\GetTempPath", "UInt", len, "Ptr", &buf)) 15 | return DllCall("kernel32.dll\GetLastError") 16 | return StrGet(&buf) 17 | } 18 | ; =============================================================================================================================== 19 | 20 | MsgBox % GetTempPath() 21 | 22 | 23 | 24 | 25 | 26 | /* C++ ========================================================================================================================== 27 | DWORD WINAPI GetTempPath( // UInt 28 | _In_ DWORD nBufferLength, // UInt 29 | _Out_ LPTSTR lpBuffer // Ptr 30 | ); 31 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/File Management Functions/MoveFile.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: MoveFile 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: MoveFileW (Unicode) and MoveFileA (ANSI) 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/desktop/aa365239.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/aa365239.aspx 10 | ; =============================================================================================================================== 11 | MoveFile(ExistingFileName, NewFileName) 12 | { 13 | if !(DllCall("kernel32.dll\MoveFile", "Str", ExistingFileName, "Str", NewFileName)) 14 | return DllCall("kernel32.dll\GetLastError") 15 | return 1 16 | } 17 | ; =============================================================================================================================== 18 | 19 | MoveFile("C:\Temp\TestFile.txt", "C:\Temp\TestFile_Move.txt") 20 | 21 | 22 | 23 | 24 | 25 | /* C++ ========================================================================================================================== 26 | BOOL WINAPI MoveFile( // UInt 27 | _In_ LPCTSTR lpExistingFileName, // Str 28 | _In_ LPCTSTR lpNewFileName // Str 29 | ); 30 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/File Management Functions/MoveFileEx.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: MoveFileEx 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: MoveFileExW (Unicode) and MoveFileExA (ANSI) 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/aa365240.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/aa365240.aspx 10 | ; =============================================================================================================================== 11 | MoveFileEx(ExistingFileName, NewFileName, Flags) 12 | { 13 | if !(DllCall("kernel32.dll\MoveFileEx", "Str", ExistingFileName, "Str", NewFileName, "UInt", Flags)) 14 | return DllCall("kernel32.dll\GetLastError") 15 | return 1 16 | } 17 | ; =============================================================================================================================== 18 | 19 | MoveFileEx("C:\Temp\TestFile.txt", "C:\Temp\TestFile_MoveEx.txt", 2) 20 | 21 | 22 | 23 | 24 | 25 | /* C++ ========================================================================================================================== 26 | BOOL WINAPI MoveFileEx( // UInt 27 | _In_ LPCTSTR lpExistingFileName, // Str 28 | _In_opt_ LPCTSTR lpNewFileName, // Str 29 | _In_ DWORD dwFlags // UInt 30 | ); 31 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/IP Helper Functions/GetIpStatistics.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetIpStatistics 3 | ; DLL...........: Iphlpapi.dll 4 | ; Library.......: Iphlpapi.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/aa365959.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/aa365959.aspx 10 | ; =============================================================================================================================== 11 | GetIpStatistics() 12 | { 13 | static MIB_IPSTATS, init := VarSetCapacity(MIB_IPSTATS, 92, 0) && NumPut(92, MIB_IPSTATS, "UInt") 14 | if (DllCall("iphlpapi.dll\GetIpStatistics", "Ptr", &MIB_IPSTATS) != 0) 15 | return DllCall("kernel32.dll\GetLastError") 16 | return { 1 : NumGet(MIB_IPSTATS, 0, "UInt"), 2 : NumGet(MIB_IPSTATS, 4, "UInt"), 3 : NumGet(MIB_IPSTATS, 8, "UInt") 17 | , 4 : NumGet(MIB_IPSTATS, 12, "UInt"), 5 : NumGet(MIB_IPSTATS, 16, "UInt"), 6 : NumGet(MIB_IPSTATS, 20, "UInt") 18 | , 7 : NumGet(MIB_IPSTATS, 24, "UInt"), 8 : NumGet(MIB_IPSTATS, 28, "UInt"), 9 : NumGet(MIB_IPSTATS, 32, "UInt") 19 | , 10 : NumGet(MIB_IPSTATS, 36, "UInt"), 11 : NumGet(MIB_IPSTATS, 40, "UInt"), 12 : NumGet(MIB_IPSTATS, 44, "UInt") 20 | , 13 : NumGet(MIB_IPSTATS, 48, "UInt"), 14 : NumGet(MIB_IPSTATS, 52, "UInt"), 15 : NumGet(MIB_IPSTATS, 56, "UInt") 21 | , 16 : NumGet(MIB_IPSTATS, 60, "UInt"), 17 : NumGet(MIB_IPSTATS, 64, "UInt"), 18 : NumGet(MIB_IPSTATS, 68, "UInt") 22 | , 19 : NumGet(MIB_IPSTATS, 72, "UInt"), 20 : NumGet(MIB_IPSTATS, 76, "UInt"), 21 : NumGet(MIB_IPSTATS, 80, "UInt") 23 | , 22 : NumGet(MIB_IPSTATS, 84, "UInt"), 23 : NumGet(MIB_IPSTATS, 88, "UInt") } 24 | } 25 | ; =============================================================================================================================== 26 | 27 | GetIpStatistics := GetIpStatistics() 28 | 29 | MsgBox % "GetIpStatistics function`n" 30 | . "MIB_IPSTATS structure`n`n" 31 | . "Forwarding:`t`t" GetIpStatistics[1] "`n" 32 | . "DefaultTTL:`t`t" GetIpStatistics[2] "`n" 33 | . "InReceives:`t`t" GetIpStatistics[3] "`n" 34 | . "InHdrErrors:`t`t" GetIpStatistics[4] "`n" 35 | . "InAddrErrors:`t`t" GetIpStatistics[5] "`n" 36 | . "ForwDatagrams:`t`t" GetIpStatistics[6] "`n" 37 | . "InUnknownProtos:`t`t" GetIpStatistics[7] "`n" 38 | . "InDiscards:`t`t" GetIpStatistics[8] "`n" 39 | . "InDelivers:`t`t`t" GetIpStatistics[9] "`n" 40 | . "OutRequests:`t`t" GetIpStatistics[10] "`n" 41 | . "RoutingDiscards:`t`t" GetIpStatistics[11] "`n" 42 | . "OutDiscards:`t`t" GetIpStatistics[12] "`n" 43 | . "OutNoRoutes:`t`t" GetIpStatistics[13] "`n" 44 | . "ReasmTimeout:`t`t" GetIpStatistics[14] "`n" 45 | . "ReasmReqds:`t`t" GetIpStatistics[15] "`n" 46 | . "ReasmOks:`t`t" GetIpStatistics[16] "`n" 47 | . "ReasmFails:`t`t" GetIpStatistics[17] "`n" 48 | . "FragOks:`t`t`t" GetIpStatistics[18] "`n" 49 | . "FragFails:`t`t`t" GetIpStatistics[19] "`n" 50 | . "FragCreates:`t`t" GetIpStatistics[20] "`n" 51 | . "NumIf:`t`t`t" GetIpStatistics[21] "`n" 52 | . "NumAddr:`t`t" GetIpStatistics[22] "`n" 53 | . "NumRoutes:`t`t" GetIpStatistics[23] 54 | 55 | 56 | 57 | 58 | 59 | /* C++ ========================================================================================================================== 60 | DWORD GetIpStatistics( // UInt 61 | _Out_ PMIB_IPSTATS pStats // Ptr (92) 62 | ); 63 | 64 | 65 | typedef struct _MIB_IPSTATS { 66 | DWORD dwForwarding; // UInt 4 => 0 67 | DWORD dwDefaultTTL; // UInt 4 => 4 68 | DWORD dwInReceives; // UInt 4 => 8 69 | DWORD dwInHdrErrors; // UInt 4 => 12 70 | DWORD dwInAddrErrors; // UInt 4 => 16 71 | DWORD dwForwDatagrams; // UInt 4 => 20 72 | DWORD dwInUnknownProtos; // UInt 4 => 24 73 | DWORD dwInDiscards; // UInt 4 => 28 74 | DWORD dwInDelivers; // UInt 4 => 32 75 | DWORD dwOutRequests; // UInt 4 => 36 76 | DWORD dwRoutingDiscards; // UInt 4 => 40 77 | DWORD dwOutDiscards; // UInt 4 => 44 78 | DWORD dwOutNoRoutes; // UInt 4 => 48 79 | DWORD dwReasmTimeout; // UInt 4 => 52 80 | DWORD dwReasmReqds; // UInt 4 => 56 81 | DWORD dwReasmOks; // UInt 4 => 60 82 | DWORD dwReasmFails; // UInt 4 => 64 83 | DWORD dwFragOks; // UInt 4 => 68 84 | DWORD dwFragFails; // UInt 4 => 72 85 | DWORD dwFragCreates; // UInt 4 => 76 86 | DWORD dwNumIf; // UInt 4 => 80 87 | DWORD dwNumAddr; // UInt 4 => 84 88 | DWORD dwNumRoutes; // UInt 4 => 88 89 | } MIB_IPSTATS, *PMIB_IPSTATS; 90 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/IP Helper Functions/GetIpStatisticsEx.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetIpStatisticsEx 3 | ; DLL...........: Iphlpapi.dll 4 | ; Library.......: Iphlpapi.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/aa365963.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/aa365963.aspx 10 | ; =============================================================================================================================== 11 | GetIpStatisticsEx() 12 | { 13 | static IPv4 := 2, IPv6 := 23 14 | static MIB_IPSTATS, init := VarSetCapacity(MIB_IPSTATS, 92, 0) && NumPut(92, MIB_IPSTATS, "UInt") 15 | if (DllCall("iphlpapi.dll\GetIpStatisticsEx", "Ptr", &MIB_IPSTATS, "UInt", IPv4) != 0) 16 | return DllCall("kernel32.dll\GetLastError") 17 | return { 1 : NumGet(MIB_IPSTATS, 0, "UInt"), 2 : NumGet(MIB_IPSTATS, 4, "UInt"), 3 : NumGet(MIB_IPSTATS, 8, "UInt") 18 | , 4 : NumGet(MIB_IPSTATS, 12, "UInt"), 5 : NumGet(MIB_IPSTATS, 16, "UInt"), 6 : NumGet(MIB_IPSTATS, 20, "UInt") 19 | , 7 : NumGet(MIB_IPSTATS, 24, "UInt"), 8 : NumGet(MIB_IPSTATS, 28, "UInt"), 9 : NumGet(MIB_IPSTATS, 32, "UInt") 20 | , 10 : NumGet(MIB_IPSTATS, 36, "UInt"), 11 : NumGet(MIB_IPSTATS, 40, "UInt"), 12 : NumGet(MIB_IPSTATS, 44, "UInt") 21 | , 13 : NumGet(MIB_IPSTATS, 48, "UInt"), 14 : NumGet(MIB_IPSTATS, 52, "UInt"), 15 : NumGet(MIB_IPSTATS, 56, "UInt") 22 | , 16 : NumGet(MIB_IPSTATS, 60, "UInt"), 17 : NumGet(MIB_IPSTATS, 64, "UInt"), 18 : NumGet(MIB_IPSTATS, 68, "UInt") 23 | , 19 : NumGet(MIB_IPSTATS, 72, "UInt"), 20 : NumGet(MIB_IPSTATS, 76, "UInt"), 21 : NumGet(MIB_IPSTATS, 80, "UInt") 24 | , 22 : NumGet(MIB_IPSTATS, 84, "UInt"), 23 : NumGet(MIB_IPSTATS, 88, "UInt") } 25 | } 26 | ; =============================================================================================================================== 27 | 28 | GetIpStatisticsEx := GetIpStatisticsEx() 29 | 30 | MsgBox % "GetIpStatistics function`n" 31 | . "MIB_IPSTATS structure`n`n" 32 | . "Forwarding:`t`t" GetIpStatisticsEx[1] "`n" 33 | . "DefaultTTL:`t`t" GetIpStatisticsEx[2] "`n" 34 | . "InReceives:`t`t" GetIpStatisticsEx[3] "`n" 35 | . "InHdrErrors:`t`t" GetIpStatisticsEx[4] "`n" 36 | . "InAddrErrors:`t`t" GetIpStatisticsEx[5] "`n" 37 | . "ForwDatagrams:`t`t" GetIpStatisticsEx[6] "`n" 38 | . "InUnknownProtos:`t`t" GetIpStatisticsEx[7] "`n" 39 | . "InDiscards:`t`t" GetIpStatisticsEx[8] "`n" 40 | . "InDelivers:`t`t`t" GetIpStatisticsEx[9] "`n" 41 | . "OutRequests:`t`t" GetIpStatisticsEx[10] "`n" 42 | . "RoutingDiscards:`t`t" GetIpStatisticsEx[11] "`n" 43 | . "OutDiscards:`t`t" GetIpStatisticsEx[12] "`n" 44 | . "OutNoRoutes:`t`t" GetIpStatisticsEx[13] "`n" 45 | . "ReasmTimeout:`t`t" GetIpStatisticsEx[14] "`n" 46 | . "ReasmReqds:`t`t" GetIpStatisticsEx[15] "`n" 47 | . "ReasmOks:`t`t" GetIpStatisticsEx[16] "`n" 48 | . "ReasmFails:`t`t" GetIpStatisticsEx[17] "`n" 49 | . "FragOks:`t`t`t" GetIpStatisticsEx[18] "`n" 50 | . "FragFails:`t`t`t" GetIpStatisticsEx[19] "`n" 51 | . "FragCreates:`t`t" GetIpStatisticsEx[20] "`n" 52 | . "NumIf:`t`t`t" GetIpStatisticsEx[21] "`n" 53 | . "NumAddr:`t`t" GetIpStatisticsEx[22] "`n" 54 | . "NumRoutes:`t`t" GetIpStatisticsEx[23] 55 | 56 | 57 | 58 | 59 | 60 | /* C++ ========================================================================================================================== 61 | DWORD GetIpStatisticsEx( // UInt 62 | _Out_ PMIB_IPSTATS pStats, // Ptr (92) 63 | _In_ DWORD dwFamily // UInt 64 | ); 65 | 66 | 67 | typedef struct _MIB_IPSTATS { 68 | DWORD dwForwarding; // UInt 4 => 0 69 | DWORD dwDefaultTTL; // UInt 4 => 4 70 | DWORD dwInReceives; // UInt 4 => 8 71 | DWORD dwInHdrErrors; // UInt 4 => 12 72 | DWORD dwInAddrErrors; // UInt 4 => 16 73 | DWORD dwForwDatagrams; // UInt 4 => 20 74 | DWORD dwInUnknownProtos; // UInt 4 => 24 75 | DWORD dwInDiscards; // UInt 4 => 28 76 | DWORD dwInDelivers; // UInt 4 => 32 77 | DWORD dwOutRequests; // UInt 4 => 36 78 | DWORD dwRoutingDiscards; // UInt 4 => 40 79 | DWORD dwOutDiscards; // UInt 4 => 44 80 | DWORD dwOutNoRoutes; // UInt 4 => 48 81 | DWORD dwReasmTimeout; // UInt 4 => 52 82 | DWORD dwReasmReqds; // UInt 4 => 56 83 | DWORD dwReasmOks; // UInt 4 => 60 84 | DWORD dwReasmFails; // UInt 4 => 64 85 | DWORD dwFragOks; // UInt 4 => 68 86 | DWORD dwFragFails; // UInt 4 => 72 87 | DWORD dwFragCreates; // UInt 4 => 76 88 | DWORD dwNumIf; // UInt 4 => 80 89 | DWORD dwNumAddr; // UInt 4 => 84 90 | DWORD dwNumRoutes; // UInt 4 => 88 91 | } MIB_IPSTATS, *PMIB_IPSTATS; 92 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/IP Helper Functions/GetTcpStatistics.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetTcpStatistics 3 | ; DLL...........: Iphlpapi.dll 4 | ; Library.......: Iphlpapi.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/aa366020.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/aa366020.aspx 10 | ; =============================================================================================================================== 11 | GetTcpStatistics() 12 | { 13 | static MIB_TCPSTATS, init := VarSetCapacity(MIB_TCPSTATS, 60, 0) && NumPut(60, MIB_TCPSTATS, "UInt") 14 | if (DllCall("iphlpapi.dll\GetTcpStatistics", "Ptr", &MIB_TCPSTATS) != 0) 15 | return DllCall("kernel32.dll\GetLastError") 16 | return { 1 : NumGet(MIB_TCPSTATS, 0, "UInt"), 2 : NumGet(MIB_TCPSTATS, 4, "UInt"), 3 : NumGet(MIB_TCPSTATS, 8, "UInt") 17 | , 4 : NumGet(MIB_TCPSTATS, 12, "UInt"), 5 : NumGet(MIB_TCPSTATS, 16, "UInt"), 6 : NumGet(MIB_TCPSTATS, 20, "UInt") 18 | , 7 : NumGet(MIB_TCPSTATS, 24, "UInt"), 8 : NumGet(MIB_TCPSTATS, 28, "UInt"), 9 : NumGet(MIB_TCPSTATS, 32, "UInt") 19 | , 10 : NumGet(MIB_TCPSTATS, 36, "UInt"), 11 : NumGet(MIB_TCPSTATS, 40, "UInt"), 10 : NumGet(MIB_TCPSTATS, 44, "UInt") 20 | , 13 : NumGet(MIB_TCPSTATS, 48, "UInt"), 14 : NumGet(MIB_TCPSTATS, 52, "UInt"), 15 : NumGet(MIB_TCPSTATS, 56, "UInt") } 21 | } 22 | ; =============================================================================================================================== 23 | 24 | GetTcpStatistics := GetTcpStatistics() 25 | 26 | MsgBox % "GetTcpStatistics function`n" 27 | . "MIB_TCPSTATS structure`n`n" 28 | . "RtoAlgorithm:`t`t" GetTcpStatistics[1] "`n" 29 | . "RtoMin:`t`t`t" GetTcpStatistics[2] "`n" 30 | . "RtoMax:`t`t`t" GetTcpStatistics[3] "`n" 31 | . "MaxConn:`t`t`t" GetTcpStatistics[4] "`n" 32 | . "ActiveOpens:`t`t" GetTcpStatistics[5] "`n" 33 | . "PassiveOpens:`t`t" GetTcpStatistics[6] "`n" 34 | . "AttemptFails:`t`t" GetTcpStatistics[7] "`n" 35 | . "EstabResets:`t`t" GetTcpStatistics[8] "`n" 36 | . "CurrEstab:`t`t`t" GetTcpStatistics[9] "`n" 37 | . "InSegs:`t`t`t" GetTcpStatistics[10] "`n" 38 | . "OutSegs:`t`t`t" GetTcpStatistics[11] "`n" 39 | . "RetransSegs:`t`t" GetTcpStatistics[12] "`n" 40 | . "InErrs:`t`t`t" GetTcpStatistics[13] "`n" 41 | . "OutRsts:`t`t`t" GetTcpStatistics[14] "`n" 42 | . "NumConns:`t`t" GetTcpStatistics[15] 43 | 44 | 45 | 46 | 47 | 48 | /* C++ ========================================================================================================================== 49 | DWORD GetTcpStatistics( // UInt 50 | _Out_ PMIB_TCPSTATS pStats // Ptr (60) 51 | ); 52 | 53 | 54 | typedef struct _MIB_TCPSTATS { 55 | DWORD dwRtoAlgorithm; // UInt 4 => 0 56 | DWORD dwRtoMin; // UInt 4 => 4 57 | DWORD dwRtoMax; // UInt 4 => 8 58 | DWORD dwMaxConn; // UInt 4 => 12 59 | DWORD dwActiveOpens; // UInt 4 => 16 60 | DWORD dwPassiveOpens; // UInt 4 => 20 61 | DWORD dwAttemptFails; // UInt 4 => 24 62 | DWORD dwEstabResets; // UInt 4 => 28 63 | DWORD dwCurrEstab; // UInt 4 => 32 64 | DWORD dwInSegs; // UInt 4 => 36 65 | DWORD dwOutSegs; // UInt 4 => 40 66 | DWORD dwRetransSegs; // UInt 4 => 44 67 | DWORD dwInErrs; // UInt 4 => 48 68 | DWORD dwOutRsts; // UInt 4 => 52 69 | DWORD dwNumConns; // UInt 4 => 56 70 | } MIB_TCPSTATS, *PMIB_TCPSTATS; 71 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/IP Helper Functions/GetTcpStatisticsEx.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetTcpStatisticsEx 3 | ; DLL...........: Iphlpapi.dll 4 | ; Library.......: Iphlpapi.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/aa366023.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/aa366023.aspx 10 | ; =============================================================================================================================== 11 | GetTcpStatisticsEx() 12 | { 13 | static IPv4 := 2, IPv6 := 23 14 | static MIB_TCPSTATS, init := VarSetCapacity(MIB_TCPSTATS, 60, 0) && NumPut(60, MIB_TCPSTATS, "UInt") 15 | if (DllCall("iphlpapi.dll\GetTcpStatisticsEx", "Ptr", &MIB_TCPSTATS, "UInt", IPv4) != 0) 16 | return DllCall("kernel32.dll\GetLastError") 17 | return { 1 : NumGet(MIB_TCPSTATS, 0, "UInt"), 2 : NumGet(MIB_TCPSTATS, 4, "UInt"), 3 : NumGet(MIB_TCPSTATS, 8, "UInt") 18 | , 4 : NumGet(MIB_TCPSTATS, 12, "UInt"), 5 : NumGet(MIB_TCPSTATS, 16, "UInt"), 6 : NumGet(MIB_TCPSTATS, 20, "UInt") 19 | , 7 : NumGet(MIB_TCPSTATS, 24, "UInt"), 8 : NumGet(MIB_TCPSTATS, 28, "UInt"), 9 : NumGet(MIB_TCPSTATS, 32, "UInt") 20 | , 10 : NumGet(MIB_TCPSTATS, 36, "UInt"), 11 : NumGet(MIB_TCPSTATS, 40, "UInt"), 12 : NumGet(MIB_TCPSTATS, 44, "UInt") 21 | , 13 : NumGet(MIB_TCPSTATS, 48, "UInt"), 14 : NumGet(MIB_TCPSTATS, 52, "UInt"), 15 : NumGet(MIB_TCPSTATS, 56, "UInt") } 22 | } 23 | ; =============================================================================================================================== 24 | 25 | GetTcpStatisticsEx := GetTcpStatisticsEx() 26 | 27 | MsgBox % "GetTcpStatistics function`n" 28 | . "MIB_TCPSTATS structure`n`n" 29 | . "RtoAlgorithm:`t`t" GetTcpStatisticsEx[1] "`n" 30 | . "RtoMin:`t`t`t" GetTcpStatisticsEx[2] "`n" 31 | . "RtoMax:`t`t`t" GetTcpStatisticsEx[3] "`n" 32 | . "MaxConn:`t`t`t" GetTcpStatisticsEx[4] "`n" 33 | . "ActiveOpens:`t`t" GetTcpStatisticsEx[5] "`n" 34 | . "PassiveOpens:`t`t" GetTcpStatisticsEx[6] "`n" 35 | . "AttemptFails:`t`t" GetTcpStatisticsEx[7] "`n" 36 | . "EstabResets:`t`t" GetTcpStatisticsEx[8] "`n" 37 | . "CurrEstab:`t`t`t" GetTcpStatisticsEx[9] "`n" 38 | . "InSegs:`t`t`t" GetTcpStatisticsEx[10] "`n" 39 | . "OutSegs:`t`t`t" GetTcpStatisticsEx[11] "`n" 40 | . "RetransSegs:`t`t" GetTcpStatisticsEx[12] "`n" 41 | . "InErrs:`t`t`t" GetTcpStatisticsEx[13] "`n" 42 | . "OutRsts:`t`t`t" GetTcpStatisticsEx[14] "`n" 43 | . "NumConns:`t`t" GetTcpStatisticsEx[15] 44 | 45 | 46 | 47 | /* C++ ========================================================================================================================== 48 | DWORD GetTcpStatisticsEx( // UInt 49 | _Out_ PMIB_TCPSTATS pStats, // Ptr (60) 50 | _In_ DWORD dwFamily // UInt 51 | ); 52 | 53 | 54 | typedef struct _MIB_TCPSTATS { 55 | DWORD dwRtoAlgorithm; // UInt 4 => 0 56 | DWORD dwRtoMin; // UInt 4 => 4 57 | DWORD dwRtoMax; // UInt 4 => 8 58 | DWORD dwMaxConn; // UInt 4 => 12 59 | DWORD dwActiveOpens; // UInt 4 => 16 60 | DWORD dwPassiveOpens; // UInt 4 => 20 61 | DWORD dwAttemptFails; // UInt 4 => 24 62 | DWORD dwEstabResets; // UInt 4 => 28 63 | DWORD dwCurrEstab; // UInt 4 => 32 64 | DWORD dwInSegs; // UInt 4 => 36 65 | DWORD dwOutSegs; // UInt 4 => 40 66 | DWORD dwRetransSegs; // UInt 4 => 44 67 | DWORD dwInErrs; // UInt 4 => 48 68 | DWORD dwOutRsts; // UInt 4 => 52 69 | DWORD dwNumConns; // UInt 4 => 56 70 | } MIB_TCPSTATS, *PMIB_TCPSTATS; 71 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/IP Helper Functions/GetUdpStatistics.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetUdpStatistics 3 | ; DLL...........: Iphlpapi.dll 4 | ; Library.......: Iphlpapi.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/aa366029.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/aa366029.aspx 10 | ; =============================================================================================================================== 11 | GetUdpStatistics() 12 | { 13 | static MIB_UDPSTATS, init := VarSetCapacity(MIB_UDPSTATS, 20, 0) && NumPut(20, MIB_UDPSTATS, "UInt") 14 | if (DllCall("iphlpapi.dll\GetUdpStatistics", "Ptr", &MIB_UDPSTATS) != 0) 15 | return DllCall("kernel32.dll\GetLastError") 16 | return { 1 : NumGet(MIB_UDPSTATS, 0, "UInt"), 2 : NumGet(MIB_UDPSTATS, 4, "UInt"), 3 : NumGet(MIB_UDPSTATS, 8, "UInt") 17 | , 4 : NumGet(MIB_UDPSTATS, 12, "UInt"), 5 : NumGet(MIB_UDPSTATS, 16, "UInt") } 18 | } 19 | ; =============================================================================================================================== 20 | 21 | GetUdpStatistics := GetUdpStatistics() 22 | 23 | MsgBox % "GetUdpStatistics function`n" 24 | . "MIB_UDPSTATS structure`n`n" 25 | . "InDatagrams:`t`t" GetUdpStatistics[1] "`n" 26 | . "NoPorts:`t`t`t" GetUdpStatistics[2] "`n" 27 | . "InErrors:`t`t`t" GetUdpStatistics[3] "`n" 28 | . "OutDatagrams:`t`t" GetUdpStatistics[4] "`n" 29 | . "NumAddrs:`t`t" GetUdpStatistics[5] 30 | 31 | 32 | 33 | 34 | 35 | /* C++ ========================================================================================================================== 36 | DWORD GetUdpStatistics( // UInt 37 | _Out_ PMIB_UDPSTATS pStats // Ptr (20) 38 | ); 39 | 40 | 41 | typedef struct _MIB_UDPSTATS { 42 | DWORD dwInDatagrams; // UInt 4 => 0 43 | DWORD dwNoPorts; // UInt 4 => 4 44 | DWORD dwInErrors; // UInt 4 => 8 45 | DWORD dwOutDatagrams; // UInt 4 => 12 46 | DWORD dwNumAddrs; // UInt 4 => 16 47 | } MIB_UDPSTATS, *PMIB_UDPSTATS; 48 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/IP Helper Functions/GetUdpStatisticsEx.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetUdpStatisticsEx 3 | ; DLL...........: Iphlpapi.dll 4 | ; Library.......: Iphlpapi.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/aa366031.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/aa366031.aspx 10 | ; =============================================================================================================================== 11 | GetUdpStatisticsEx() 12 | { 13 | static IPv4 := 2, IPv6 := 23 14 | static MIB_UDPSTATS, init := VarSetCapacity(MIB_UDPSTATS, 20, 0) && NumPut(20, MIB_UDPSTATS, "UInt") 15 | if (DllCall("iphlpapi.dll\GetUdpStatisticsEx", "Ptr", &MIB_UDPSTATS, "UInt", IPv4) != 0) 16 | return DllCall("kernel32.dll\GetLastError") 17 | return { 1 : NumGet(MIB_UDPSTATS, 0, "UInt"), 2 : NumGet(MIB_UDPSTATS, 4, "UInt"), 3 : NumGet(MIB_UDPSTATS, 8, "UInt") 18 | , 4 : NumGet(MIB_UDPSTATS, 12, "UInt"), 5 : NumGet(MIB_UDPSTATS, 16, "UInt") } 19 | } 20 | ; =============================================================================================================================== 21 | 22 | GetUdpStatisticsEx := GetUdpStatisticsEx() 23 | 24 | MsgBox % "GetUdpStatisticsEx function`n" 25 | . "MIB_UDPSTATS structure`n`n" 26 | . "InDatagrams:`t`t" GetUdpStatisticsEx[1] "`n" 27 | . "NoPorts:`t`t`t" GetUdpStatisticsEx[2] "`n" 28 | . "InErrors:`t`t`t" GetUdpStatisticsEx[3] "`n" 29 | . "OutDatagrams:`t`t" GetUdpStatisticsEx[4] "`n" 30 | . "NumAddrs:`t`t" GetUdpStatisticsEx[5] 31 | 32 | 33 | 34 | 35 | 36 | /* C++ ========================================================================================================================== 37 | DWORD GetUdpStatisticsEx( // UInt 38 | _Out_ PMIB_UDPSTATS pStats, // Ptr (20) 39 | _In_ DWORD dwFamily // UInt 40 | ); 41 | 42 | 43 | typedef struct _MIB_UDPSTATS { 44 | DWORD dwInDatagrams; // UInt 4 => 0 45 | DWORD dwNoPorts; // UInt 4 => 4 46 | DWORD dwInErrors; // UInt 4 => 8 47 | DWORD dwOutDatagrams; // UInt 4 => 12 48 | DWORD dwNumAddrs; // UInt 4 => 16 49 | } MIB_UDPSTATS, *PMIB_UDPSTATS; 50 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Keyboard Input Functions/BlockInput.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: BlockInput 3 | ; DLL...........: User32.dll 4 | ; Library.......: User32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms646290.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms646290.aspx 10 | ; =============================================================================================================================== 11 | BlockInput(BlockIt := 0) 12 | { 13 | if !(DllCall("user32.dll\BlockInput", "UInt", BlockIt)) 14 | return DllCall("kernel32.dll\GetLastError") 15 | return 1 16 | } 17 | ; =============================================================================================================================== 18 | 19 | BlockInput(1) ; Keyboard and Mouse input events are blocked. 20 | Sleep 5000 21 | BlockInput(0) ; Keyboard and Mouse input events are unblocked. 22 | 23 | 24 | 25 | 26 | 27 | /* C++ ========================================================================================================================== 28 | BOOL WINAPI BlockInput( // UInt 29 | _In_ BOOL fBlockIt // UInt 30 | ); 31 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Keyboard Input Functions/GetKBCodePage.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetKBCodePage 3 | ; DLL...........: User32.dll 4 | ; Library.......: User32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms646295.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms646295.aspx 10 | ; =============================================================================================================================== 11 | GetKBCodePage() 12 | { 13 | return DllCall("user32.dll\GetKBCodePage") 14 | } 15 | ; =============================================================================================================================== 16 | 17 | MsgBox % GetKBCodePage() 18 | 19 | 20 | 21 | 22 | 23 | /* C++ ========================================================================================================================== 24 | UINT WINAPI GetKBCodePage(void); // UInt 25 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Keyboard Input Functions/GetKeyboardLayout.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetKeyboardLayout 3 | ; DLL...........: User32.dll 4 | ; Library.......: User32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms646296.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms646296.aspx 10 | ; =============================================================================================================================== 11 | GetKeyboardLayout(Thread := 0) 12 | { 13 | return DllCall("user32.dll\GetKeyboardLayout", "UInt", Thread) 14 | } 15 | ; =============================================================================================================================== 16 | 17 | MsgBox % GetKeyboardLayout(0) 18 | 19 | 20 | 21 | 22 | 23 | /* C++ ========================================================================================================================== 24 | HKL WINAPI GetKeyboardLayout( // Ptr 25 | _In_ DWORD idThread // UInt 26 | ); 27 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Memory Management Functions/GetPhysicallyInstalledSystemMemory.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetPhysicallyInstalledSystemMemory 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/cc300158.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/cc300158.aspx 10 | ; =============================================================================================================================== 11 | GetPhysicallyInstalledSystemMemory() 12 | { 13 | if !(DllCall("kernel32.dll\GetPhysicallyInstalledSystemMemory", "UInt64*", TotalMemory)) 14 | return DllCall("kernel32.dll\GetLastError") 15 | return TotalMemory 16 | } 17 | ; =============================================================================================================================== 18 | 19 | MsgBox % GetPhysicallyInstalledSystemMemory() " KB`n" 20 | . Round(GetPhysicallyInstalledSystemMemory() / 1024, 2) " MB`n" 21 | . Round(GetPhysicallyInstalledSystemMemory() / 1024**2, 2) " GB`n" 22 | 23 | 24 | 25 | 26 | 27 | /* C++ ========================================================================================================================== 28 | BOOL WINAPI GetPhysicallyInstalledSystemMemory( // UInt 29 | _Out_ PULONGLONG TotalMemoryInKilobytes // UInt64* 30 | ); 31 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Memory Management Functions/GlobalMemoryStatusEx.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GlobalMemoryStatusEx 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/desktop/aa366589.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/aa366589.aspx 10 | ; =============================================================================================================================== 11 | GlobalMemoryStatusEx() 12 | { 13 | static MEMORYSTATUSEX, init := VarSetCapacity(MEMORYSTATUSEX, 64, 0) && NumPut(64, MEMORYSTATUSEX, "UInt") 14 | if !(DllCall("kernel32.dll\GlobalMemoryStatusEx", "Ptr", &MEMORYSTATUSEX)) 15 | return DllCall("kernel32.dll\GetLastError") 16 | return { 1 : NumGet(MEMORYSTATUSEX, 0, "UInt"), 2 : NumGet(MEMORYSTATUSEX, 4, "UInt") 17 | , 3 : NumGet(MEMORYSTATUSEX, 8, "UInt64"), 4 : NumGet(MEMORYSTATUSEX, 16, "UInt64") 18 | , 5 : NumGet(MEMORYSTATUSEX, 24, "UInt64"), 6 : NumGet(MEMORYSTATUSEX, 32, "UInt64") 19 | , 7 : NumGet(MEMORYSTATUSEX, 40, "UInt64"), 8 : NumGet(MEMORYSTATUSEX, 48, "UInt64") 20 | , 9 : NumGet(MEMORYSTATUSEX, 56, "UInt64") } 21 | } 22 | ; =============================================================================================================================== 23 | 24 | GlobalMemoryStatusEx := GlobalMemoryStatusEx() 25 | 26 | MsgBox, % "GlobalMemoryStatusEx function`n" 27 | . "MEMORYSTATUSEX structure`n`n" 28 | . "Lenght:`t`t`t" GlobalMemoryStatusEx[1] "`n`n" 29 | . "MemoryLoad:`t`t" GlobalMemoryStatusEx[2] " %`n`n" 30 | . "TotalPhys:`t`t`t" GlobalMemoryStatusEx[3] " bytes`n" 31 | . "AvailPhys:`t`t`t" GlobalMemoryStatusEx[4] " bytes`n`n" 32 | . "TotalPageFile:`t`t" GlobalMemoryStatusEx[5] " bytes`n" 33 | . "AvailPageFile:`t`t" GlobalMemoryStatusEx[6] " bytes`n`n" 34 | . "TotalVirtual:`t`t" GlobalMemoryStatusEx[7] " bytes`n" 35 | . "AvailVirtual:`t`t" GlobalMemoryStatusEx[8] " bytes`n`n" 36 | . "AvailExtendedVirtual:`t`t" GlobalMemoryStatusEx[9] 37 | 38 | 39 | 40 | 41 | 42 | /* C++ ========================================================================================================================== 43 | BOOL WINAPI GlobalMemoryStatusEx( // UInt 44 | _Inout_ LPMEMORYSTATUSEX lpBuffer // Ptr (64) 45 | ); 46 | 47 | 48 | typedef struct _MEMORYSTATUSEX { 49 | DWORD dwLength; // UInt 4 => 0 50 | DWORD dwMemoryLoad; // UInt 4 => 4 51 | DWORDLONG ullTotalPhys; // UInt64 8 => 8 52 | DWORDLONG ullAvailPhys; // UInt64 8 => 16 53 | DWORDLONG ullTotalPageFile; // UInt64 8 => 24 54 | DWORDLONG ullAvailPageFile; // UInt64 8 => 32 55 | DWORDLONG ullTotalVirtual; // UInt64 8 => 40 56 | DWORDLONG ullAvailVirtual; // UInt64 8 => 48 57 | DWORDLONG ullAvailExtendedVirtual; // UInt64 8 => 56 58 | } MEMORYSTATUSEX, *LPMEMORYSTATUSEX; 59 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Mouse Input Functions/ClipCursor.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: ClipCursor 3 | ; DLL...........: User32.dll 4 | ; Library.......: User32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms648383.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms648383.aspx 10 | ; =============================================================================================================================== 11 | ClipCursor(Confine := true, X1 := 100, Y1 := 200, X2 := 800, Y2 := 900) 12 | { 13 | if !(Confine) 14 | return DllCall("ClipCursor", "Ptr", 0) 15 | 16 | VarSetCapacity(RECT, 16, 0) 17 | ;DllCall("SetRect", "Ptr", &RECT, "Int", X1, "Int", Y1, "Int", X2, "Int", Y2) 18 | NumPut(Y2, NumPut(X2, NumPut(Y1, NumPut(X1, RECT, 0, "Int"), "Int"), "Int"), "Int") 19 | if !(DllCall("ClipCursor", "Ptr", &RECT)) 20 | return A_LastError 21 | return true 22 | } 23 | ; =============================================================================================================================== 24 | 25 | ClipCursor(True, 100, 200, 800, 900) ; Confines the cursor to a rectangular area on the screen. 26 | Sleep 5000 27 | ClipCursor(False) ; Release the confines. 28 | 29 | 30 | 31 | 32 | 33 | /* C++ ========================================================================================================================== 34 | BOOL WINAPI ClipCursor( // Int 35 | _In_opt_ const RECT *lpRect // Ptr 36 | ); 37 | 38 | 39 | typedef struct _RECT { 40 | LONG left; ( X1 ) // Int 4 => 0 41 | LONG top; ( Y1 ) // Int 4 => 4 42 | LONG right; ( X2 ) // Int 4 => 8 43 | LONG bottom; ( Y2 ) // Int 4 => 12 44 | } RECT, *PRECT; 45 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Mouse Input Functions/GetCapture.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetCapture 3 | ; DLL...........: User32.dll 4 | ; Library.......: User32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms646262.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms646262.aspx 10 | ; =============================================================================================================================== 11 | GetCapture() 12 | { 13 | return DllCall("user32.dll\GetCapture") 14 | } 15 | ; =============================================================================================================================== 16 | 17 | MsgBox % GetCapture() 18 | 19 | 20 | 21 | 22 | 23 | /* C++ ========================================================================================================================== 24 | HWND WINAPI GetCapture(void); // Ptr 25 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Mouse Input Functions/GetDoubleClickTime.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetDoubleClickTime 3 | ; DLL...........: User32.dll 4 | ; Library.......: User32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms646258.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms646258.aspx 10 | ; =============================================================================================================================== 11 | GetDoubleClickTime() 12 | { 13 | return DllCall("user32.dll\GetDoubleClickTime") 14 | } 15 | ; =============================================================================================================================== 16 | 17 | MsgBox % GetDoubleClickTime() 18 | 19 | 20 | 21 | 22 | 23 | /* C++ ========================================================================================================================== 24 | UINT WINAPI GetDoubleClickTime(void); // UInt 25 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Mouse Input Functions/ReleaseCapture.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: ReleaseCapture 3 | ; DLL...........: User32.dll 4 | ; Library.......: User32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms646261.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms646261.aspx 10 | ; =============================================================================================================================== 11 | ReleaseCapture() 12 | { 13 | if !(DllCall("user32.dll\ReleaseCapture")) 14 | return DllCall("kernel32.dll\GetLastError") 15 | return 1 16 | } 17 | ; =============================================================================================================================== 18 | 19 | ReleaseCapture() 20 | 21 | 22 | 23 | 24 | 25 | /* C++ ========================================================================================================================== 26 | BOOL WINAPI ReleaseCapture(void); // UInt 27 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Mouse Input Functions/SetDoubleClickTime.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: SetDoubleClickTime 3 | ; DLL...........: User32.dll 4 | ; Library.......: User32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms646263.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms646263.aspx 10 | ; =============================================================================================================================== 11 | SetDoubleClickTime(Interval) 12 | { 13 | if !(DllCall("user32.dll\SetDoubleClickTime", "UInt", Interval)) 14 | return DllCall("kernel32.dll\GetLastError") 15 | return 1 16 | } 17 | ; =============================================================================================================================== 18 | 19 | SetDoubleClickTime(500) 20 | 21 | 22 | 23 | 24 | 25 | /* C++ ========================================================================================================================== 26 | BOOL WINAPI SetDoubleClickTime( // UInt 27 | _In_ UINT uInterval // UInt 28 | ); 29 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Mouse Input Functions/SwapMouseButton.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: SwapMouseButton 3 | ; DLL...........: User32.dll 4 | ; Library.......: User32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms646264.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms646264.aspx 10 | ; =============================================================================================================================== 11 | SwapMouseButton(Swap) 12 | { 13 | DllCall("user32.dll\SwapMouseButton", "UInt", Swap) 14 | } 15 | ; =============================================================================================================================== 16 | 17 | SwapMouseButton(1) ; Left-Hand 18 | sleep 10000 19 | SwapMouseButton(0) ; Right-Hand 20 | 21 | 22 | 23 | 24 | 25 | /* C++ ========================================================================================================================== 26 | BOOL WINAPI SwapMouseButton( // UInt 27 | _In_ BOOL fSwap // UInt 28 | ); 29 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Multimedia Functions/timeGetTime.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: timeGetTime 3 | ; DLL...........: Winmm.dll 4 | ; Library.......: Winmm.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/dd757629.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/dd757629.aspx 10 | ; =============================================================================================================================== 11 | timeGetTime() 12 | { 13 | return DllCall("winmm.dll\timeGetTime", "UInt") 14 | } 15 | ; =============================================================================================================================== 16 | 17 | MsgBox % timeGetTime() 18 | 19 | 20 | 21 | 22 | 23 | /* C++ ========================================================================================================================== 24 | DWORD timeGetTime(void); // UInt 25 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/National Language Support Functions/GetDurationFormat.ahk: -------------------------------------------------------------------------------- 1 | ; ================================================================================================= 2 | ; Function......: GetDurationFormat 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: http://msdn.microsoft.com/en-us/library/windows/desktop/dd318091(v=vs.85).aspx 9 | ; ================================================================================================= 10 | GetDurationFormat(ullDuration, lpFormat := "d'd':hh:mm:ss") 11 | { 12 | VarSetCapacity(lpDurationStr, 128, 0) 13 | DllCall("Kernel32.dll\GetDurationFormat" 14 | , "UInt", 0x400 15 | , "UInt", 0 16 | , "Ptr", 0 17 | , "Int64", ullDuration * 10000000 ; Number of Seconds 18 | , "WStr", lpFormat 19 | , "WStr", lpDurationStr 20 | , "Int", 64) 21 | return lpDurationStr 22 | } 23 | ; =================================================================================== 24 | 25 | MsgBox, % GetDurationFormat(421337) "`n" 26 | . GetDurationFormat(421337, "d:hh:mm:ss") "`n" 27 | . GetDurationFormat(4213.37, "hh:mm:ss:ff") 28 | 29 | 30 | 31 | 32 | 33 | /* C++ ============================================================================== 34 | int GetDurationFormat( // Int 35 | _In_ LCID Locale, // UInt 36 | _In_ DWORD dwFlags, // UInt 37 | _In_opt_ const SYSTEMTIME *lpDuration, // Ptr 38 | _In_ ULONGLONG ullDuration, // Int64 39 | _In_opt_ LPCWSTR lpFormat, // WStr 40 | _Out_opt_ LPWSTR lpDurationStr, // WStr 41 | _In_ int cchDuration // Int 42 | ); 43 | ================================================================================== */ -------------------------------------------------------------------------------- /src/Others/ZwDelayExecution.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: ZwDelayExecution 3 | ; DLL...........: Ntdll.dll 4 | ; Library.......: 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: 9 | ; =============================================================================================================================== 10 | ZwDelayExecution(Alertable, Interval) 11 | { 12 | DllCall("ntdll.dll\ZwDelayExecution", "UChar", Alertable, "Int64*", Interval) 13 | } 14 | ; =============================================================================================================================== 15 | 16 | DllCall("kernel32.dll\QueryPerformanceFrequency", "Int64*", F) 17 | DllCall("kernel32.dll\QueryPerformanceCounter", "Int64*", S) 18 | ZwDelayExecution(0, -2000000) 19 | DllCall("kernel32.dll\QueryPerformanceCounter", "Int64*", E) 20 | MsgBox % (E - S) / F 21 | 22 | 23 | 24 | 25 | 26 | /* C++ ========================================================================================================================== 27 | NTSYSAPI NTSTATUS NTAPI ZwDelayExecution( 28 | _In_ BOOLEAN Alertable, // UChar 29 | _In_ LARGE_INTEGER * Interval // Int64* 30 | ); 31 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/PSAPI Functions/GetModuleFileNameEx.ahk: -------------------------------------------------------------------------------- 1 | ; ================================================================================================= 2 | ; Function......: GetModuleFileNameEx 3 | ; DLL...........: Kernel32.dll / Psapi.dll 4 | ; Library.......: Kernel32.lib / Psapi.lib 5 | ; U/ANSI........: GetModuleFileNameExW (Unicode) and GetModuleFileNameExA (ANSI) 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: http://msdn.microsoft.com/en-us/library/windows/desktop/ms683198(v=vs.85).aspx 9 | ; ================================================================================================= 10 | GetModuleFileNameEx(PID) 11 | { 12 | hProcess := DllCall("Kernel32.dll\OpenProcess", "UInt", 0x001F0FFF, "UInt", 0, "UInt", PID) 13 | if (ErrorLevel || hProcess = 0) 14 | return 15 | static lpFilename, nSize := 260, int := VarSetCapacity(lpFilename, nSize, 0) 16 | DllCall("Psapi.dll\GetModuleFileNameEx", "Ptr", hProcess, "Ptr", 0, "Str", lpFilename, "UInt", nSize) 17 | DllCall("Kernel32.dll\CloseHandle", "Ptr", hProcess) 18 | return lpFilename 19 | } 20 | ; =================================================================================== 21 | 22 | Current_PID := GetCurrentProcessId() 23 | MsgBox, % GetModuleFileNameEx(Current_PID) 24 | 25 | GetCurrentProcessId() 26 | { 27 | return DllCall("Kernel32.dll\GetCurrentProcessId") 28 | } 29 | 30 | 31 | 32 | 33 | 34 | /* C++ ============================================================================== 35 | DWORD WINAPI GetModuleFileNameEx( // UInt 36 | _In_ HANDLE hProcess, // Ptr 37 | _In_opt_ HMODULE hModule, // Ptr 38 | _Out_ LPTSTR lpFilename, // Str 39 | _In_ DWORD nSize // UInt 40 | ); 41 | ================================================================================== */ -------------------------------------------------------------------------------- /src/PSAPI Functions/GetProcessMemoryInfo.ahk: -------------------------------------------------------------------------------- 1 | ; ================================================================================================= 2 | ; Function......: GetProcessMemoryInfo 3 | ; DLL...........: Kernel32.dll / Psapi.dll 4 | ; Library.......: Kernel32.lib / Psapi.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: http://msdn.microsoft.com/en-us/library/windows/desktop/ms683219(v=vs.85).aspx 9 | ; ================================================================================================= 10 | GetProcessMemoryInfo_PMCEX(PID) 11 | { 12 | pu := "" 13 | hProcess := DllCall("Kernel32.dll\OpenProcess", "UInt", 0x001F0FFF, "UInt", 0, "UInt", PID) 14 | if (hProcess) 15 | { 16 | static PMCEX, size := (A_PtrSize = 8 ? 80 : 44), init := VarSetCapacity(PMCEX, size, 0) && NumPut(size, PMCEX) 17 | if (DllCall("Kernel32.dll\K32GetProcessMemoryInfo", "Ptr", hProcess, "UInt", &PMCEX, "UInt", size)) 18 | { 19 | pu := { 1 : NumGet(PMCEX, 0, "UInt"), 2 : NumGet(PMCEX, 4, "UInt") 20 | , 3 : NumGet(PMCEX, 8, "Ptr"), 4 : NumGet(PMCEX, (A_PtrSize = 8 ? 16 : 12), "Ptr") 21 | , 5 : NumGet(PMCEX, (A_PtrSize = 8 ? 24 : 16), "Ptr"), 6 : NumGet(PMCEX, (A_PtrSize = 8 ? 32 : 20), "Ptr") 22 | , 7 : NumGet(PMCEX, (A_PtrSize = 8 ? 40 : 24), "Ptr"), 8 : NumGet(PMCEX, (A_PtrSize = 8 ? 48 : 28), "Ptr") 23 | , 9 : NumGet(PMCEX, (A_PtrSize = 8 ? 56 : 32), "Ptr"), 10 : NumGet(PMCEX, (A_PtrSize = 8 ? 64 : 36), "Ptr") 24 | , 11 : NumGet(PMCEX, (A_PtrSize = 8 ? 72 : 40), "Ptr") } 25 | } 26 | DllCall("Kernel32.dll\CloseHandle", "Ptr", hProcess) 27 | } 28 | return pu 29 | } 30 | GetProcessMemoryInfo_PMC(PID) 31 | { 32 | pu := "" 33 | hProcess := DllCall("Kernel32.dll\OpenProcess", "UInt", 0x001F0FFF, "UInt", 0, "UInt", PID) 34 | if (hProcess) 35 | { 36 | static PMC, size := (A_PtrSize = 8 ? 72 : 40), init := VarSetCapacity(PMC, size, 0) && NumPut(size, PMC) 37 | if (DllCall("Psapi.dll\GetProcessMemoryInfo", "Ptr", hProcess, "UInt", &PMC, "UInt", size)) 38 | { 39 | pu := { 1 : NumGet(PMC, 0, "UInt"), 2 : NumGet(PMC, 4, "UInt") 40 | , 3 : NumGet(PMC, 8, "Ptr"), 4 : NumGet(PMC, (A_PtrSize = 8 ? 16 : 12), "Ptr") 41 | , 5 : NumGet(PMC, (A_PtrSize = 8 ? 24 : 16), "Ptr"), 6 : NumGet(PMC, (A_PtrSize = 8 ? 32 : 20), "Ptr") 42 | , 7 : NumGet(PMC, (A_PtrSize = 8 ? 40 : 24), "Ptr"), 8 : NumGet(PMC, (A_PtrSize = 8 ? 48 : 28), "Ptr") 43 | , 9 : NumGet(PMC, (A_PtrSize = 8 ? 56 : 32), "Ptr"), 10 : NumGet(PMC, (A_PtrSize = 8 ? 64 : 36), "Ptr") } 44 | } 45 | DllCall("Kernel32.dll\CloseHandle", "Ptr", hProcess) 46 | } 47 | return pu 48 | } 49 | ; =================================================================================== 50 | 51 | ownPID := DllCall("GetCurrentProcessId") 52 | BuildVersion := DllCall("GetVersion") >> 16 & 0xffff 53 | 54 | if (BuildVersion >= "7600") { 55 | GPMI := GetProcessMemoryInfo_PMCEX(ownPID) 56 | MsgBox, % "GetProcessMemoryInfo function`n" 57 | . "PROCESS_MEMORY_COUNTERS_EX structure`n`n" 58 | . "cb:`t`t`t`t" GPMI[1] "`n" 59 | . "PageFaultCount:`t`t`t" GPMI[2] " bytes`n" 60 | . "PeakWorkingSetSize:`t`t`t" GPMI[3] " bytes`n" 61 | . "WorkingSetSize:`t`t`t" GPMI[4] " bytes`n" 62 | . "QuotaPeakPagedPoolUsage:`t`t" GPMI[5] " bytes`n" 63 | . "QuotaPagedPoolUsage:`t`t" GPMI[6] " bytes`n" 64 | . "QuotaPeakNonPagedPoolUsage:`t" GPMI[7] " bytes`n" 65 | . "QuotaNonPagedPoolUsage:`t`t" GPMI[8] " bytes`n" 66 | . "PagefileUsage:`t`t`t" GPMI[9] " bytes`n" 67 | . "PeakPagefileUsage:`t`t`t" GPMI[10] " bytes`n" 68 | . "PrivateUsage:`t`t`t" GPMI[11] " bytes`n`n" 69 | . "BUILD: " BuildVersion " | PID: " ownPID "`n" 70 | } else { 71 | GPMI := GetProcessMemoryInfo_PMC(ownPID) 72 | MsgBox, % "GetProcessMemoryInfo function`n" 73 | . "PROCESS_MEMORY_COUNTERS_EX structure`n`n" 74 | . "cb:`t`t`t`t" GPMI[1] "`n" 75 | . "PageFaultCount:`t`t`t" GPMI[2] " bytes`n" 76 | . "PeakWorkingSetSize:`t`t" GPMI[3] " bytes`n" 77 | . "WorkingSetSize:`t`t`t" GPMI[4] " bytes`n" 78 | . "QuotaPeakPagedPoolUsage:`t`t" GPMI[5] " bytes`n" 79 | . "QuotaPagedPoolUsage:`t`t" GPMI[6] " bytes`n" 80 | . "QuotaPeakNonPagedPoolUsage:`t" GPMI[7] " bytes`n" 81 | . "QuotaNonPagedPoolUsage:`t`t" GPMI[8] " bytes`n" 82 | . "PagefileUsage:`t`t`t" GPMI[9] " bytes`n" 83 | . "PeakPagefileUsage:`t`t`t" GPMI[10] " bytes`n`n" 84 | . "BUILD: " BuildVersion " | PID: " ownPID "`n" 85 | } 86 | 87 | 88 | 89 | 90 | 91 | /* C++ ============================================================================== 92 | BOOL WINAPI GetProcessMemoryInfo( // UInt 93 | _In_ HANDLE Process, // Ptr 94 | _Out_ PPROCESS_MEMORY_COUNTERS ppsmemCounters, // UInt 95 | _In_ DWORD cb // UInt 96 | ); 97 | 98 | 99 | typedef struct _PROCESS_MEMORY_COUNTERS { 100 | DWORD cb; // 0 (40) | 0 (72) UInt 101 | DWORD PageFaultCount; // 4 => 4 | 4 => 4 UInt 102 | SIZE_T PeakWorkingSetSize; // 4 => 8 | 8 => 8 Ptr 103 | SIZE_T WorkingSetSize; // 4 => 12 | 8 => 16 Ptr 104 | SIZE_T QuotaPeakPagedPoolUsage; // 4 => 16 | 8 => 24 Ptr 105 | SIZE_T QuotaPagedPoolUsage; // 4 => 20 | 8 => 32 Ptr 106 | SIZE_T QuotaPeakNonPagedPoolUsage; // 4 => 24 | 8 => 40 Ptr 107 | SIZE_T QuotaNonPagedPoolUsage; // 4 => 28 | 8 => 48 Ptr 108 | SIZE_T PagefileUsage; // 4 => 32 | 8 => 56 Ptr 109 | SIZE_T PeakPagefileUsage; // 4 => 36 | 8 => 64 Ptr 110 | } PROCESS_MEMORY_COUNTERS, *PPROCESS_MEMORY_COUNTERS; 111 | 112 | typedef struct _PROCESS_MEMORY_COUNTERS_EX { 113 | DWORD cb; // 0 (44) | 0 (80) UInt 114 | DWORD PageFaultCount; // 4 => 4 | 4 => 4 UInt 115 | SIZE_T PeakWorkingSetSize; // 4 => 8 | 8 => 8 Ptr 116 | SIZE_T WorkingSetSize; // 4 => 12 | 8 => 16 Ptr 117 | SIZE_T QuotaPeakPagedPoolUsage; // 4 => 16 | 8 => 24 Ptr 118 | SIZE_T QuotaPagedPoolUsage; // 4 => 20 | 8 => 32 Ptr 119 | SIZE_T QuotaPeakNonPagedPoolUsage; // 4 => 24 | 8 => 40 Ptr 120 | SIZE_T QuotaNonPagedPoolUsage; // 4 => 28 | 8 => 48 Ptr 121 | SIZE_T PagefileUsage; // 4 => 32 | 8 => 56 Ptr 122 | SIZE_T PeakPagefileUsage; // 4 => 36 | 8 => 64 Ptr 123 | SIZE_T PrivateUsage; // 4 => 40 | 8 => 72 Ptr 124 | } PROCESS_MEMORY_COUNTERS_EX, *PPROCESS_MEMORY_COUNTERS_EX; 125 | ================================================================================== */ -------------------------------------------------------------------------------- /src/Process and Thread Functions/GetActiveProcessorCount.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetActiveProcessorCount 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/dd405485.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/dd405485.aspx 10 | ; =============================================================================================================================== 11 | GetActiveProcessorCount(GroupNumber := 0xFFFF) 12 | { 13 | if !(ret := DllCall("kernel32.dll\GetActiveProcessorCount", "UShort", GroupNumber)) 14 | return DllCall("kernel32.dll\GetLastError") 15 | return ret 16 | } 17 | ; =============================================================================================================================== 18 | 19 | MsgBox % GetActiveProcessorCount() 20 | 21 | 22 | 23 | 24 | 25 | /* C++ ========================================================================================================================== 26 | DWORD GetActiveProcessorCount( // UInt 27 | _In_ WORD GroupNumber // UShort 28 | ); 29 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Process and Thread Functions/GetActiveProcessorGroupCount.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetActiveProcessorGroupCount 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/dd405486.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/dd405486.aspx 10 | ; =============================================================================================================================== 11 | GetActiveProcessorGroupCount() 12 | { 13 | if !(ret := DllCall("kernel32.dll\GetActiveProcessorGroupCount")) 14 | return DllCall("kernel32.dll\GetLastError") 15 | return ret 16 | } 17 | ; =============================================================================================================================== 18 | 19 | MsgBox % GetActiveProcessorGroupCount() 20 | 21 | 22 | 23 | 24 | 25 | /* C++ ========================================================================================================================== 26 | WORD GetActiveProcessorGroupCount(void); // UShort 27 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Process and Thread Functions/GetCommandLine.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetCommandLine 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms683156.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms683156.aspx 10 | ; =============================================================================================================================== 11 | GetCommandLine() 12 | { 13 | return DllCall("kernel32.dll\GetCommandLine") 14 | } 15 | ; =============================================================================================================================== 16 | 17 | MsgBox % GetCommandLine() 18 | 19 | 20 | 21 | 22 | 23 | /* C++ ========================================================================================================================== 24 | LPTSTR WINAPI GetCommandLine(void); // Ptr 25 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Process and Thread Functions/GetCurrentProcess.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetCurrentProcess 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms683179.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms683179.aspx 10 | ; =============================================================================================================================== 11 | GetCurrentProcess() 12 | { 13 | return DllCall("kernel32.dll\GetCurrentProcess") 14 | } 15 | ; =============================================================================================================================== 16 | 17 | MsgBox % GetCurrentProcess() 18 | 19 | 20 | 21 | 22 | 23 | /* C++ ========================================================================================================================== 24 | HANDLE WINAPI GetCurrentProcess(void); // Ptr 25 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Process and Thread Functions/GetCurrentProcessId.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetCurrentProcessId 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms683180.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms683180.aspx 10 | ; =============================================================================================================================== 11 | GetCurrentProcessId() 12 | { 13 | return DllCall("kernel32.dll\GetCurrentProcessId") 14 | } 15 | ; =============================================================================================================================== 16 | 17 | MsgBox % GetCurrentProcessId() 18 | 19 | 20 | 21 | 22 | 23 | /* C++ ========================================================================================================================== 24 | DWORD WINAPI GetCurrentProcessId(void); // UInt 25 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Process and Thread Functions/GetCurrentProcessorNumber.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetCurrentProcessorNumber 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms683181.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms683181.aspx 10 | ; =============================================================================================================================== 11 | GetCurrentProcessorNumber() 12 | { 13 | return DllCall("kernel32.dll\GetCurrentProcessorNumber") 14 | } 15 | ; =============================================================================================================================== 16 | 17 | MsgBox % GetCurrentProcessorNumber() 18 | 19 | 20 | 21 | 22 | 23 | /* C++ ========================================================================================================================== 24 | DWORD WINAPI GetCurrentProcessorNumber(void); // UInt 25 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Process and Thread Functions/GetCurrentThread.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetCurrentThread 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms683182.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms683182.aspx 10 | ; =============================================================================================================================== 11 | GetCurrentThread() 12 | { 13 | return DllCall("kernel32.dll\GetCurrentThread") 14 | } 15 | ; =============================================================================================================================== 16 | 17 | MsgBox % GetCurrentThread() 18 | 19 | 20 | 21 | 22 | 23 | /* C++ ========================================================================================================================== 24 | HANDLE WINAPI GetCurrentThread(void); // Ptr 25 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Process and Thread Functions/GetCurrentThreadId.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetCurrentThreadId 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms683183.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms683183.aspx 10 | ; =============================================================================================================================== 11 | GetCurrentThreadId() 12 | { 13 | return DllCall("kernel32.dll\GetCurrentThreadId") 14 | } 15 | ; =============================================================================================================================== 16 | 17 | MsgBox % GetCurrentThreadId() 18 | 19 | 20 | 21 | 22 | 23 | /* C++ ========================================================================================================================== 24 | DWORD WINAPI GetCurrentThreadId(void); // UInt 25 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Process and Thread Functions/GetMaximumProcessorCount.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetMaximumProcessorCount 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/dd405489.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/dd405489.aspx 10 | ; =============================================================================================================================== 11 | GetMaximumProcessorCount(GroupNumber) 12 | { 13 | if !(ret := DllCall("kernel32.dll\GetMaximumProcessorCount", "UShort", GroupNumber)) 14 | return DllCall("kernel32.dll\GetLastError") 15 | return ret 16 | } 17 | ; =============================================================================================================================== 18 | 19 | MsgBox % GetMaximumProcessorCount(0xffff) 20 | 21 | 22 | 23 | 24 | 25 | /* C++ ========================================================================================================================== 26 | DWORD GetMaximumProcessorCount( // UInt 27 | _In_ WORD GroupNumber // UShort 28 | ); 29 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Process and Thread Functions/GetMaximumProcessorGroupCount.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetMaximumProcessorGroupCount 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/dd405490.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/dd405490.aspx 10 | ; =============================================================================================================================== 11 | GetMaximumProcessorGroupCount() 12 | { 13 | if !(ret := DllCall("kernel32.dll\GetMaximumProcessorGroupCount")) 14 | return DllCall("kernel32.dll\GetLastError") 15 | return ret 16 | } 17 | ; =============================================================================================================================== 18 | 19 | MsgBox % GetMaximumProcessorGroupCount() 20 | 21 | 22 | 23 | 24 | 25 | /* C++ ========================================================================================================================== 26 | WORD GetMaximumProcessorGroupCount(void); // UShort 27 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Process and Thread Functions/GetProcessVersion.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetMaximumProcessorCount 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/dd405489.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/dd405489.aspx 10 | ; =============================================================================================================================== 11 | GetMaximumProcessorCount(ProcessId := 0) 12 | { 13 | if !(ret := DllCall("Kernel32.dll\GetMaximumProcessorCount", "UInt", ProcessId)) 14 | return DllCall("kernel32.dll\GetLastError") 15 | return ret 16 | } 17 | ; =============================================================================================================================== 18 | 19 | MsgBox % GetMaximumProcessorCount() 20 | 21 | 22 | 23 | 24 | 25 | /* C++ ========================================================================================================================== 26 | DWORD WINAPI GetProcessVersion( // UInt 27 | _In_ DWORD ProcessId // UInt 28 | ); 29 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Process and Thread Functions/Sleep.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: Sleep 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms686298.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms686298.aspx 10 | ; =============================================================================================================================== 11 | Sleep(Milliseconds) 12 | { 13 | DllCall("kernel32.dll\Sleep", "UInt", Milliseconds) 14 | } 15 | ; =============================================================================================================================== 16 | 17 | Sleep(2000) 18 | 19 | 20 | 21 | 22 | 23 | /* C++ ========================================================================================================================== 24 | VOID WINAPI Sleep( // Ptr 25 | _In_ DWORD dwMilliseconds // UInt 26 | ); 27 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Process and Thread Functions/SleepEx.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: Sleep 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms686307.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms686307.aspx 10 | ; =============================================================================================================================== 11 | SleepEx(Milliseconds, Alertable) 12 | { 13 | DllCall("kernel32.dll\SleepEx", "UInt", Milliseconds, "UInt", Alertable) 14 | } 15 | ; =============================================================================================================================== 16 | 17 | SleepEx(2000, 0) 18 | 19 | 20 | 21 | 22 | 23 | /* C++ ========================================================================================================================== 24 | DWORD WINAPI SleepEx( // UInt 25 | _In_ DWORD dwMilliseconds, // UInt 26 | _In_ BOOL bAlertable // UInt 27 | ); 28 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/String Functions/CharLower.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: CharLower 3 | ; DLL...........: User32.dll 4 | ; Library.......: User32.lib 5 | ; U/ANSI........: CharLowerW (Unicode) and CharLowerA (ANSI) 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms647467.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms647467.aspx 10 | ; =============================================================================================================================== 11 | CharLower(str) 12 | { 13 | DllCall("user32.dll\CharLower", "Ptr", &str, "Ptr") 14 | return StrGet(&str) 15 | } 16 | ; =============================================================================================================================== 17 | 18 | MsgBox % CharLower("UPPER_TO_LOWER") 19 | 20 | 21 | 22 | 23 | 24 | /* C++ ========================================================================================================================== 25 | LPTSTR WINAPI CharLower( // Ptr (Str) 26 | _Inout_ LPTSTR lpsz // Ptr (Str) 27 | ); 28 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/String Functions/CharLowerBuff.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: CharLowerBuff 3 | ; DLL...........: User32.dll 4 | ; Library.......: User32.lib 5 | ; U/ANSI........: CharLowerBuffW (Unicode) and CharLowerBuffA (ANSI) 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms647468.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms647468.aspx 10 | ; =============================================================================================================================== 11 | CharLowerBuff(str, len) 12 | { 13 | if (DllCall("user32.dll\CharLowerBuff", "Ptr", &str, "UInt", len) = len) 14 | return StrGet(&str) 15 | } 16 | ; =============================================================================================================================== 17 | 18 | MsgBox % CharLowerBuff("UPPER_TO_LOWER", 5) 19 | 20 | 21 | 22 | 23 | 24 | /* C++ ========================================================================================================================== 25 | DWORD WINAPI CharLowerBuff( // UInt 26 | _Inout_ LPTSTR lpsz, // Str 27 | _In_ DWORD cchLength // UInt 28 | ); 29 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/String Functions/CharUpper.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: CharUpper 3 | ; DLL...........: User32.dll 4 | ; Library.......: User32.lib 5 | ; U/ANSI........: CharUpperW (Unicode) and CharUpperA (ANSI) 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms647474.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms647474.aspx 10 | ; =============================================================================================================================== 11 | CharUpper(str) 12 | { 13 | DllCall("user32.dll\CharUpper", "Ptr", &str, "Ptr") 14 | return StrGet(&str) 15 | } 16 | ; =============================================================================================================================== 17 | 18 | MsgBox % CharUpper("lower_to_upper") 19 | 20 | 21 | 22 | 23 | 24 | /* C++ ========================================================================================================================== 25 | LPTSTR WINAPI CharUpper( // Ptr (Str) 26 | _Inout_ LPTSTR lpsz // Ptr (Str) 27 | ); 28 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/String Functions/CharUpperBuff.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: CharUpperBuff 3 | ; DLL...........: User32.dll 4 | ; Library.......: User32.lib 5 | ; U/ANSI........: CharUpperBuffW (Unicode) and CharUpperBuffA (ANSI) 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms647475.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms647475.aspx 10 | ; =============================================================================================================================== 11 | CharUpperBuff(str, len) 12 | { 13 | if (DllCall("user32.dll\CharUpperBuff", "Ptr", &str, "UInt", len) = len) 14 | return StrGet(&str) 15 | } 16 | ; =============================================================================================================================== 17 | 18 | MsgBox % CharUpperBuff("lower_to_upper", 5) 19 | 20 | 21 | 22 | 23 | 24 | /* C++ ========================================================================================================================== 25 | DWORD WINAPI CharUpperBuff( // UInt 26 | _Inout_ LPTSTR lpsz, // Str 27 | _In_ DWORD cchLength // UInt 28 | ); 29 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/System Information Functions/GetComputerName.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetComputerName 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: GetComputerNameW (Unicode) and GetComputerNameA (ANSI) 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms724295.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms724295.aspx 10 | ; =============================================================================================================================== 11 | GetComputerName() 12 | { 13 | static size := 31 + 1 * (A_IsUnicode ? 2 : 1), init := VarSetCapacity(buf, size, 0) 14 | if !(DllCall("kernel32.dll\GetComputerName", "Ptr", &buf, "UInt*", size)) 15 | return DllCall("kernel32.dll\GetLastError") 16 | return StrGet(&buf, size, "UTF-16") 17 | } 18 | ; =============================================================================================================================== 19 | 20 | MsgBox % GetComputerName() 21 | 22 | 23 | 24 | 25 | 26 | /* C++ ========================================================================================================================== 27 | BOOL WINAPI GetComputerName( // UInt 28 | _Out_ LPTSTR lpBuffer, // Ptr 29 | _Inout_ LPDWORD lpnSize // UInt* 30 | ); 31 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/System Information Functions/GetProductInfo.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetProductInfo 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms724358.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms724358.aspx 10 | ; =============================================================================================================================== 11 | GetProductInfo(OSMaj, OSMin, SpMaj, SpMin) 12 | { 13 | if !(DllCall("kernel32.dll\GetProductInfo", "UInt", OSMaj, "UInt", OSMin, "UInt", SpMaj, "UInt", SpMin, "UInt*", ProductType)) 14 | return DllCall("kernel32.dll\GetLastError") 15 | return ProductType 16 | } 17 | ; =============================================================================================================================== 18 | 19 | GetVersionEx() 20 | { 21 | static OSVEREX, init := VarSetCapacity(OSVEREX, 284, 0) && NumPut(284, OSVEREX, "UInt") 22 | if !(DllCall("kernel32.dll\GetVersionEx", "Ptr", &OSVEREX)) 23 | return DllCall("kernel32.dll\GetLastError") 24 | return { 1 : NumGet(OSVEREX, 0, "UInt" ), 2 : NumGet(OSVEREX, 4, "UInt" ) 25 | , 3 : NumGet(OSVEREX, 8, "UInt" ), 4 : NumGet(OSVEREX, 12, "UInt" ) 26 | , 5 : NumGet(OSVEREX, 16, "UInt" ), 6 : StrGet(&OSVEREX + 20, 128, "UTF-16") 27 | , 7 : NumGet(OSVEREX, 276, "UShort"), 8 : NumGet(OSVEREX, 278, "UShort") 28 | , 9 : NumGet(OSVEREX, 280, "UShort"), 10 : NumGet(OSVEREX, 282, "UChar" ) } 29 | } 30 | 31 | GetVersionEx := GetVersionEx() 32 | 33 | MsgBox % GetProductInfo(GetVersionEx[2], GetVersionEx[3], GetVersionEx[7], GetVersionEx[8]) 34 | 35 | 36 | 37 | 38 | 39 | /* C++ ========================================================================================================================== 40 | BOOL WINAPI GetProductInfo( // UInt 41 | _In_ DWORD dwOSMajorVersion, // UInt 42 | _In_ DWORD dwOSMinorVersion, // UInt 43 | _In_ DWORD dwSpMajorVersion, // UInt 44 | _In_ DWORD dwSpMinorVersion, // UInt 45 | _Out_ PDWORD pdwReturnedProductType // UInt* 46 | ); 47 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/System Information Functions/GetSystemDirectory.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetSystemDirectory 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: GetSystemDirectoryW (Unicode) and GetSystemDirectoryA (ANSI) 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms724373.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms724373.aspx 10 | ; =============================================================================================================================== 11 | GetSystemDirectory() 12 | { 13 | static size := VarSetCapacity(buf, 260, 0) 14 | if !(DllCall("kernel32.dll\GetSystemDirectory", "Ptr", &buf, "UInt", size)) 15 | return DllCall("kernel32.dll\GetLastError") 16 | return StrGet(&buf, size, "UTF-16") 17 | } 18 | ; =============================================================================================================================== 19 | 20 | MsgBox % GetSystemDirectory() 21 | 22 | 23 | 24 | 25 | 26 | /* C++ ========================================================================================================================== 27 | UINT WINAPI GetSystemDirectory( // UInt 28 | _Out_ LPTSTR lpBuffer, // Ptr (Str) 29 | _In_ UINT uSize // UInt 30 | ); 31 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/System Information Functions/GetSystemRegistryQuota.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetSystemRegistryQuota 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms724387.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms724387.aspx 10 | ; =============================================================================================================================== 11 | GetSystemRegistryQuota() 12 | { 13 | if !(DllCall("kernel32.dll\GetSystemRegistryQuota", "UInt*", QuotaAllowed, "UInt*", QuotaUsed)) 14 | return DllCall("kernel32.dll\GetLastError") 15 | return { 1: QuotaAllowed, 2 : QuotaUsed } 16 | } 17 | ; =============================================================================================================================== 18 | 19 | GetSystemRegistryQuota := GetSystemRegistryQuota() 20 | 21 | MsgBox % "pdwQuotaAllowed:`t" GetSystemRegistryQuota[1] " bytes`n" 22 | . "pdwQuotaUsed:`t" GetSystemRegistryQuota[2] " bytes" 23 | 24 | 25 | 26 | 27 | 28 | /* C++ ========================================================================================================================== 29 | BOOL WINAPI GetSystemRegistryQuota( // UInt 30 | _Out_opt_ PDWORD pdwQuotaAllowed, // UInt* 31 | _Out_opt_ PDWORD pdwQuotaUsed // UInt* 32 | ); 33 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/System Information Functions/GetSystemWindowsDirectory.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetSystemWindowsDirectory 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: GetSystemWindowsDirectoryW (Unicode) and GetSystemWindowsDirectoryA (ANSI) 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms724403.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms724403.aspx 10 | ; =============================================================================================================================== 11 | GetSystemWindowsDirectory() 12 | { 13 | static size := VarSetCapacity(buf, 260, 0) 14 | if !(DllCall("kernel32.dll\GetSystemWindowsDirectory", "Ptr", &buf, "UInt", size)) 15 | return DllCall("kernel32.dll\GetLastError") 16 | return StrGet(&buf, size, "UTF-16") 17 | } 18 | ; =============================================================================================================================== 19 | 20 | MsgBox % GetSystemWindowsDirectory() 21 | 22 | 23 | 24 | 25 | 26 | /* C++ ========================================================================================================================== 27 | UINT WINAPI GetSystemWindowsDirectory( // UInt 28 | _Out_ LPTSTR lpBuffer, // Ptr (Str) 29 | _In_ UINT uSize // UInt 30 | ); 31 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/System Information Functions/GetSystemWow64Directory.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetSystemWow64Directory 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: GetSystemWow64DirectoryW (Unicode) and GetSystemWow64DirectoryA (ANSI) 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms724405.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms724405.aspx 10 | ; =============================================================================================================================== 11 | GetSystemWow64Directory() 12 | { 13 | static size := VarSetCapacity(buf, 260, 0) 14 | if !(DllCall("kernel32.dll\GetSystemWow64Directory", "Ptr", &buf, "UInt", size)) 15 | return DllCall("kernel32.dll\GetLastError") 16 | return StrGet(&buf, size, "UTF-16") 17 | } 18 | ; =============================================================================================================================== 19 | 20 | MsgBox % GetSystemWow64Directory() 21 | 22 | 23 | 24 | 25 | 26 | /* C++ ========================================================================================================================== 27 | UINT WINAPI GetSystemWow64Directory( // UInt 28 | _Out_ LPTSTR lpBuffer, // Ptr (Str) 29 | _In_ UINT uSize // UInt 30 | ); 31 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/System Information Functions/GetUserName.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetUserName 3 | ; DLL...........: Advapi32.dll 4 | ; Library.......: Advapi32.lib 5 | ; U/ANSI........: GetUserNameW (Unicode) and GetUserNameA (ANSI) 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms724432.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms724432.aspx 10 | ; =============================================================================================================================== 11 | GetUserName() 12 | { 13 | static size := VarSetCapacity(buf, 256, 0) + 1 14 | if !(DllCall("advapi32.dll\GetUserName", "Ptr", &buf, "UInt*", size)) 15 | return DllCall("kernel32.dll\GetLastError") 16 | return StrGet(&buf, size, "UTF-16") 17 | } 18 | ; =============================================================================================================================== 19 | 20 | MsgBox % GetUserName() 21 | 22 | 23 | 24 | 25 | 26 | /* C++ ========================================================================================================================== 27 | BOOL WINAPI GetUserName( // UInt 28 | _Out_ LPTSTR lpBuffer, // Ptr (Str) 29 | _Inout_ LPDWORD lpnSize // UInt* 30 | ); 31 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/System Information Functions/GetUserNameEx.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetUserNameEx 3 | ; DLL...........: Secur32.dll 4 | ; Library.......: Secur32.lib 5 | ; U/ANSI........: GetUserNameExW (Unicode) and GetUserNameExA (ANSI) 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms724435.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms724435.aspx 10 | ; =============================================================================================================================== 11 | GetUserNameEx(name := 2) 12 | { 13 | static size := VarSetCapacity(buf, 1023, 0) + 1 14 | if !(DllCall("secur32.dll\GetUserNameEx", "UInt", name, "Ptr", &buf, "UInt*", size)) 15 | return DllCall("kernel32.dll\GetLastError") 16 | return StrGet(&buf, size, "UTF-16") 17 | } 18 | ; =============================================================================================================================== 19 | 20 | MsgBox % GetUserNameEx(2) 21 | 22 | 23 | 24 | 25 | 26 | /* C++ ========================================================================================================================== 27 | BOOLEAN WINAPI GetUserNameEx( // UChar 28 | _In_ EXTENDED_NAME_FORMAT NameFormat, // UInt 29 | _Out_ LPTSTR lpNameBuffer, // Ptr (Str) 30 | _Inout_ PULONG lpnSize // UInt* 31 | ); 32 | 33 | 34 | 35 | typedef enum { 36 | NameUnknown = 0, 37 | NameFullyQualifiedDN = 1, (e.g. CN=Jeff Smith,OU=Users,DC=Engineering,DC=Microsoft,DC=Com) 38 | NameSamCompatible = 2, (e.g. Engineering\JSmith) 39 | NameDisplay = 3, (e.g. Jeff Smith) 40 | NameUniqueId = 6, (e.g. {4fa050f0-f561-11cf-bdd9-00aa003a77b6}) 41 | NameCanonical = 7, (e.g. engineering.microsoft.com/software/someone) 42 | NameUserPrincipal = 8, (e.g. someone@example.com) 43 | NameCanonicalEx = 9, (e.g. engineering.microsoft.com/software\nJSmith) 44 | NameServicePrincipal = 10, (e.g. www/www.microsoft.com@microsoft.com) 45 | NameDnsDomain = 12 The DNS domain name followed by a backward-slash and the SAM user name. 46 | } EXTENDED_NAME_FORMAT, *PEXTENDED_NAME_FORMAT; 47 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/System Information Functions/GetVersion.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetVersion 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms724439.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms724439.aspx 10 | ; =============================================================================================================================== 11 | GetVersion() 12 | { 13 | return { 1 : LOBYTE(LOWORD(DllCall("kernel32.dll\GetVersion"))) 14 | , 2 : HIBYTE(LOWORD(DllCall("kernel32.dll\GetVersion"))) 15 | , 3 : HIWORD(DllCall("kernel32.dll\GetVersion")) } 16 | } 17 | LOWORD(l) 18 | { 19 | return l & 0xffff 20 | } 21 | HIWORD(l) 22 | { 23 | return (l >> 16) & 0xffff 24 | } 25 | LOBYTE(w) 26 | { 27 | return w & 0xff 28 | } 29 | HIBYTE(w) 30 | { 31 | return (w >> 8) & 0xff 32 | } 33 | ; =============================================================================================================================== 34 | 35 | GetVersion := GetVersion() 36 | MsgBox % "Major:`t" GetVersion[1] "`n" 37 | . "Minor:`t" GetVersion[2] "`n" 38 | . "Build:`t" GetVersion[3] 39 | 40 | 41 | MajorVersion := DllCall("kernel32.dll\GetVersion") & 0xff 42 | MinorVersion := DllCall("kernel32.dll\GetVersion") >> 8 & 0xff 43 | BuildVersion := DllCall("kernel32.dll\GetVersion") >> 16 & 0xffff 44 | 45 | MsgBox % MajorVersion "." MinorVersion "." BuildVersion 46 | 47 | MsgBox % ((GV := DllCall("kernel32.dll\GetVersion") & 0xFFFF) & 0xFF) (GV >> 8) 48 | MsgBox % ((m := (b := DllCall("kernel32.dll\GetVersion")) & 0xFFFF) & 0xFF) "." (m >> 8) "." (b >> 16) 49 | 50 | 51 | 52 | 53 | 54 | /* C++ ========================================================================================================================== 55 | DWORD WINAPI GetVersion(void); // UInt 56 | 57 | 58 | void main() 59 | { 60 | DWORD dwVersion = 0; 61 | DWORD dwMajorVersion = 0; 62 | DWORD dwMinorVersion = 0; 63 | DWORD dwBuild = 0; 64 | 65 | dwVersion = GetVersion(); 66 | 67 | // Get the Windows version. 68 | dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion))); 69 | dwMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion))); 70 | 71 | // Get the build number. 72 | if (dwVersion < 0x80000000) 73 | dwBuild = (DWORD)(HIWORD(dwVersion)); 74 | 75 | printf("Version is %d.%d (%d)\n", dwMajorVersion, dwMinorVersion, dwBuild); 76 | } 77 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/System Information Functions/GetVersionEx.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetVersionEx 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: GetVersionExW (Unicode) and GetVersionExA (ANSI) 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms724451.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms724451.aspx 10 | ; =============================================================================================================================== 11 | GetVersionEx() 12 | { 13 | static OSVEREX, init := VarSetCapacity(OSVEREX, 284, 0) && NumPut(284, OSVEREX, "UInt") 14 | if !(DllCall("kernel32.dll\GetVersionEx", "Ptr", &OSVEREX)) 15 | return DllCall("kernel32.dll\GetLastError") 16 | return { 1 : NumGet(OSVEREX, 0, "UInt" ), 2 : NumGet(OSVEREX, 4, "UInt" ) 17 | , 3 : NumGet(OSVEREX, 8, "UInt" ), 4 : NumGet(OSVEREX, 12, "UInt" ) 18 | , 5 : NumGet(OSVEREX, 16, "UInt" ), 6 : StrGet(&OSVEREX + 20, 128, "UTF-16") 19 | , 7 : NumGet(OSVEREX, 276, "UShort"), 8 : NumGet(OSVEREX, 278, "UShort") 20 | , 9 : NumGet(OSVEREX, 280, "UShort"), 10 : NumGet(OSVEREX, 282, "UChar" ) } 21 | } 22 | ; =============================================================================================================================== 23 | 24 | GetVersionEx := GetVersionEx() 25 | 26 | MsgBox % "GetVersionEx function`n" 27 | . "OSVERSIONINFOEX structure`n`n" 28 | . "OSVersionInfoSize:`t`t" GetVersionEx[1] "`n" 29 | . "MajorVersion:`t`t" GetVersionEx[2] "`n" 30 | . "MinorVersion:`t`t" GetVersionEx[3] "`n" 31 | . "BuildNumber:`t`t" GetVersionEx[4] "`n" 32 | . "PlatformId:`t`t" GetVersionEx[5] "`n" 33 | . "CSDVersion:`t`t" GetVersionEx[6] "`n" 34 | . "ServicePackMajor:`t`t" GetVersionEx[7] "`n" 35 | . "ServicePackMinor:`t`t" GetVersionEx[8] "`n" 36 | . "SuiteMask:`t`t" GetVersionEx[9] "`n" 37 | . "ProductType:`t`t" GetVersionEx[10] 38 | 39 | 40 | 41 | 42 | 43 | /* C++ ========================================================================================================================== 44 | BOOL WINAPI GetVersionEx( // UInt 45 | _Inout_ LPOSVERSIONINFO lpVersionInfo // Ptr (284) 46 | ); 47 | 48 | 49 | typedef struct _OSVERSIONINFOEX { 50 | DWORD dwOSVersionInfoSize; // UInt 4 => 0 51 | DWORD dwMajorVersion; // UInt 4 => 4 52 | DWORD dwMinorVersion; // UInt 4 => 8 53 | DWORD dwBuildNumber; // UInt 4 => 12 54 | DWORD dwPlatformId; // UInt 4 => 16 55 | TCHAR szCSDVersion[128]; // UTF-16 128 => 128 56 | WORD wServicePackMajor; // UShort 2 => 276 57 | WORD wServicePackMinor; // UShort 2 => 278 58 | WORD wSuiteMask; // UShort 2 => 280 59 | BYTE wProductType; // UChar 2 => 282 60 | BYTE wReserved; // Reserved for future use. 61 | } OSVERSIONINFOEX, *POSVERSIONINFOEX, *LPOSVERSIONINFOEX; 62 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/System Information Functions/GetWindowsDirectory.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetWindowsDirectory 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: GetWindowsDirectoryW (Unicode) and GetWindowsDirectoryA (ANSI) 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms724454.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms724454.aspx 10 | ; =============================================================================================================================== 11 | GetWindowsDirectory() 12 | { 13 | static size := VarSetCapacity(buf, 260, 0) 14 | if !(DllCall("kernel32.dll\GetWindowsDirectory", "Ptr", &buf, "UInt", size)) 15 | return DllCall("kernel32.dll\GetLastError") 16 | return StrGet(&buf, size, "UTF-16") 17 | } 18 | ; =============================================================================================================================== 19 | 20 | MsgBox % GetWindowsDirectory() 21 | 22 | 23 | 24 | 25 | 26 | /* C++ ========================================================================================================================== 27 | UINT WINAPI GetWindowsDirectory( // UInt 28 | _Out_ LPTSTR lpBuffer, // Ptr (Str) 29 | _In_ UINT uSize // UInt 30 | ); 31 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/System Information Functions/QueryPerformanceCounter.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: QueryPerformanceCounter 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms644904.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms644904.aspx 10 | ; =============================================================================================================================== 11 | QueryPerformanceCounter() 12 | { 13 | if !(DllCall("kernel32.dll\QueryPerformanceCounter", "Int64*", PerformanceCount)) 14 | return DllCall("kernel32.dll\GetLastError") 15 | return PerformanceCount 16 | } 17 | ; =============================================================================================================================== 18 | 19 | MsgBox % QueryPerformanceCounter() 20 | 21 | 22 | DllCall("kernel32.dll\QueryPerformanceFrequency", "Int64*", F) 23 | DllCall("kernel32.dll\QueryPerformanceCounter", "Int64*", S) 24 | loop 10000000 25 | i++ 26 | DllCall("kernel32.dll\QueryPerformanceCounter", "Int64*", E) 27 | MsgBox % (E - S) / F 28 | 29 | 30 | 31 | 32 | 33 | /* C++ ========================================================================================================================== 34 | BOOL WINAPI QueryPerformanceCounter( // UInt 35 | _Out_ LARGE_INTEGER *lpPerformanceCount // Int64* 36 | ); 37 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/System Information Functions/QueryPerformanceFrequency.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: QueryPerformanceFrequency 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms644905.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms644905.aspx 10 | ; =============================================================================================================================== 11 | QueryPerformanceFrequency() 12 | { 13 | if !(DllCall("kernel32.dll\QueryPerformanceFrequency", "Int64*", Frequency)) 14 | return DllCall("kernel32.dll\GetLastError") 15 | return Frequency 16 | } 17 | ; =============================================================================================================================== 18 | 19 | MsgBox % QueryPerformanceFrequency() 20 | 21 | 22 | DllCall("kernel32.dll\QueryPerformanceFrequency", "Int64*", F) 23 | DllCall("kernel32.dll\QueryPerformanceCounter", "Int64*", S) 24 | loop 10000000 25 | i++ 26 | DllCall("kernel32.dll\QueryPerformanceCounter", "Int64*", E) 27 | MsgBox % (E - S) / F 28 | 29 | 30 | 31 | 32 | 33 | /* C++ ========================================================================================================================== 34 | BOOL WINAPI QueryPerformanceFrequency( // UInt 35 | _Out_ LARGE_INTEGER *lpFrequency // Int64* 36 | ); 37 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/System Shutdown Functions/LockWorkStation.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: LockWorkStation 3 | ; DLL...........: User32.dll 4 | ; Library.......: User32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/aa376875.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/aa376875.aspx 10 | ; =============================================================================================================================== 11 | LockWorkStation() 12 | { 13 | if !(DllCall("user32.dll\LockWorkStation")) 14 | return DllCall("kernel32.dll\GetLastError") 15 | return 1 16 | } 17 | ; =============================================================================================================================== 18 | 19 | LockWorkStation() 20 | 21 | 22 | 23 | 24 | 25 | /* C++ ========================================================================================================================== 26 | BOOL WINAPI LockWorkStation(void); // UInt 27 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Time Functions/GetLocalTime.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetLocalTime 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms724338.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms724338.aspx 10 | ; =============================================================================================================================== 11 | GetLocalTime() 12 | { 13 | static SYSTEMTIME, init := VarSetCapacity(SYSTEMTIME, 16, 0) && NumPut(16, SYSTEMTIME, "UShort") 14 | DllCall("kernel32.dll\GetLocalTime", "Ptr", &SYSTEMTIME, "Ptr") 15 | return { 1 : NumGet(SYSTEMTIME, 0, "UShort"), 2 : NumGet(SYSTEMTIME, 2, "UShort") 16 | , 3 : NumGet(SYSTEMTIME, 4, "UShort"), 4 : NumGet(SYSTEMTIME, 6, "UShort") 17 | , 5 : NumGet(SYSTEMTIME, 8, "UShort"), 6 : NumGet(SYSTEMTIME, 10, "UShort") 18 | , 7 : NumGet(SYSTEMTIME, 12, "UShort"), 8 : NumGet(SYSTEMTIME, 14, "UShort") } 19 | } 20 | ; =============================================================================================================================== 21 | 22 | GetLocalTime := GetLocalTime() 23 | 24 | MsgBox % "GetLocalTime function`n" 25 | . "SYSTEMTIME structure`n`n" 26 | . "wYear:`t`t" GetLocalTime[1] "`n" 27 | . "wMonth:`t`t" GetLocalTime[2] "`n" 28 | . "wDayOfWeek:`t" GetLocalTime[3] "`n" 29 | . "wDay:`t`t" GetLocalTime[4] "`n" 30 | . "wHour:`t`t" GetLocalTime[5] "`n" 31 | . "wMinute:`t`t" GetLocalTime[6] "`n" 32 | . "wSecond:`t`t" GetLocalTime[7] "`n" 33 | . "wMilliseconds:`t" GetLocalTime[8] 34 | 35 | 36 | 37 | 38 | 39 | /* C++ ========================================================================================================================== 40 | void WINAPI GetLocalTime( // Ptr 41 | _Out_ LPSYSTEMTIME lpSystemTime // Ptr (16) 42 | ); 43 | 44 | 45 | typedef struct _SYSTEMTIME { 46 | WORD wYear; // UShort 2 => 0 47 | WORD wMonth; // UShort 2 => 2 48 | WORD wDayOfWeek; // UShort 2 => 4 49 | WORD wDay; // UShort 2 => 6 50 | WORD wHour; // UShort 2 => 8 51 | WORD wMinute; // UShort 2 => 10 52 | WORD wSecond; // UShort 2 => 12 53 | WORD wMilliseconds; // UShort 2 => 14 54 | } SYSTEMTIME, *PSYSTEMTIME; 55 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Time Functions/GetSystemTime.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetSystemTime 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms724390.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms724390.aspx 10 | ; =============================================================================================================================== 11 | GetSystemTime() 12 | { 13 | static SYSTEMTIME, init := VarSetCapacity(SYSTEMTIME, 16, 0) && NumPut(16, SYSTEMTIME, "UShort") 14 | DllCall("kernel32.dll\GetSystemTime", "Ptr", &SYSTEMTIME, "Ptr") 15 | return { 1 : NumGet(SYSTEMTIME, 0, "UShort"), 2 : NumGet(SYSTEMTIME, 2, "UShort") 16 | , 3 : NumGet(SYSTEMTIME, 4, "UShort"), 4 : NumGet(SYSTEMTIME, 6, "UShort") 17 | , 5 : NumGet(SYSTEMTIME, 8, "UShort"), 6 : NumGet(SYSTEMTIME, 10, "UShort") 18 | , 7 : NumGet(SYSTEMTIME, 12, "UShort"), 8 : NumGet(SYSTEMTIME, 14, "UShort") } 19 | } 20 | ; =============================================================================================================================== 21 | 22 | GetSystemTime := GetSystemTime() 23 | 24 | MsgBox % "GetSystemTime function`n" 25 | . "SYSTEMTIME structure`n`n" 26 | . "wYear:`t`t" GetSystemTime[1] "`n" 27 | . "wMonth:`t`t" GetSystemTime[2] "`n" 28 | . "wDayOfWeek:`t" GetSystemTime[3] "`n" 29 | . "wDay:`t`t" GetSystemTime[4] "`n" 30 | . "wHour:`t`t" GetSystemTime[5] "`n" 31 | . "wMinute:`t`t" GetSystemTime[6] "`n" 32 | . "wSecond:`t`t" GetSystemTime[7] "`n" 33 | . "wMilliseconds:`t" GetSystemTime[8] 34 | 35 | 36 | 37 | 38 | 39 | /* C++ ========================================================================================================================== 40 | void WINAPI GetSystemTime( // Ptr 41 | _Out_ LPSYSTEMTIME lpSystemTime // Ptr (16) 42 | ); 43 | 44 | 45 | typedef struct _SYSTEMTIME { 46 | WORD wYear; // UShort 2 => 0 47 | WORD wMonth; // UShort 2 => 2 48 | WORD wDayOfWeek; // UShort 2 => 4 49 | WORD wDay; // UShort 2 => 6 50 | WORD wHour; // UShort 2 => 8 51 | WORD wMinute; // UShort 2 => 10 52 | WORD wSecond; // UShort 2 => 12 53 | WORD wMilliseconds; // UShort 2 => 14 54 | } SYSTEMTIME, *PSYSTEMTIME; 55 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Time Functions/GetTickCount.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetTickCount 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms724408.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms724408.aspx 10 | ; =============================================================================================================================== 11 | GetTickCount() 12 | { 13 | return DllCall("kernel32.dll\GetTickCount", "UInt") 14 | } 15 | ; =============================================================================================================================== 16 | 17 | MsgBox % GetTickCount() 18 | 19 | 20 | 21 | 22 | 23 | /* C++ ========================================================================================================================== 24 | DWORD WINAPI GetTickCount(void); // UInt 25 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Time Functions/GetTickCount64.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetTickCount64 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms724411.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms724411.aspx 10 | ; =============================================================================================================================== 11 | GetTickCount64() 12 | { 13 | return DllCall("kernel32.dll\GetTickCount64", "UInt64") 14 | } 15 | ; =============================================================================================================================== 16 | 17 | MsgBox % GetTickCount64() 18 | 19 | 20 | 21 | 22 | 23 | /* C++ ========================================================================================================================== 24 | ULONGLONG WINAPI GetTickCount64(void); // UInt64 25 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Time Functions/SetLocalTime.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: SetLocalTime 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms724936.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms724936.aspx 10 | ; =============================================================================================================================== 11 | SetLocalTime(Year := 1601, Month := 1, DayOfWeek := 0, Day := 1, Hour := 0, Minute := 0, Second := 0, Milliseconds := 0) 12 | { 13 | static VarSetCapacity(SYSTEMTIME, 16) 14 | , NumPut(Year, SYSTEMTIME, 0, "UShort"), NumPut(Month, SYSTEMTIME, 2, "UShort") 15 | , NumPut(DayOfWeek, SYSTEMTIME, 4, "UShort"), NumPut(Day, SYSTEMTIME, 6, "UShort") 16 | , NumPut(Hour, SYSTEMTIME, 8, "UShort"), NumPut(Minute, SYSTEMTIME, 10, "UShort") 17 | , NumPut(Second, SYSTEMTIME, 12, "UShort"), NumPut(Milliseconds, SYSTEMTIME, 14, "UShort") 18 | if !(DllCall("kernel32.dll\SetLocalTime", "Ptr", &SYSTEMTIME)) 19 | return DllCall("kernel32.dll\GetLastError") 20 | return 1 21 | } 22 | ; =============================================================================================================================== 23 | 24 | SetLocalTime(2015, 1, 25, 7, 13, 37, 27, 724) 25 | 26 | 27 | 28 | 29 | 30 | /* C++ ========================================================================================================================== 31 | BOOL WINAPI SetLocalTime( // UInt 32 | _In_ const SYSTEMTIME *lpSystemTime // Ptr (16) 33 | ); 34 | 35 | 36 | typedef struct _SYSTEMTIME { 37 | WORD wYear; // UShort 2 => 0 38 | WORD wMonth; // UShort 2 => 2 39 | WORD wDayOfWeek; // UShort 2 => 4 40 | WORD wDay; // UShort 2 => 6 41 | WORD wHour; // UShort 2 => 8 42 | WORD wMinute; // UShort 2 => 10 43 | WORD wSecond; // UShort 2 => 12 44 | WORD wMilliseconds; // UShort 2 => 14 45 | } SYSTEMTIME, *PSYSTEMTIME; 46 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Time Functions/SetSystemTime.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: SetSystemTime 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/ms724942.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms724942.aspx 10 | ; =============================================================================================================================== 11 | SetSystemTime(Year := 1601, Month := 1, DayOfWeek := 0, Day := 1, Hour := 0, Minute := 0, Second := 0, Milliseconds := 0) 12 | { 13 | static VarSetCapacity(SYSTEMTIME, 16) 14 | , NumPut(Year, SYSTEMTIME, 0, "UShort"), NumPut(Month, SYSTEMTIME, 2, "UShort") 15 | , NumPut(DayOfWeek, SYSTEMTIME, 4, "UShort"), NumPut(Day, SYSTEMTIME, 6, "UShort") 16 | , NumPut(Hour, SYSTEMTIME, 8, "UShort"), NumPut(Minute, SYSTEMTIME, 10, "UShort") 17 | , NumPut(Second, SYSTEMTIME, 12, "UShort"), NumPut(Milliseconds, SYSTEMTIME, 14, "UShort") 18 | if !(DllCall("kernel32.dll\SetSystemTime", "Ptr", &SYSTEMTIME)) 19 | return DllCall("kernel32.dll\GetLastError") 20 | return 1 21 | } 22 | ; =============================================================================================================================== 23 | 24 | SetSystemTime(2015, 1, 25, 7, 13, 37, 27, 724) 25 | 26 | 27 | 28 | 29 | 30 | /* C++ ========================================================================================================================== 31 | BOOL WINAPI SetSystemTime( // UInt 32 | _In_ const SYSTEMTIME *lpSystemTime // Ptr (16) 33 | ); 34 | 35 | 36 | typedef struct _SYSTEMTIME { 37 | WORD wYear; // UShort 2 => 0 38 | WORD wMonth; // UShort 2 => 2 39 | WORD wDayOfWeek; // UShort 2 => 4 40 | WORD wDay; // UShort 2 => 6 41 | WORD wHour; // UShort 2 => 8 42 | WORD wMinute; // UShort 2 => 10 43 | WORD wSecond; // UShort 2 => 12 44 | WORD wMilliseconds; // UShort 2 => 14 45 | } SYSTEMTIME, *PSYSTEMTIME; 46 | ============================================================================================================================== */ -------------------------------------------------------------------------------- /src/Volume Management Functions/GetDriveType.ahk: -------------------------------------------------------------------------------- 1 | ; =============================================================================================================================== 2 | ; Function......: GetDriveType 3 | ; DLL...........: Kernel32.dll 4 | ; Library.......: Kernel32.lib 5 | ; U/ANSI........: GetDriveTypeW (Unicode) and GetDriveTypeA (ANSI) 6 | ; Author........: jNizM 7 | ; Modified......: 8 | ; Links.........: https://msdn.microsoft.com/en-us/library/aa364939.aspx 9 | ; https://msdn.microsoft.com/en-us/library/windows/desktop/aa364939.aspx 10 | ; =============================================================================================================================== 11 | GetDriveType(path, convert := 0) 12 | { 13 | static DriveType := { 0 : "DRIVE_UNKNOWN", 1 : "DRIVE_NO_ROOT_DIR", 2 : "DRIVE_REMOVABLE" 14 | , 3 : "DRIVE_FIXED", 4 : "DRIVE_REMOTE", 5 : "DRIVE_CDROM", 6 : "DRIVE_RAMDISK" } 15 | ret := DllCall("kernel32.dll\GetDriveType", "Ptr", &path) 16 | return convert ? DriveType[ret] : ret 17 | } 18 | ; =============================================================================================================================== 19 | 20 | MsgBox % GetDriveType("C:\") ; ==> 3 21 | MsgBox % GetDriveType("C:\", 1) ; ==> DRIVE_FIXED 22 | 23 | 24 | 25 | 26 | 27 | /* C++ ========================================================================================================================== 28 | UINT WINAPI GetDriveType( // UInt 29 | _In_opt_ LPCTSTR lpRootPathName // Ptr 30 | ); 31 | 32 | 33 | 34 | 0 = DRIVE_UNKNOWN // The drive type cannot be determined. 35 | 1 = DRIVE_NO_ROOT_DIR // The root path is invalid; for example, there is no volume mounted at the specified path. 36 | 2 = DRIVE_REMOVABLE // The drive has removable media; for example, a floppy drive, thumb drive, or flash card reader. 37 | 3 = DRIVE_FIXED // The drive has fixed media; for example, a hard disk drive or flash drive. 38 | 4 = DRIVE_REMOTE // The drive is a remote (network) drive. 39 | 5 = DRIVE_CDROM // The drive is a CD-ROM drive. 40 | 6 = DRIVE_RAMDISK // The drive is a RAM disk. 41 | ============================================================================================================================== */ --------------------------------------------------------------------------------