├── Forum.txt ├── LICENSE ├── README.md └── src ├── ComObject └── EnumInstalledApps.ahk ├── FileObject ├── FileCountLines.ahk ├── FileFindString.ahk ├── FileReadLastLines.ahk └── GetFilePEHeader.ahk ├── Gui ├── CreateGradient.ahk ├── DisableCloseButton.ahk ├── DisableMove.ahk └── TaskBarProgress.ahk ├── Message └── WM_DEVICECHANGE.ahk ├── Network ├── DNSQuery.ahk ├── DnsServerList.ahk ├── GetAdaptersInfo.ahk ├── GetDnsServerList.ahk ├── GetNetworkConnectivityHint.ahk ├── ResolveHostname.ahk └── ReverseLookup.ahk ├── NetworkManagement ├── NetGetJoinInformation.ahk ├── NetGroupEnum.ahk ├── NetGroupGetInfo.ahk ├── NetGroupGetUsers.ahk ├── NetLocalGroupEnum.ahk ├── NetLocalGroupGetInfo.ahk └── NetLocalGroupGetMembers.ahk ├── Others ├── CreateGUID.ahk ├── CreateUUID.ahk ├── GetFileOwner.ahk ├── GetFileVersionInfo.ahk └── IsRemoteSession.ahk ├── ProcessThreadModule ├── GetModuleBaseAddr.ahk ├── GetProcessHandles.ahk ├── GetProcessThreads.ahk ├── GetThreadStartAddr.ahk └── IsProcessElevated.ahk ├── Strings ├── Base64ToString.ahk ├── CountLeadingChar.ahk ├── GetCurrencyFormat.ahk ├── GetCurrencyFormatEx.ahk ├── GetDurationFormat.ahk ├── GetDurationFormatEx.ahk ├── GetNumberFormat.ahk ├── GetNumberFormatEx.ahk └── StringToBase64.ahk └── SystemInformation ├── SystemDeviceInformation.ahk ├── SystemHandleInformation.ahk ├── SystemPerformanceInformation.ahk ├── SystemProcessInformation.ahk ├── SystemProcessorInformation.ahk ├── SystemProcessorPerformanceInformation.ahk ├── SystemProcessorPowerInformation.ahk └── SystemSecureBootInformation.ahk /Forum.txt: -------------------------------------------------------------------------------- 1 | [center][b][color=#FB6601][size=200]Collection of useful AutoHotkey v2 scripts and functions[/size][/color][/b][/center] 2 | [center]( [url=https://github.com/jNizM/ahk-scripts-v2]GitHub[/url] - Tested with AutoHotkey v2.0.2 64-bit )[/center] 3 | 4 | 5 | [b][size=150]Source[/size][/b] 6 | [hr][/hr][url=https://github.com/jNizM/ahk-scripts-v2]Release on GitHub[/url] 7 | 8 | 9 | [b][size=150]Functions & Script Examples[/size][/b] 10 | [hr][/hr] 11 | [list] 12 | [*][b]ComObject[/b] 13 | [list] 14 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/ComObject/EnumInstalledApps.ahk]EnumInstalledApps[/url] (Gets general information about an application.) 15 | [/list] 16 | [*][b]FileObject[/b] 17 | [list] 18 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/FileObject/FileCountLines.ahk]FileCountLines[/url] (Count the number of lines in a text file.) 19 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/FileObject/FileFindString.ahk]FileFindWord[/url] (Finds a specific word / string in a text file.) 20 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/FileObject/FileReadLastLines.ahk]FileReadLastLines[/url] (Read last x lines of a text file.) 21 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/FileObject/GetFilePEHeader.ahk]GetFilePEHeader[/url] (Get the PE File Header information - Machine Type.) 22 | [/list] 23 | [*][b]Gui[/b] 24 | [list] 25 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/Gui/CreateGradient.ahk]CreateGradient[/url] (Creates a gradient bitmap for picture controls.) 26 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/Gui/DisableCloseButton.ahk]DisableCloseButton[/url] (Disables the GUI Close Button.) 27 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/Gui/DisableMove.ahk]DisableMove[/url] (Disables the GUI Move function.) 28 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/Gui/TaskBarProgress.ahk]TaskBarProgress[/url] (Displays or updates a progress bar hosted in a taskbar button.) 29 | [/list] 30 | [*][b]Messages[/b] 31 | [list] 32 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/Message/WM_DEVICECHANGE.ahk]WM_DEVICECHANGE[/url] (Detecting Media Insertion or Removal.) 33 | [/list] 34 | [*][b]Network[/b] 35 | [list] 36 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/Network/DnsServerList.ahk]DnsServerList[/url] (Gets a list of DNS servers for the local computer.) 37 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/Network/DNSQuery.ahk]DNSQuery[/url] (Retrieves the Resource Record (RR) depends on DNS Record Type.) 38 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/Network/GetAdaptersInfo.ahk]GetAdaptersInfo[/url] (Gets network adapter information for the local computer.) 39 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/Network/GetDnsServerList.ahk]GetDnsServerList[/url] (Gets a list of DNS servers for the local computer.) 40 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/Network/GetNetworkConnectivityHint.ahk]GetNetworkConnectivityHint[/url] (Retrieves the level and cost of network connectivity.) 41 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/Network/ResolveHostname.ahk]ResolveHostname[/url] (Gets the IP Address from a Hostname.) 42 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/Network/ReverseLookup.ahk]ReverseLookup[/url] (Gets the Hostname by the IP Adresse.) 43 | [/list] 44 | [*][b]NetworkManagement[/b] 45 | [list] 46 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/NetworkManagement/NetGetJoinInformation.ahk]NetGetJoinInformation[/url] (Retrieves join status information for the specified computer.) 47 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/NetworkManagement/NetGroupEnum.ahk]NetGroupEnum[/url] (Retrieves information about each global group in the security database, which is the SAM database or the Active Directory.) 48 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/NetworkManagement/NetGroupGetInfo.ahk]NetGroupGetInfo[/url] (Retrieves information about a particular global group in the security database, which is the SAM database or the Active Directory.) 49 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/NetworkManagement/NetGroupGetUsers.ahk]NetGroupGetUsers[/url] (Retrieves a list of the members in a particular global group in the security database, which is the SAM database or the Active Directory.) 50 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/NetworkManagement/NetLocalGroupEnum.ahk]NetLocalGroupEnum[/url] (Returns information about each local group account on the specified server.) 51 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/NetworkManagement/NetLocalGroupGetInfo.ahk]NetLocalGroupGetInfo[/url] (Retrieves information about a particular local group account on a server.) 52 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/NetworkManagement/NetLocalGroupGetMembers.ahk]NetLocalGNetLocalGroupGetMembersroupGetInfo[/url] (Retrieves a list of the members of a particular local group.) 53 | [/list] 54 | [*][b]Others[/b] 55 | [list] 56 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/Others/CreateGUID.ahk]CreateGUID[/url] (Creates an Globally Unique IDentifier) 57 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/Others/CreateUUID.ahk]CreateUUID[/url] (Creates an Universally Unique IDentifier) 58 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/Others/GetFileOwner.ahk]GetFileOwner[/url] (Finding the Owner of a File or Folder) 59 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/Others/GetFileVersionInfo.ahk]GetFileVersionInfo[/url] (Retrieves specified version information from the specified version-information resource.) 60 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/Others/IsRemoteSession.ahk]IsRemoteSession[/url] (Returns TRUE that the current session is a remote session, and FALSE that the current session is a local session.) 61 | [/list] 62 | [*][b]Processes / Threads / Modules[/b] 63 | [list] 64 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/ProcessThreadModule/GetModuleBaseAddr.ahk]GetModuleBaseAddr[/url] (Retrieves the base address and size of the module in the context of the owning process.) 65 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/ProcessThreadModule/GetProcessHandles.ahk]GetProcessHandles[/url] (Retrieves all Handles in the context of the owning process.) 66 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/ProcessThreadModule/GetProcessThreads.ahk]GetProcessThreads[/url] (Retrieves a list of all threads in a process.) 67 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/ProcessThreadModule/GetThreadStartAddr.ahk]GetThreadStartAddr[/url] (Retrieves the start address of a thread.) 68 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/ProcessThreadModule/IsProcessElevated.ahk]IsProcessElevated[/url] (Retrieves whether a token has elevated privileges.) 69 | [/list] 70 | [*][b]Strings[/b] 71 | [list] 72 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/Strings/Base64ToString.ahk]Base64ToString[/url] (Converts a base64 string to a readable string.) 73 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/Strings/CountLeadingChar.ahk]CountLeadingChar[/url] (Count how often a certain character occurs at the beginning of a string.) 74 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/Strings/GetCurrencyFormat.ahk]GetCurrencyFormat[/url] (Formats a number string as a currency string for a locale specified by identifier.) 75 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/Strings/GetCurrencyFormatEx.ahk]GetCurrencyFormatEx[/url] (Formats a number string as a currency string for a locale specified by name.) 76 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/Strings/GetDurationFormat.ahk]GetDurationFormat[/url] (Formats a duration of time as a time string for a locale specified by identifier.) 77 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/Strings/GetDurationFormatEx.ahk]GetDurationFormatEx[/url] (Formats a duration of time as a time string for a locale specified by name.) 78 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/Strings/GetNumberFormat.ahk]GetNumberFormat[/url] (Formats a number string as a number string customized for a locale specified by identifier.) 79 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/Strings/GetNumberFormatEx.ahk]GetNumberFormatEx[/url] (Formats a number string as a number string customized for a locale specified by name.) 80 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/Strings/StringToBase64.ahk]StringToBase64[/url] (Converts a readable string to a base64 string.) 81 | [/list] 82 | [*][b]SystemInformation (NtQuerySystemInformation)[/b] 83 | [list] 84 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/SystemInformation/SystemDeviceInformation.ahk]SystemDeviceInformation[/url] (SYSTEM_DEVICE_INFORMATION) 85 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/SystemInformation/SystemHandleInformation.ahk]SystemHandleInformation[/url] (SYSTEM_HANDLE_INFORMATION) 86 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/SystemInformation/SystemPerformanceInformation.ahk]SystemPerformanceInformation[/url] (SYSTEM_PERFORMANCE_INFORMATION) 87 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/SystemInformation/SystemProcessInformation.ahk]SystemProcessInformation[/url] (SYSTEM_PROCESS_INFORMATION) 88 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/SystemInformation/SystemProcessorInformation.ahk]SystemProcessorInformation[/url] (SYSTEM_PROCESSOR_INFORMATION) 89 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/SystemInformation/SystemProcessorPerformanceInformation.ahk]SystemProcessorPerformanceInformation[/url] (SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION) 90 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/SystemInformation/SystemProcessorPowerInformation.ahk]SystemProcessorPowerInformation[/url] (SYSTEM_PROCESSOR_POWER_INFORMATION) 91 | [*][url=https://github.com/jNizM/ahk-scripts-v2/blob/main/src/SystemInformation/SystemSecureBootInformation.ahk]SystemSecureBootInformation[/url] (SYSTEM_SECUREBOOT_INFORMATION) 92 | [/list] 93 | [/list] 94 | 95 | 96 | [b][size=150]Questions / Bugs / Issues[/size][/b] 97 | [hr][/hr]If you notice any kind of bugs or issues, report them here. Same for any kind of questions. 98 | 99 | 100 | [b][size=150]Copyright and License[/size][/b] 101 | [hr][/hr][url=https://opensource.org/licenses/MIT]MIT License[/url] -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 jNizM 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # A collection of useful AutoHotkey v2 scripts and functions 2 | ( [AHK forum](https://www.autohotkey.com/boards/viewtopic.php?f=83&t=89720) - Tested with AutoHotkey v2.0.2 64-bit ) 3 | 4 | 5 | ## Functions & Script Examples 6 | 7 | - ### ComObject 8 | - [EnumInstalledApps](src/ComObject/EnumInstalledApps.ahk) (Gets general information about an application.) 9 | 10 | 11 | - ### FileObject 12 | - [FileCountLines](src/FileObject/FileCountLines.ahk) (Count the number of lines in a text file.) 13 | - [FileFindString](src/FileObject/FileFindString.ahk) (Finds a specific word / string in a text file.) 14 | - [FileReadLastLines](src/FileObject/FileReadLastLines.ahk) (Read last x lines of a text file.) 15 | - [GetFilePEHeader](src/FileObject/GetFilePEHeader.ahk) (Get the PE File Header information - Machine Type.) 16 | 17 | 18 | - ### Gui 19 | - [CreateGradient](src/Gui/CreateGradient.ahk) (Creates a gradient bitmap for picture controls.) 20 | - [DisableCloseButton](src/Gui/DisableCloseButton.ahk) (Disables the GUI Close Button.) 21 | - [DisableMove](src/Gui/DisableMove.ahk) (Disables the GUI Move function.) 22 | - [TaskBarProgress](src/Gui/TaskBarProgress.ahk) (Displays or updates a progress bar hosted in a taskbar button.) 23 | 24 | 25 | - ### Message 26 | - [WM_DEVICECHANGE](src/Message/WM_DEVICECHANGE.ahk) (Detecting Media Insertion or Removal.) 27 | 28 | 29 | - ### Network 30 | - [DnsServerList](src/Network/DnsServerList.ahk) (Gets a list of DNS servers for the local computer.) 31 | - [DNSQuery](src/Network/DNSQuery.ahk) (Retrieves the Resource Record (RR) depends on DNS Record Type.) 32 | - [GetAdaptersInfo](src/Network/GetAdaptersInfo.ahk) (Gets network adapter information for the local computer.) 33 | - [GetDnsServerList](src/Network/GetDnsServerList.ahk) (Gets a list of DNS servers for the local computer.) 34 | - [GetNetworkConnectivityHint](src/Network/GetNetworkConnectivityHint.ahk) (Retrieves the level and cost of network connectivity.) 35 | - [ResolveHostname](src/Network/ResolveHostname.ahk) (Gets the IP Address from a Hostname.) 36 | - [ReverseLookup](src/Network/ReverseLookup.ahk) (Gets the Hostname by the IP Adresse.) 37 | 38 | 39 | - ### NetworkManagement 40 | - [NetGetJoinInformation](src/NetworkManagement/NetGetJoinInformation.ahk) (Retrieves join status information for the specified computer.) 41 | - [NetGroupEnum](src/NetworkManagement/NetGroupEnum.ahk) (Retrieves information about each global group.) 42 | - [NetGroupGetInfo](src/NetworkManagement/NetGroupGetInfo.ahk) (Retrieves information about a particular global group.) 43 | - [NetGroupGetUsers](src/NetworkManagement/NetGroupGetUsers.ahk) (Retrieves a list of the members in a particular global group.) 44 | - [NetLocalGroupEnum](src/NetworkManagement/NetLocalGroupEnum.ahk) (Returns information about each local group account on the specified server.) 45 | - [NetLocalGroupGetInfo](src/NetworkManagement/NetLocalGroupGetInfo.ahk) (Retrieves information about a particular local group account on a server.) 46 | - [NetLocalGroupGetMembers](src/NetworkManagement/NetLocalGroupGetMembers.ahk) (Retrieves a list of the members of a particular local group.) 47 | 48 | 49 | - ### Others 50 | - [CreateGUID](src/Others/CreateGUID.ahk) (Creates an Globally Unique IDentifier) 51 | - [CreateUUID](src/Others/CreateUUID.ahk) (Creates an Universally Unique IDentifier) 52 | - [GetFileOwner](src/Others/GetFileOwner.ahk) (Finding the Owner of a File or Folder) 53 | - [GetFileVersionInfo](src/Others/GetFileVersionInfo.ahk) (Retrieves specified version information from the specified version-information resource.) 54 | - [IsRemoteSession](src/Others/IsRemoteSession.ahk) (Returns TRUE that the current session is a remote session, and FALSE that the current session is a local session.) 55 | 56 | 57 | - ### Processes / Threads / Modules 58 | - [GetModuleBaseAddr](src/ProcessThreadModule/GetModuleBaseAddr.ahk) (Retrieves the base address and size of the module in the context of the owning process.) 59 | - [GetProcessHandles](src/ProcessThreadModule/GetProcessHandles.ahk) (Retrieves all Handles in the context of the owning process.) 60 | - [GetProcessThreads](src/ProcessThreadModule/GetProcessThreads.ahk) (Retrieves a list of all threads in a process.) 61 | - [GetThreadStartAddr](src/ProcessThreadModule/GetThreadStartAddr.ahk) (Retrieves the start address of a thread.) 62 | - [IsProcessElevated](src/ProcessThreadModule/IsProcessElevated.ahk) (Retrieves whether a token has elevated privileges.) 63 | 64 | 65 | - ### Strings 66 | - [Base64ToString](src/Strings/Base64ToString.ahk) (Converts a base64 string to a readable string.) 67 | - [CountLeadingChar](src/Strings/CountLeadingChar.ahk) (Count how often a certain character occurs at the beginning of a string.) 68 | - [GetCurrencyFormat](src/Strings/GetCurrencyFormat.ahk) (Formats a number string as a currency string for a locale specified by identifier.) 69 | - [GetCurrencyFormatEx](src/Strings/GetCurrencyFormatEx.ahk) (Formats a number string as a currency string for a locale specified by name.) 70 | - [GetDurationFormat](src/Strings/GetDurationFormat.ahk) (Formats a duration of time as a time string for a locale specified by identifier.) 71 | - [GetDurationFormatEx](src/Strings/GetDurationFormatEx.ahk) (Formats a duration of time as a time string for a locale specified by name.) 72 | - [GetNumberFormat](src/Strings/GetNumberFormat.ahk) (Formats a number string as a number string customized for a locale specified by identifier.) 73 | - [GetNumberFormatEx](src/Strings/GetNumberFormatEx.ahk) (Formats a number string as a number string customized for a locale specified by name.) 74 | - [StringToBase64](src/Strings/StringToBase64.ahk) (Converts a readable string to a base64 string.) 75 | 76 | 77 | - ### SystemInformation (NtQuerySystemInformation) 78 | - [SystemDeviceInformation](src/SystemInformation/SystemDeviceInformation.ahk) (SYSTEM_DEVICE_INFORMATION) 79 | - [SystemHandleInformation](src/SystemInformation/SystemHandleInformation.ahk) (SYSTEM_HANDLE_INFORMATION) 80 | - [SystemPerformanceInformation](src/SystemInformation/SystemPerformanceInformation.ahk) (SYSTEM_PERFORMANCE_INFORMATION) 81 | - [SystemProcessInformation](src/SystemInformation/SystemProcessInformation.ahk) (SYSTEM_PROCESS_INFORMATION) 82 | - [SystemProcessorInformation](src/SystemInformation/SystemProcessorInformation.ahk) (SYSTEM_PROCESSOR_INFORMATION) 83 | - [SystemProcessorPerformanceInformation](src/SystemInformation/SystemProcessorPerformanceInformation.ahk) (SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION) 84 | - [SystemProcessorPowerInformation](src/SystemInformation/SystemProcessorPowerInformation.ahk) (SYSTEM_PROCESSOR_POWER_INFORMATION) 85 | - [SystemSecureBootInformation](src/SystemInformation/SystemSecureBootInformation.ahk) (SYSTEM_SECUREBOOT_INFORMATION) 86 | 87 | 88 | ## Copyright and License 89 | [MIT License](LICENSE) 90 | 91 | 92 | ## Donations (PayPal) 93 | [Donations are appreciated if I could help you](https://www.paypal.me/smithz) -------------------------------------------------------------------------------- /src/ComObject/EnumInstalledApps.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author ........: jNizM, just me 3 | ; Released ......: 2021-04-23 4 | ; Modified ......: 2023-01-12 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: EnumInstalledApps() 8 | ; 9 | ; Parameter(s)...: No parameters used 10 | ; 11 | ; Return ........: Gets general information about an application (from the Add/Remove Programs Application). 12 | ; ============================================================================================================================================================= 13 | 14 | #Requires AutoHotkey v2.0 15 | 16 | 17 | EnumInstalledApps() 18 | { 19 | static CLSID_EnumInstalledApps := "{0B124F8F-91F0-11D1-B8B5-006008059382}" 20 | static IID_IEnumInstalledApps := "{1BC752E1-9046-11D1-B8B3-006008059382}" 21 | static InfoData := [ "DisplayName", "Version", "Publisher", "ProductID", "RegisteredOwner", "RegisteredCompany", "Language" 22 | , "SupportUrl", "SupportTelephone", "HelpLink", "InstallLocation", "InstallSource", "InstallDate" 23 | , "Contact", "Comments", "Image", "ReadmeUrl", "UpdateInfoUrl" ] 24 | 25 | InstalledApps := Map() 26 | EnumInstalledApps := ComObject(CLSID_EnumInstalledApps, IID_IEnumInstalledApps) 27 | while !(ComCall(3, EnumInstalledApps, "Ptr*", &IShellApp := 0, "UInt")) 28 | { 29 | AppInfoData := Buffer(8 + (A_PtrSize * 18), 0) 30 | NumPut("UInt", AppInfoData.Size, AppInfoData, 0) 31 | NumPut("UInt", 0x0EDFFF, AppInfoData, 4) 32 | if !(ComCall(3, IShellApp, "Ptr", AppInfoData)) 33 | { 34 | InstalledApp := Map() 35 | Offset := 8 - A_PtrSize 36 | for each, Info in InfoData 37 | InstalledApp[Info] := (Addr := NumGet(AppInfoData, Offset += A_PtrSize, "UPtr")) ? StrGet(Addr, "UTF-16") : "" 38 | InstalledApps[A_Index] := InstalledApp 39 | } 40 | ObjRelease(IShellApp) 41 | } 42 | return InstalledApps 43 | } 44 | 45 | 46 | ; ============================================================================================================================================================= 47 | ; Example 48 | ; ============================================================================================================================================================= 49 | 50 | Apps := EnumInstalledApps() 51 | for i, v in Apps { 52 | output := "" 53 | for k, v in Apps[i] 54 | output .= k ": " v "`n" 55 | MsgBox output 56 | } 57 | -------------------------------------------------------------------------------- /src/FileObject/FileCountLines.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author ........: jNizM 3 | ; Released ......: 2021-04-23 4 | ; Modified ......: 2023-01-12 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: FileCountLines( FileName ) 8 | ; 9 | ; Parameter(s)...: FileName - path to the file 10 | ; 11 | ; Return ........: Count the number of lines in a file. 12 | ; ============================================================================================================================================================= 13 | 14 | #Requires AutoHotkey v2.0 15 | 16 | 17 | FileCountLines(FileName) 18 | { 19 | try 20 | File := FileOpen(FileName, "r-d") 21 | catch as Err 22 | { 23 | MsgBox "Can't open '" FileName "`n`n" Type(Err) ": " Err.Message 24 | return 25 | } 26 | 27 | CountLines := 0 28 | while !(File.AtEOF) 29 | { 30 | File.ReadLine() 31 | CountLines++ 32 | } 33 | File.Close() 34 | 35 | return CountLines 36 | } 37 | 38 | 39 | ; ============================================================================================================================================================= 40 | ; Example 41 | ; ============================================================================================================================================================= 42 | 43 | MsgBox FileCountLines("C:\Windows\Logs\CBS\CBS.log") -------------------------------------------------------------------------------- /src/FileObject/FileFindString.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author ........: jNizM 3 | ; Released ......: 2021-04-23 4 | ; Modified ......: 2023-01-12 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: FileFindString( FileName, Search ) 8 | ; 9 | ; Parameter(s)...: FileName - path to the file 10 | ; Search - the word or string to search for 11 | ; 12 | ; Return ........: Finds a specific word / string in a text file. 13 | ; ============================================================================================================================================================= 14 | 15 | #Requires AutoHotkey v2.0 16 | 17 | 18 | FileFindString(FileName, Search) 19 | { 20 | try 21 | File := FileOpen(FileName, "r-d") 22 | catch as Err 23 | { 24 | MsgBox "Can't open '" FileName "`n`n" Type(Err) ": " Err.Message 25 | return 26 | } 27 | 28 | Found := Map() 29 | while !(File.AtEOF) 30 | { 31 | if (InStr(GetLine := File.ReadLine(), Search)) 32 | { 33 | Found[A_Index] := GetLine 34 | } 35 | } 36 | File.Close() 37 | 38 | return Found 39 | } 40 | 41 | 42 | ; ============================================================================================================================================================= 43 | ; Example 44 | ; ============================================================================================================================================================= 45 | 46 | for Index, Value in FileFindString("C:\Windows\Logs\CBS\CBS.log", "CBS_E_INVALID_PACKAGE") 47 | MsgBox "Line: " Index "`n`n" Value -------------------------------------------------------------------------------- /src/FileObject/FileReadLastLines.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author ........: jNizM 3 | ; Released ......: 2021-04-23 4 | ; Modified ......: 2023-01-12 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: FileReadLastLines( FileName, [ LastLines ] ) 8 | ; 9 | ; Parameter(s)...: FileName - path to the file 10 | ; LastLines - the number of last lines to be displayed 11 | ; 12 | ; Return ........: Read last x lines of a text file. 13 | ; ============================================================================================================================================================= 14 | 15 | #Requires AutoHotkey v2.0 16 | 17 | 18 | FileReadLastLines(FileName, LastLines := 5) 19 | { 20 | try 21 | File := FileOpen(FileName, "r-d") 22 | catch as Err 23 | { 24 | MsgBox "Can't open '" FileName "`n`n" Type(Err) ": " Err.Message 25 | return 26 | } 27 | 28 | CountLines := 0, LinesCount := 0, GetLine := "", GetLines := Map() 29 | while !(File.AtEOF) 30 | { 31 | File.ReadLine() 32 | CountLines++ 33 | } 34 | File.Seek(0) 35 | while !(File.AtEOF) 36 | { 37 | GetLine := File.ReadLine() 38 | if (LinesCount >= CountLines - LastLines) 39 | { 40 | GetLines[A_Index] := GetLine 41 | } 42 | LinesCount++ 43 | } 44 | File.Close() 45 | 46 | return GetLines 47 | } 48 | 49 | 50 | ; ============================================================================================================================================================= 51 | ; Example 52 | ; ============================================================================================================================================================= 53 | 54 | for Index, Value in FileReadLastLines("C:\Windows\Logs\CBS\CBS.log", 10) 55 | MsgBox "Line: " Index "`n`n" Value -------------------------------------------------------------------------------- /src/FileObject/GetFilePEHeader.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author ........: jNizM 3 | ; Released ......: 2021-05-11 4 | ; Modified ......: 2023-01-12 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: GetFilePEHeader( FileName ) 8 | ; 9 | ; Parameter(s)...: FileName - path to the file 10 | ; 11 | ; Return ........: Get the PE File Header information (Machine Type). 12 | ; ============================================================================================================================================================= 13 | 14 | #Requires AutoHotkey v2.0 15 | 16 | 17 | GetFilePEHeader(FileName) 18 | { 19 | static IMAGE_DOS_SIGNATURE := 0x5A4D 20 | static IMAGE_NT_SIGNATURE := 0x4550 21 | static MachineType := Map(0x0000, "UNKNOWN", 0x014c, "I386", 0x0200, "IA64", 0x8664, "AMD64") 22 | 23 | SplitPath FileName,,, &ext 24 | if !(ext ~= "exe|dll|sys|drv|scr|cpl|ocx|ax|efi") 25 | { 26 | MsgBox "This File is not a Portable Executable (PE) file." 27 | return 28 | } 29 | 30 | try 31 | File := FileOpen(FileName, "r-d") 32 | catch as Err 33 | { 34 | MsgBox "Can't open '" FileName "`n`n" Type(Err) ": " Err.Message 35 | return 36 | } 37 | 38 | if (File.ReadUShort() = IMAGE_DOS_SIGNATURE) 39 | { 40 | File.Seek(60) 41 | File.Seek(e_lfanew := File.ReadInt()) 42 | if (File.ReadUInt() = IMAGE_NT_SIGNATURE) 43 | { 44 | File.Seek(e_lfanew + 4) 45 | PEHeader := MachineType[File.ReadUShort()] 46 | } 47 | } 48 | File.Close() 49 | 50 | return PEHeader 51 | } 52 | 53 | 54 | ; ============================================================================================================================================================= 55 | ; Example 56 | ; ============================================================================================================================================================= 57 | 58 | MsgBox GetFilePEHeader("C:\Windows\System32\kernel32.dll") 59 | MsgBox GetFilePEHeader("C:\Program Files\AutoHotkey\AutoHotkey.exe") -------------------------------------------------------------------------------- /src/Gui/CreateGradient.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author(s) .....: jNizM, just me, SKAN 3 | ; Released ......: 2006-05-23 4 | ; Modified ......: 2023-01-16 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: CreateGradient() 8 | ; 9 | ; Parameter(s)...: Handle - Picture.Hwnd 10 | ; Colors - Array of Colors 11 | ; 12 | ; Return ........: Creates a gradient bitmap for picture controls. 13 | ; ============================================================================================================================================================= 14 | 15 | #Requires AutoHotkey v2.0 16 | 17 | 18 | Main := Gui() 19 | Main.MarginX := 0 20 | Main.MarginY := 0 21 | PIC1 := Main.AddPicture("xm ym w400 h400 0x4E") 22 | CreateGradient(PIC1.Hwnd, ["0x3399FF", "0xFF3399"]*) 23 | Main.OnEvent("Close", ExitFunc) 24 | Main.Show("AutoSize") 25 | 26 | 27 | ExitFunc(*) 28 | { 29 | if (hBITMAP) 30 | DllCall("gdi32\DeleteObject", "ptr", hBITMAP) 31 | ExitApp 32 | } 33 | 34 | 35 | CreateGradient(Handle, Colors*) 36 | { 37 | static IMAGE_BITMAP := 0 38 | static LR_COPYDELETEORG := 0x00000008 39 | static LR_CREATEDIBSECTION := 0x00002000 40 | static STM_SETIMAGE := 0x0172 41 | global hBITMAP 42 | 43 | ControlGetPos(,, &OutW, &OutW, Handle) 44 | Addr := Bits := Buffer(Colors.Length * 2 * 4) 45 | for each, Color in Colors 46 | Addr := NumPut("UInt", Color, "UInt", Color, Addr) 47 | 48 | hBITMAP := DllCall("gdi32\CreateBitmap", "Int", 2, "Int", Colors.Length, "UInt", 1, "UInt", 32, "Ptr", 0, "Ptr") 49 | hBITMAP := DllCall("user32\CopyImage", "Ptr", hBITMAP, "UInt", IMAGE_BITMAP, "Int", 0, "Int", 0, "UInt", LR_COPYDELETEORG | LR_CREATEDIBSECTION, "Ptr") 50 | DllCall("gdi32\SetBitmapBits", "Ptr", hBITMAP, "UInt", Bits.Size, "Ptr", Bits) 51 | hBITMAP := DllCall("user32\CopyImage", "Ptr", hBITMAP, "UInt", 0, "Int", OutW, "Int", OutW, "UInt", LR_COPYDELETEORG | LR_CREATEDIBSECTION, "Ptr") 52 | SendMessage(STM_SETIMAGE, IMAGE_BITMAP, hBitMAP, Handle) 53 | return true 54 | } 55 | 56 | 57 | ; ============================================================================================================================================================= -------------------------------------------------------------------------------- /src/Gui/DisableCloseButton.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author ........: jNizM 3 | ; Released ......: 2017-04-13 4 | ; Modified ......: 2023-01-16 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: GuiDisableCloseButton() 8 | ; 9 | ; Parameter(s)...: Handle - Gui.Hwnd 10 | ; 11 | ; Return ........: Disables the GUI Close Button. 12 | ; ============================================================================================================================================================= 13 | 14 | #Requires AutoHotkey v2.0 15 | 16 | 17 | Main := Gui() 18 | Main.OnEvent("Close", (*) => ExitApp) 19 | Main.Show("w400 h300") 20 | GuiDisableCloseButton(Main.Hwnd) 21 | 22 | 23 | GuiDisableCloseButton(Handle) 24 | { 25 | static SC_CLOSE := 0xF060 26 | static MF_GRAYED := 0x00000001 27 | static MF_DISABLED := 0x00000002 28 | 29 | hMenu := DllCall("user32\GetSystemMenu", "Ptr", Handle, "Int", False, "Ptr") 30 | DllCall("user32\EnableMenuItem", "Ptr", hMenu, "UInt", SC_CLOSE, "UInt", MF_GRAYED | MF_DISABLED) 31 | return DllCall("user32\DrawMenuBar", "Ptr", Handle) 32 | } 33 | 34 | 35 | ; ============================================================================================================================================================= -------------------------------------------------------------------------------- /src/Gui/DisableMove.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author ........: jNizM 3 | ; Released ......: 2017-04-13 4 | ; Modified ......: 2023-01-16 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: GuiDisableMove() 8 | ; 9 | ; Parameter(s)...: Handle - Gui.Hwnd 10 | ; 11 | ; Return ........: Disables the GUI Move function. 12 | ; ============================================================================================================================================================= 13 | 14 | #Requires AutoHotkey v2.0 15 | 16 | 17 | Main := Gui() 18 | Main.OnEvent("Close", (*) => ExitApp) 19 | Main.Show("w400 h300") 20 | GuiDisableMove(Main.Hwnd) 21 | 22 | 23 | GuiDisableMove(Handle) 24 | { 25 | static SC_MOVE := 0xF010 26 | static MF_BYCOMMAND := 0x00000000 27 | 28 | hMenu := DllCall("user32\GetSystemMenu", "Ptr", Handle, "Int", False, "Ptr") 29 | DllCall("user32\RemoveMenu", "Ptr", hMenu, "UInt", SC_MOVE, "UInt", MF_BYCOMMAND) 30 | return DllCall("user32\DrawMenuBar", "Ptr", Handle) 31 | } 32 | 33 | 34 | ; ============================================================================================================================================================= -------------------------------------------------------------------------------- /src/Gui/TaskBarProgress.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author ........: jNizM, lexikos 3 | ; Released ......: 2009-11-06 4 | ; Modified ......: 2023-01-16 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: SetTaskbarProgress() 8 | ; 9 | ; Parameter(s)...: Handle - Gui.Hwnd 10 | ; Value - in 0-100 % 11 | ; State - see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist3-setprogressstate 12 | ; 13 | ; Return ........: Displays or updates a progress bar hosted in a taskbar button to show the specific percentage completed of the full operation. 14 | ; ============================================================================================================================================================= 15 | 16 | #Requires AutoHotkey v2.0 17 | 18 | 19 | Main := Gui() 20 | Main.MarginX := 15 21 | Main.MarginY := 15 22 | Main.SetFont("s9", "Segoe UI") 23 | 24 | BT1 := Main.AddButton("xm ym w200", "Start") 25 | BT1.OnEvent("Click", Start) 26 | 27 | PG1 := Main.AddProgress("xm y+10 w200") 28 | 29 | Main.OnEvent("Close", (*) => ExitApp) 30 | Main.Show("AutoSize") 31 | 32 | 33 | Start(GuiCtrl, *) 34 | { 35 | static TBPF := Map("NOPROGRESS", 0, "INDETERMINATE", 1, "NORMAL", 2, "ERROR", 4, "PAUSED", 8) 36 | loop 100 37 | { 38 | PG1.Value := A_Index 39 | SetTaskbarProgress(Main.Hwnd, A_Index) 40 | Sleep 50 41 | } 42 | } 43 | 44 | 45 | SetTaskbarProgress(Handle, Value, State := 2) 46 | { 47 | static CLSID_TaskbarList := "{56FDF344-FD6D-11D0-958A-006097C9A090}" 48 | static IID_ITaskbarList3 := "{EA1AFB91-9E28-4B86-90E9-9E9F8A5EEFAF}" 49 | static SetProgressValue := 9 50 | static SetProgressState := 10 51 | static ITaskbarList3 := false 52 | 53 | if !(ITaskbarList3) 54 | try ITaskbarList3 := ComObject(CLSID_TaskbarList, IID_ITaskbarList3) 55 | 56 | ComCall(SetProgressState, ITaskbarList3, "Ptr", Handle, "Int", State) 57 | ComCall(SetProgressValue, ITaskbarList3, "Ptr", Handle, "Int64", Value, "Int64", 100) 58 | return (ITaskbarList3 ? 0 : 1) 59 | } 60 | 61 | 62 | ; ============================================================================================================================================================= -------------------------------------------------------------------------------- /src/Message/WM_DEVICECHANGE.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author ........: jNizM 3 | ; Released ......: 2017-03-03 4 | ; Modified ......: 2023-01-13 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: WM_DEVICECHANGE 8 | ; 9 | ; Parameter(s)...: 10 | ; 11 | ; Return ........: Notifies an application of a change to the hardware configuration of a device or the computer. 12 | ; ============================================================================================================================================================= 13 | 14 | #Requires AutoHotkey v2.0 15 | 16 | OnMessage 0x0219, WM_DEVICECHANGE 17 | Persistent 18 | 19 | 20 | WM_DEVICECHANGE(wParam, lParam, *) 21 | { 22 | static DBT_DEVICEARRIVAL := 0x8000 23 | static DBT_DEVICEREMOVECOMPLETE := 0x8004 24 | static DBT_DEVTYP_VOLUME := 0x00000002 25 | 26 | if (wParam = DBT_DEVICEARRIVAL) || (wParam = DBT_DEVICEREMOVECOMPLETE) 27 | { 28 | if (NumGet(lParam, 4, "UInt") = DBT_DEVTYP_VOLUME) 29 | { 30 | Device := FirstDriveFromMask(NumGet(lParam, 12, "UInt")) 31 | DeviceChangeInfo(Device, wParam) 32 | } 33 | } 34 | } 35 | 36 | 37 | FirstDriveFromMask(unitmask) 38 | { 39 | i := 0 40 | while (unitmask > 1) && (++i < 0x1A) 41 | unitmask >>= 1 42 | return 0x41 + i 43 | } 44 | 45 | 46 | DeviceChangeInfo(Device, ChangeInfo) 47 | { 48 | TrayTip Chr(Device) ":\ " ((ChangeInfo = 0x8000) ? "plugged in" : "is removed"), "DeviceChange" 49 | SetTimer () => TrayTip(), -3000 50 | } 51 | 52 | ; ============================================================================================================================================================= -------------------------------------------------------------------------------- /src/Network/DNSQuery.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author(s) .....: jNizM, just me 3 | ; Released ......: 2013-11-02 4 | ; Modified ......: 2023-01-18 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: DNSQuery() 8 | ; 9 | ; Parameter(s)...: [in] Name - String that represents the DNS name to query 10 | ; [in] Type - DNS Record Type (https://learn.microsoft.com/en-us/windows/win32/dns/dns-constants#dns-record-types) 11 | ; [in, opt] Option - DNS Query Options (https://learn.microsoft.com/en-us/windows/win32/dns/dns-constants#dns-query-options) 12 | ; 13 | ; Return ........: Retrieves the Resource Record (RR) depends on DNS Record Type. 14 | ; ============================================================================================================================================================= 15 | 16 | #Requires AutoHotkey v2.0 17 | 18 | #DllLoad "dnsapi.dll" 19 | #DllLoad "ntdll.dll" 20 | 21 | 22 | DNSQuery(Name, Type, Options := 0) 23 | { 24 | static STATUS_SUCCESS := 0 25 | static DnsFreeRecordList := 1 26 | static RECORD_DATA := (A_PtrSize * 2) + 16 27 | static DNS_TYPE := Map("A", 0x0001, "NS", 0x0002, "CNAME", 0x0005, "SOA", 0x0006, "PTR", 0x000c, "MX", 0x000f, "TEXT", 0x0010, "AAAA", 0x001c) 28 | 29 | if !(DNS_TYPE.Has(Type)) 30 | throw Error() 31 | 32 | DNS_STATUS := DllCall("dnsapi\DnsQuery_W", "Str", Name, "Short", DNS_TYPE[Type], "UInt", Options, "Ptr", 0, "Ptr*", &DNS_RECORD := 0, "Ptr", 0) 33 | 34 | if (DNS_STATUS = STATUS_SUCCESS) 35 | { 36 | Addr := DNS_RECORD 37 | DNS_RECORD_LIST := Map() 38 | while (Addr) 39 | { 40 | LIST := Map() 41 | RECORD_TYPE := NumGet(Addr, A_PtrSize * 2, "UShort") 42 | switch RECORD_TYPE 43 | { 44 | case DNS_TYPE["A"]: 45 | { 46 | LIST["IpAddress"] := RtlIpv4AddressToStringW(NumGet(Addr, RECORD_DATA, "UInt")) 47 | } 48 | case DNS_TYPE["NS"], DNS_TYPE["CNAME"], DNS_TYPE["PTR"]: 49 | { 50 | LIST["NameHost"] := StrGet(NumGet(Addr, RECORD_DATA, "Ptr")) 51 | } 52 | case DNS_TYPE["SOA"]: 53 | { 54 | LIST["NamePrimaryServer"] := StrGet(NumGet(Addr, RECORD_DATA, "Ptr")) 55 | LIST["NameAdministrator"] := StrGet(NumGet(Addr + 8, RECORD_DATA, "Ptr")) 56 | LIST["SerialNo"] := NumGet(Addr + 16, RECORD_DATA, "UInt") 57 | LIST["Refresh"] := NumGet(Addr + 20, RECORD_DATA, "UInt") 58 | LIST["Retry"] := NumGet(Addr + 24, RECORD_DATA, "UInt") 59 | LIST["Expire"] := NumGet(Addr + 28, RECORD_DATA, "UInt") 60 | LIST["DefaultTtl"] := NumGet(Addr + 32, RECORD_DATA, "UInt") 61 | } 62 | case DNS_TYPE["MX"]: 63 | { 64 | LIST["NameExchange"] := StrGet(NumGet(Addr, RECORD_DATA, "Ptr")) 65 | LIST["Preference"] := NumGet(Addr + 8, RECORD_DATA, "UChar") 66 | } 67 | case DNS_TYPE["TEXT"]: 68 | { 69 | LIST["StringArray"] := StrGet(NumGet(Addr + 8, RECORD_DATA, "Ptr")) 70 | } 71 | case DNS_TYPE["AAAA"]: 72 | { 73 | LIST["Ip6Address"] := RtlIpv6AddressToStringW(NumGet(Addr, RECORD_DATA, "UInt")) 74 | } 75 | } 76 | DNS_RECORD_LIST[A_Index] := LIST 77 | try Addr := NumGet(Addr, "Ptr") 78 | } 79 | DllCall("dnsapi\DnsRecordListFree", "Ptr", DNS_RECORD, "Int", DnsFreeRecordList) 80 | return DNS_RECORD_LIST 81 | } 82 | 83 | throw OSError() 84 | } 85 | 86 | 87 | RtlIpv4AddressToStringW(IN_ADDR) 88 | { 89 | Size := VarSetStrCapacity(&StringAddr, 32) 90 | if (DllCall("ntdll\RtlIpv4AddressToStringW", "Ptr*", IN_ADDR, "Str", StringAddr)) 91 | return StringAddr 92 | return False 93 | } 94 | 95 | RtlIpv6AddressToStringW(IN6_ADDR) 96 | { 97 | Size := VarSetStrCapacity(&StringAddr, 92) 98 | if (DllCall("ntdll\RtlIpv6AddressToStringW", "Ptr*", IN6_ADDR, "Str", StringAddr)) 99 | return StringAddr 100 | return False 101 | } 102 | 103 | 104 | ; ============================================================================================================================================================= 105 | ; Example(s) 106 | ; ============================================================================================================================================================= 107 | 108 | for i, v in DNS := DNSQuery("www.google.com", "A") 109 | for k, v in DNS[i] 110 | MsgBox k ": " v 111 | 112 | for i, v in DNS := DNSQuery("www.google.com", "AAAA") 113 | for k, v in DNS[i] 114 | MsgBox k ": " v 115 | 116 | for i, v in DNS := DNSQuery("learn.microsoft.com", "CNAME") 117 | for k, v in DNS[i] 118 | MsgBox k ": " v 119 | 120 | for i, v in DNS := DNSQuery("8.8.8.8.IN-ADDR.ARPA", "PTR") 121 | for k, v in DNS[i] 122 | MsgBox k ": " v 123 | 124 | for i, v in DNS := DNSQuery("google.com", "MX") 125 | for k, v in DNS[i] 126 | MsgBox k ": " v 127 | 128 | for i, v in DNS := DNSQuery("google.com", "TEXT") 129 | for k, v in DNS[i] 130 | MsgBox k ": " v 131 | 132 | for i, v in DNS := DNSQuery("google.com", "MX") 133 | for k, v in DNS[i] 134 | MsgBox k ": " v 135 | 136 | for i, v in DNS := DNSQuery("google.com", "SOA") 137 | for k, v in DNS[i] 138 | MsgBox k ": " v 139 | -------------------------------------------------------------------------------- /src/Network/DnsServerList.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author ........: jNizM 3 | ; Released ......: 2023-01-17 4 | ; Modified ......: 2023-01-17 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: DnsServerList() 8 | ; 9 | ; Parameter(s)...: No parameters used 10 | ; 11 | ; Return ........: Gets a list of DNS servers for the local computer. 12 | ; ============================================================================================================================================================= 13 | 14 | #Requires AutoHotkey v2.0 15 | 16 | 17 | DnsServerList() 18 | { 19 | static STATUS_SUCCESS := 0 20 | static DnsConfigDnsServerList := 6 21 | 22 | DllCall("dnsapi\DnsQueryConfig", "Int", DnsConfigDnsServerList, "UInt", 0, "Ptr", 0, "Ptr", 0, "Ptr", 0, "UInt*", &Size := 0) 23 | Buf := Buffer(Size) 24 | DNS_STATUS := DllCall("dnsapi\DnsQueryConfig", "Int", DnsConfigDnsServerList, "UInt", 0, "Ptr", 0, "Ptr", 0, "Ptr", Buf, "UInt*", Buf.Size) 25 | 26 | if (DNS_STATUS = STATUS_SUCCESS) 27 | { 28 | DNS_SERVER := Array() 29 | loop NumGet(Buf, 0, "UInt") 30 | { 31 | DNS_SERVER.Push(DllCall("ws2_32\inet_ntoa", "UInt", NumGet(Buf, 4 * A_Index, "UInt"), "AStr")) 32 | } 33 | return DNS_SERVER 34 | } 35 | 36 | throw OSError() 37 | } 38 | 39 | 40 | ; ============================================================================================================================================================= 41 | ; Example 42 | ; ============================================================================================================================================================= 43 | 44 | DNS := DnsServerList() 45 | loop DNS.Length 46 | MsgBox DNS[A_Index] -------------------------------------------------------------------------------- /src/Network/GetAdaptersInfo.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author ........: jNizM 3 | ; Released ......: 2021-04-23 4 | ; Modified ......: 2023-01-12 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: GetAdaptersInfo() 8 | ; 9 | ; Parameter(s)...: No parameters used 10 | ; 11 | ; Return ........: Gets network adapter information for the local computer. 12 | ; ============================================================================================================================================================= 13 | 14 | #Requires AutoHotkey v2.0 15 | 16 | 17 | GetAdaptersInfo() 18 | { 19 | static ERROR_SUCCESS := 0 20 | static ERROR_BUFFER_OVERFLOW := 111 21 | static MAX_ADAPTER_NAME_LENGTH := 256 22 | static MAX_ADAPTER_DESCRIPTION_LENGTH := 128 23 | static MAX_ADAPTER_ADDRESS_LENGTH := 8 24 | static IF_TYPE := Map(1, "OTHER", 6, "ETHERNET", 9, "TOKENRING", 23, "PPP", 24, "LOOPBACK", 28, "SLIP", 71, "IEEE80211") 25 | 26 | if (DllCall("iphlpapi\GetAdaptersInfo", "Ptr", 0, "UInt*", &Size := 0, "UInt") = ERROR_BUFFER_OVERFLOW) 27 | { 28 | Buf := Buffer(Size) 29 | if (DllCall("iphlpapi\GetAdaptersInfo", "Ptr", Buf, "UInt*", Size, "UInt") = ERROR_SUCCESS) 30 | { 31 | ADAPTER_INFO := Map() 32 | Addr := Buf.Ptr 33 | while (Addr) 34 | { 35 | Offset := A_PtrSize, Address := "" 36 | 37 | ADAPTER := Map() 38 | ADAPTER["ComboIndex"] := NumGet(Addr + Offset, "UInt"), Offset += 4 39 | ADAPTER["AdapterName"] := StrGet(Addr + Offset, MAX_ADAPTER_NAME_LENGTH + 4, "CP0"), Offset += MAX_ADAPTER_NAME_LENGTH + 4 40 | ADAPTER["Description"] := StrGet(Addr + Offset, MAX_ADAPTER_DESCRIPTION_LENGTH + 4, "CP0"), Offset += MAX_ADAPTER_DESCRIPTION_LENGTH + 4 41 | AddressLength := NumGet(Addr + Offset, "UInt"), Offset += 4 42 | loop AddressLength 43 | Address .= Format("{:02x}", NumGet(Addr + Offset + A_Index - 1, "UChar")) ":" 44 | ADAPTER["Address"] := SubStr(Address, 1, -1), Offset += MAX_ADAPTER_ADDRESS_LENGTH 45 | ADAPTER["Index"] := NumGet(Addr + Offset, "UInt"), Offset += 4 46 | ADAPTER["Type"] := IF_TYPE[NumGet(Addr + Offset, "UInt")], Offset += 4 47 | ADAPTER["DhcpEnabled"] := NumGet(Addr + Offset, "UInt"), Offset += A_PtrSize 48 | CurrentIpAddress := NumGet(Addr + Offset + A_PtrSize, "Ptr"), Offset += A_PtrSize 49 | ADAPTER["IpAddressList"] := StrGet(Addr + Offset + A_PtrSize, "CP0") 50 | ADAPTER["IpMaskList"] := StrGet(Addr + Offset + A_PtrSize + 16, "CP0"), Offset += A_PtrSize + 32 + A_PtrSize 51 | ADAPTER["GatewayList"] := StrGet(Addr + Offset + A_PtrSize, "CP0"), Offset += A_PtrSize + 32 + A_PtrSize 52 | ADAPTER["DhcpServer"] := StrGet(Addr + Offset + A_PtrSize, "CP0"), Offset += A_PtrSize + 32 + A_PtrSize 53 | ADAPTER["HaveWins"] := NumGet(Addr + Offset, "Int"), Offset += A_PtrSize 54 | ADAPTER["PrimaryWinsServer"] := StrGet(Addr + Offset + A_PtrSize, "CP0"), Offset += A_PtrSize + 32 + A_PtrSize 55 | ADAPTER["SecondaryWinsServer"] := StrGet(Addr + Offset + A_PtrSize, "CP0"), Offset += A_PtrSize + 32 + A_PtrSize 56 | ADAPTER["LeaseObtained"] := ConvertUnixTime(NumGet(Addr + Offset, "Int")), Offset += A_PtrSize 57 | ADAPTER["LeaseExpires"] := ConvertUnixTime(NumGet(Addr + Offset, "Int")) 58 | ADAPTER_INFO[A_Index] := ADAPTER 59 | 60 | Addr := NumGet(Addr, "Ptr") 61 | } 62 | return ADAPTER_INFO 63 | } 64 | } 65 | return 66 | } 67 | 68 | 69 | ConvertUnixTime(value) 70 | { 71 | unix := 19700101 72 | unix := DateAdd(unix, value, "seconds") 73 | return FormatTime(unix, "yyyy-MM-dd HH:mm:ss") 74 | } 75 | 76 | 77 | ; ============================================================================================================================================================= 78 | ; Example 79 | ; ============================================================================================================================================================= 80 | 81 | Adapters := GetAdaptersInfo() 82 | for i, v in Adapters { 83 | output := "" 84 | for k, v in Adapters[i] 85 | output .= k ": " v "`n" 86 | MsgBox output 87 | } -------------------------------------------------------------------------------- /src/Network/GetDnsServerList.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author ........: jNizM 3 | ; Released ......: 2021-04-22 4 | ; Modified ......: 2023-01-12 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: GetDnsServerList() 8 | ; 9 | ; Parameter(s)...: No parameters used 10 | ; 11 | ; Return ........: Gets a list of DNS servers for the local computer. 12 | ; ============================================================================================================================================================= 13 | 14 | #Requires AutoHotkey v2.0 15 | 16 | 17 | GetDnsServerList() 18 | { 19 | static ERROR_SUCCESS := 0 20 | static ERROR_BUFFER_OVERFLOW := 111 21 | 22 | if (DllCall("iphlpapi\GetNetworkParams", "Ptr", 0, "UInt*", &Size := 0, "UInt") = ERROR_BUFFER_OVERFLOW) 23 | { 24 | Buf := Buffer(Size) 25 | if (DllCall("iphlpapi\GetNetworkParams", "Ptr", Buf, "UInt*", Size, "UInt") = ERROR_SUCCESS) 26 | { 27 | DNS_SERVERS := Array() 28 | DNS_SERVERS.Push(StrGet(Buf.Ptr + 264 + (A_PtrSize * 2), "CP0")) 29 | IPAddr := NumGet(Buf.Ptr + 264 + A_PtrSize, "UPtr") 30 | while (IPAddr) 31 | { 32 | DNS_SERVERS.Push(StrGet(IPAddr + A_PtrSize, "CP0")) 33 | IPAddr := NumGet(IPAddr, "UPtr") 34 | } 35 | return DNS_SERVERS 36 | } 37 | } 38 | return 39 | } 40 | 41 | 42 | ; ============================================================================================================================================================= 43 | ; Example 44 | ; ============================================================================================================================================================= 45 | 46 | DNS := GetDnsServerList() 47 | loop DNS.Length 48 | MsgBox DNS[A_Index] -------------------------------------------------------------------------------- /src/Network/GetNetworkConnectivityHint.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author ........: jNizM 3 | ; Released ......: 2022-10-14 4 | ; Modified ......: 2023-01-12 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: GetNetworkConnectivityHint() 8 | ; 9 | ; Parameter(s)...: No parameters used 10 | ; 11 | ; Return ........: Retrieves the aggregate level and cost of network connectivity that an application or service is likely to experience. 12 | ; ============================================================================================================================================================= 13 | 14 | #Requires AutoHotkey v2.0 15 | 16 | 17 | GetNetworkConnectivityHint() 18 | { 19 | static NO_ERROR := 0 ; User-Mode: NO_ERROR on success, error code on failure. 20 | static LEVEL_HINT := Map(0, "Unknown", 1, "None", 2, "LocalAccess", 3, "InternetAccess", 4, "ConstrainedInternetAccess", 5, "Hidden") 21 | static COST_HINT := Map(0, "Unknown", 1, "Unrestricted", 2, "Fixed", 3, "Variable") 22 | 23 | if (VerCompare(A_OSVersion, "10.0.19041") < 0) 24 | throw Error("Minimum supported client: Windows 10, version 2004 (Build 19041)", -1) 25 | 26 | Buf := Buffer(20) 27 | NETIOAPI_SUCCESS := DllCall("iphlpapi\GetNetworkConnectivityHint", "Ptr", Buf, "UInt") 28 | if (NETIOAPI_SUCCESS = NO_ERROR) 29 | { 30 | NETWORK_CONNECTIVITY_HINT := Map() 31 | NETWORK_CONNECTIVITY_HINT["ConnectivityLevel"] := LEVEL_HINT[NumGet(Buf, 0, "Int")] 32 | NETWORK_CONNECTIVITY_HINT["ConnectivityCost"] := COST_HINT[NumGet(Buf, 4, "Int")] 33 | NETWORK_CONNECTIVITY_HINT["ApproachingDataLimit"] := NumGet(Buf, 8, "Int") 34 | NETWORK_CONNECTIVITY_HINT["OverDataLimit"] := NumGet(Buf, 12, "Int") 35 | NETWORK_CONNECTIVITY_HINT["Roaming"] := NumGet(Buf, 16, "Int") 36 | return NETWORK_CONNECTIVITY_HINT 37 | } 38 | throw OSError() 39 | } 40 | 41 | 42 | ; ============================================================================================================================================================= 43 | ; Example 44 | ; ============================================================================================================================================================= 45 | 46 | for k, v in GetNetworkConnectivityHint() 47 | output .= k ": " v "`n" 48 | MsgBox output -------------------------------------------------------------------------------- /src/Network/ResolveHostname.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author ........: jNizM 3 | ; Released ......: 2021-04-30 4 | ; Modified ......: 2023-01-12 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: ResolveHostname( HostName ) 8 | ; 9 | ; Parameter(s)...: HostName - the hostname to be resolved 10 | ; 11 | ; Return ........: Gets the IP Address from a Hostname (Resolve Hostname to IP Address) like nslookup. 12 | ; ============================================================================================================================================================= 13 | 14 | #Requires AutoHotkey v2.0 15 | 16 | 17 | ResolveHostname(HostName) 18 | { 19 | static WSA_SUCCESS := 0 20 | static AF_INET := 2 21 | static SOCK_STREAM := 1 22 | static IPPROTO_TCP := 6 23 | 24 | WSADATA := Buffer(394 + (A_PtrSize - 2) + A_PtrSize) 25 | if (DllCall("ws2_32\WSAStartup", "UShort", 0x0202, "Ptr", WSADATA) != WSA_SUCCESS) 26 | { 27 | throw OSError(DllCall("ws2_32\WSAGetLastError")) 28 | } 29 | 30 | hints := Buffer(16 + 4 * A_PtrSize, 0) 31 | NumPut("Int", AF_INET, hints, 4) 32 | NumPut("Int", SOCK_STREAM, hints, 8) 33 | NumPut("Int", IPPROTO_TCP, hints, 12) 34 | if (DllCall("ws2_32\GetAddrInfoW", "Str", HostName, "Ptr", 0, "Ptr", hints, "Ptr*", &result := 0) != WSA_SUCCESS) 35 | { 36 | DllCall("ws2_32\WSACleanup") 37 | throw OSError(DllCall("ws2_32\WSAGetLastError")) 38 | } 39 | 40 | addrinfo := result 41 | IPList := Array() 42 | while (addrinfo) 43 | { 44 | ai_addr := NumGet(addrinfo, 16 + 2 * A_PtrSize, "Ptr") 45 | ai_addrlen := NumGet(addrinfo, 16, "UInt") 46 | DllCall("ws2_32\WSAAddressToStringW", "Ptr", ai_addr, "UInt", ai_addrlen, "Ptr", 0, "Ptr", 0, "UInt*", &AddressStringLength := 0) 47 | AddressString := Buffer(AddressStringLength << 1) 48 | if (DllCall("ws2_32\WSAAddressToStringW", "Ptr", ai_addr, "UInt", ai_addrlen, "Ptr", 0, "Ptr", AddressString, "UInt*", AddressString.Size) != WSA_SUCCESS) 49 | { 50 | DllCall("ws2_32\FreeAddrInfoW", "Ptr", result) 51 | DllCall("ws2_32\WSACleanup") 52 | throw OSError(DllCall("ws2_32\WSAGetLastError")) 53 | } 54 | IPList.Push(StrGet(AddressString)) 55 | addrinfo := NumGet(addrinfo, 16 + 3 * A_PtrSize, "Ptr") 56 | } 57 | 58 | DllCall("ws2_32\FreeAddrInfoW", "Ptr", result) 59 | DllCall("ws2_32\WSACleanup") 60 | return IPList 61 | } 62 | 63 | 64 | ; ============================================================================================================================================================= 65 | ; Example 66 | ; ============================================================================================================================================================= 67 | 68 | IPList := ResolveHostname("one.one.one.one") 69 | 70 | loop IPList.Length 71 | MsgBox IPList[A_Index] -------------------------------------------------------------------------------- /src/Network/ReverseLookup.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author ........: jNizM 3 | ; Released ......: 2021-04-30 4 | ; Modified ......: 2023-01-12 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: ReverseLookup( HostName ) 8 | ; 9 | ; Parameter(s)...: IPAddr - the IP Address to be resolved 10 | ; 11 | ; Return ........: Gets the Hostname by the IP Adresse (Reverse Lookup) like nslookup. 12 | ; ============================================================================================================================================================= 13 | 14 | #Requires AutoHotkey v2.0 15 | 16 | 17 | ReverseLookup(IPAddr) 18 | { 19 | static WSA_SUCCESS := 0 20 | static INADDR_ANY := 0x00000000 21 | static INADDR_NONE := 0xffffffff 22 | static NI_MAXHOST := 1025 23 | static AF_INET := 2 24 | 25 | WSADATA := Buffer(394 + (A_PtrSize - 2) + A_PtrSize) 26 | if (DllCall("ws2_32\WSAStartup", "UShort", 0x0202, "Ptr", WSADATA) != WSA_SUCCESS) 27 | { 28 | throw OSError(DllCall("ws2_32\WSAGetLastError")) 29 | } 30 | 31 | inaddr := DllCall("ws2_32\inet_addr", "AStr", IPAddr, "UInt") 32 | if (inaddr = INADDR_ANY) || (inaddr = INADDR_NONE) 33 | { 34 | DllCall("ws2_32\WSACleanup") 35 | throw OSError(DllCall("ws2_32\WSAGetLastError")) 36 | } 37 | 38 | Sockaddr := Buffer(16) 39 | NumPut("Short", AF_INET, Sockaddr, 0) 40 | NumPut("Ptr", inaddr, Sockaddr, 4) 41 | HostName := Buffer(NI_MAXHOST << 1, 0) 42 | if (DllCall("ws2_32\GetNameInfoW", "Ptr", Sockaddr, "UInt", Sockaddr.Size, "Ptr", HostName, "UInt", NI_MAXHOST, "Ptr", 0, "UInt", 0, "Int", 0) != WSA_SUCCESS) 43 | { 44 | DllCall("ws2_32\WSACleanup") 45 | throw OSError(DllCall("ws2_32\WSAGetLastError")) 46 | } 47 | 48 | DllCall("ws2_32\WSACleanup") 49 | return StrGet(HostName) 50 | } 51 | 52 | 53 | ; ============================================================================================================================================================= 54 | ; Example 55 | ; ============================================================================================================================================================= 56 | 57 | MsgBox ReverseLookup("1.1.1.1") -------------------------------------------------------------------------------- /src/NetworkManagement/NetGetJoinInformation.ahk: -------------------------------------------------------------------------------- 1 | ; =========================================================================================================================================================================== 2 | ; Retrieves join status information for the specified computer. 3 | ; Tested with AutoHotkey v2.0-beta.3 4 | ; =========================================================================================================================================================================== 5 | 6 | NetGetJoinInformation(Server := "127.0.0.1") 7 | { 8 | #DllLoad "netapi32.dll" 9 | 10 | static NERR_SUCCESS := 0 11 | static JOIN_STATUS := Map(0, "Unknown", 1, "Unjoined", 2, "WorkgroupName", 3, "DomainName") 12 | 13 | NET_API_STATUS := DllCall("netapi32\NetGetJoinInformation", "WStr", Server 14 | , "Ptr*", &Buf := 0 15 | , "Int*", &Status := 0 16 | , "UInt") 17 | 18 | if (NET_API_STATUS = NERR_SUCCESS) 19 | { 20 | JOIN_INFO := Map() 21 | JOIN_INFO["Name"] := StrGet(Buf) 22 | JOIN_INFO["Type"] := JOIN_STATUS[Status] 23 | 24 | DllCall("netapi32\NetApiBufferFree", "Ptr", Buf, "UInt") 25 | return JOIN_INFO 26 | } 27 | 28 | DllCall("netapi32\NetApiBufferFree", "Ptr", Buf, "UInt") 29 | return false 30 | } 31 | 32 | ; =========================================================================================================================================================================== 33 | 34 | for k, v in NetGetJoinInformation() 35 | output .= k ": " v "`n" 36 | MsgBox output -------------------------------------------------------------------------------- /src/NetworkManagement/NetGroupEnum.ahk: -------------------------------------------------------------------------------- 1 | ; =========================================================================================================================================================================== 2 | ; Retrieves information about each global group in the security database, which is the SAM database or, in the case of domain controllers, the Active Directory. 3 | ; Tested with AutoHotkey v2.0-beta.3 4 | ; =========================================================================================================================================================================== 5 | 6 | NetGroupEnum(ServerName := "127.0.0.1") 7 | { 8 | #DllLoad "netapi32.dll" 9 | 10 | static NERR_SUCCESS := 0 11 | static GROUP_INFO_1 := 1 12 | static MAX_PREFERRED_LENGTH := -1 13 | 14 | NET_API_STATUS := DllCall("netapi32\NetGroupEnum", "WStr", ServerName 15 | , "UInt", GROUP_INFO_1 16 | , "Ptr*", &Buf := 0 17 | , "UInt", MAX_PREFERRED_LENGTH 18 | , "UInt*", &EntriesRead := 0 19 | , "UInt*", &TotalEntries := 0 20 | , "UInt*", 0 21 | , "UInt") 22 | 23 | if (NET_API_STATUS = NERR_SUCCESS) 24 | { 25 | Addr := Buf 26 | GROUP_INFO := Map() 27 | loop EntriesRead 28 | { 29 | INFO := Map() 30 | INFO["name"] := (Ptr := NumGet(Addr, A_PtrSize * 0, "Ptr")) ? StrGet(Ptr) : "" 31 | INFO["comment"] := (Ptr := NumGet(Addr, A_PtrSize * 1, "Ptr")) ? StrGet(Ptr) : "" 32 | GROUP_INFO[A_Index] := INFO 33 | 34 | Addr += A_PtrSize * 2 35 | } 36 | 37 | DllCall("netapi32\NetApiBufferFree", "Ptr", Buf, "UInt") 38 | return GROUP_INFO 39 | } 40 | 41 | DllCall("netapi32\NetApiBufferFree", "Ptr", Buf, "UInt") 42 | return false 43 | } 44 | 45 | ; =========================================================================================================================================================================== 46 | 47 | GroupEnum := NetGroupEnum("dc.contoso.com") 48 | for i, v in GroupEnum { 49 | for k, v in GroupEnum[i] 50 | output .= k ": " v "`n" 51 | MsgBox output 52 | output := "" 53 | } -------------------------------------------------------------------------------- /src/NetworkManagement/NetGroupGetInfo.ahk: -------------------------------------------------------------------------------- 1 | ; =========================================================================================================================================================================== 2 | ; Retrieves information about a particular global group in the security database, which is the SAM database or, in the case of domain controllers, the Active Directory. 3 | ; Tested with AutoHotkey v2.0-beta.3 4 | ; =========================================================================================================================================================================== 5 | 6 | NetGroupGetInfo(GroupName, ServerName := "127.0.0.1") 7 | { 8 | #DllLoad "netapi32.dll" 9 | 10 | static NERR_SUCCESS := 0 11 | static GROUP_INFO_1 := 1 12 | 13 | NET_API_STATUS := DllCall("netapi32\NetGroupGetInfo", "WStr", ServerName 14 | , "WStr", GroupName 15 | , "UInt", GROUP_INFO_1 16 | , "Ptr*", &Buf := 0 17 | , "UInt") 18 | 19 | if (NET_API_STATUS = NERR_SUCCESS) 20 | { 21 | GROUP_INFO := Map() 22 | GROUP_INFO["name"] := (Ptr := NumGet(Buf, A_PtrSize * 0, "Ptr")) ? StrGet(Ptr) : "" 23 | GROUP_INFO["comment"] := (Ptr := NumGet(Buf, A_PtrSize * 1, "Ptr")) ? StrGet(Ptr) : "" 24 | 25 | DllCall("netapi32\NetApiBufferFree", "Ptr", Buf, "UInt") 26 | return GROUP_INFO 27 | } 28 | 29 | DllCall("netapi32\NetApiBufferFree", "Ptr", Buf, "UInt") 30 | return false 31 | } 32 | 33 | ; =========================================================================================================================================================================== 34 | 35 | for k, v in NetGroupGetInfo("G_GROUP_TEST", "dc.contoso.com") 36 | output .= k ": " v "`n" 37 | MsgBox output -------------------------------------------------------------------------------- /src/NetworkManagement/NetGroupGetUsers.ahk: -------------------------------------------------------------------------------- 1 | ; =========================================================================================================================================================================== 2 | ; Retrieves a list of the members in a particular global group in the security database, which is the SAM database or the Active Directory. 3 | ; Tested with AutoHotkey v2.0-beta.3 4 | ; =========================================================================================================================================================================== 5 | 6 | NetGroupGetUsers(GroupName, ServerName := "127.0.0.1") 7 | { 8 | #DllLoad "netapi32.dll" 9 | 10 | static NERR_SUCCESS := 0 11 | static GROUP_USERS_INFO_0 := 0 12 | static MAX_PREFERRED_LENGTH := -1 13 | 14 | NET_API_STATUS := DllCall("netapi32\NetGroupGetUsers", "WStr", ServerName 15 | , "WStr", GroupName 16 | , "UInt", GROUP_USERS_INFO_0 17 | , "Ptr*", &Buf := 0 18 | , "UInt", MAX_PREFERRED_LENGTH 19 | , "UInt*", &EntriesRead := 0 20 | , "UInt*", &TotalEntries := 0 21 | , "UPtr*", 0 22 | , "UInt") 23 | 24 | if (NET_API_STATUS = NERR_SUCCESS) 25 | { 26 | Addr := Buf 27 | GROUP_USERS_INFO := Array() 28 | loop EntriesRead 29 | { 30 | GROUP_USERS_INFO.Push((Ptr := NumGet(Addr, A_PtrSize * 0, "Ptr")) ? StrGet(Ptr) : "") 31 | Addr += A_PtrSize 32 | } 33 | 34 | DllCall("netapi32\NetApiBufferFree", "Ptr", Buf, "UInt") 35 | return GROUP_USERS_INFO 36 | } 37 | 38 | DllCall("netapi32\NetApiBufferFree", "Ptr", Buf, "UInt") 39 | return false 40 | } 41 | 42 | ; =========================================================================================================================================================================== 43 | 44 | for k, v in NetGroupGetUsers("G_GROUP_TEST", "dc.contoso.com") 45 | output .= k ": " v "`n" 46 | MsgBox output -------------------------------------------------------------------------------- /src/NetworkManagement/NetLocalGroupEnum.ahk: -------------------------------------------------------------------------------- 1 | ; =========================================================================================================================================================================== 2 | ; Returns information about each local group account on the specified server. 3 | ; Tested with AutoHotkey v2.0-beta.3 4 | ; =========================================================================================================================================================================== 5 | 6 | NetLocalGroupEnum(ServerName := "127.0.0.1") 7 | { 8 | #DllLoad "netapi32.dll" 9 | 10 | static NERR_SUCCESS := 0 11 | static LOCALGROUP_INFO_1 := 1 12 | static MAX_PREFERRED_LENGTH := -1 13 | 14 | NET_API_STATUS := DllCall("netapi32\NetLocalGroupEnum", "WStr", ServerName 15 | , "UInt", LOCALGROUP_INFO_1 16 | , "Ptr*", &Buf := 0 17 | , "UInt", MAX_PREFERRED_LENGTH 18 | , "UInt*", &EntriesRead := 0 19 | , "UInt*", &TotalEntries := 0 20 | , "UPtr*", 0 21 | , "UInt") 22 | 23 | if (NET_API_STATUS = NERR_SUCCESS) 24 | { 25 | Addr := Buf 26 | LOCALGROUP_INFO := Map() 27 | loop EntriesRead 28 | { 29 | INFO := Map() 30 | INFO["name"] := (Ptr := NumGet(Addr, A_PtrSize * 0, "Ptr")) ? StrGet(Ptr) : "" 31 | INFO["comment"] := (Ptr := NumGet(Addr, A_PtrSize * 1, "Ptr")) ? StrGet(Ptr) : "" 32 | LOCALGROUP_INFO[A_Index] := INFO 33 | 34 | Addr += A_PtrSize * 2 35 | } 36 | 37 | DllCall("netapi32\NetApiBufferFree", "Ptr", Buf, "UInt") 38 | return LOCALGROUP_INFO 39 | } 40 | 41 | DllCall("netapi32\NetApiBufferFree", "Ptr", Buf, "UInt") 42 | return false 43 | } 44 | 45 | ; =========================================================================================================================================================================== 46 | 47 | LocalGroupEnum := NetLocalGroupEnum("dc.contoso.com") 48 | for i, v in LocalGroupEnum { 49 | for k, v in LocalGroupEnum[i] 50 | output .= k ": " v "`n" 51 | MsgBox output 52 | output := "" 53 | } -------------------------------------------------------------------------------- /src/NetworkManagement/NetLocalGroupGetInfo.ahk: -------------------------------------------------------------------------------- 1 | ; =========================================================================================================================================================================== 2 | ; Retrieves information about a particular local group account on a server. 3 | ; Tested with AutoHotkey v2.0-beta.3 4 | ; =========================================================================================================================================================================== 5 | 6 | NetLocalGroupGetInfo(GroupName, ServerName := "127.0.0.1") 7 | { 8 | #DllLoad "netapi32.dll" 9 | 10 | static NERR_SUCCESS := 0 11 | static LOCALGROUP_INFO_1 := 1 12 | 13 | NET_API_STATUS := DllCall("netapi32\NetLocalGroupGetInfo", "WStr", ServerName 14 | , "WStr", GroupName 15 | , "UInt", LOCALGROUP_INFO_1 16 | , "Ptr*", &Buf := 0 17 | , "UInt") 18 | 19 | if (NET_API_STATUS = NERR_SUCCESS) 20 | { 21 | LOCALGROUP_INFO := Map() 22 | LOCALGROUP_INFO["name"] := (Ptr := NumGet(Buf, A_PtrSize * 0, "Ptr")) ? StrGet(Ptr) : "" 23 | LOCALGROUP_INFO["comment"] := (Ptr := NumGet(Buf, A_PtrSize * 1, "Ptr")) ? StrGet(Ptr) : "" 24 | 25 | DllCall("netapi32\NetApiBufferFree", "Ptr", Buf, "UInt") 26 | return LOCALGROUP_INFO 27 | } 28 | 29 | DllCall("netapi32\NetApiBufferFree", "Ptr", Buf, "UInt") 30 | return false 31 | } 32 | 33 | ; =========================================================================================================================================================================== 34 | 35 | for k, v in NetLocalGroupGetInfo("L_GROUP_TEST", "dc.contoso.com") 36 | output .= k ": " v "`n" 37 | MsgBox output -------------------------------------------------------------------------------- /src/NetworkManagement/NetLocalGroupGetMembers.ahk: -------------------------------------------------------------------------------- 1 | ; =========================================================================================================================================================================== 2 | ; Author ........: jNizM 3 | ; Released ......: 2022-01-17 4 | ; Modified ......: 5 | ; Tested with....: AutoHotkey v2.0-beta.3 (x64) 6 | ; Tested on .....: Windows 11 - 21H2 (x64) 7 | ; Function ......: NetLocalGroupGetMembers( GroupName, [ServerName] ) 8 | ; 9 | ; Parameter(s)...: GroupName - the name of the local group whose members are to be listed 10 | ; ServerName - DNS or NetBIOS name of the remote server on which the function is to execute 11 | ; 12 | ; Return ........: Retrieves a list of the members of a particular local group in the security database, which is the security accounts manager (SAM) database or, 13 | ; in the case of domain controllers, the Active Directory. 14 | ; =========================================================================================================================================================================== 15 | 16 | NetLocalGroupGetMembers(GroupName, ServerName := "127.0.0.1") 17 | { 18 | #DllLoad "netapi32.dll" 19 | 20 | static NERR_SUCCESS := 0 21 | static LOCALGROUP_MEMBERS_INFO_1 := 1 22 | static LOCALGROUP_MEMBERS_INFO_2 := 2 23 | static MAX_PREFERRED_LENGTH := -1 24 | static SID_NAME_USE := Map(1, "User", 2, "Group", 16, "WellKnownGroup", 32, "DeletedAccount", 128, "Unknown") 25 | 26 | NET_API_STATUS := DllCall("netapi32\NetLocalGroupGetMembers", "WStr", ServerName 27 | , "WStr", GroupName 28 | , "UInt", ((ServerName = "127.0.0.1") ? LOCALGROUP_MEMBERS_INFO_1 : LOCALGROUP_MEMBERS_INFO_2) 29 | , "Ptr*", &Buf := 0 30 | , "UInt", MAX_PREFERRED_LENGTH 31 | , "UInt*", &EntriesRead := 0 32 | , "UInt*", &TotalEntries := 0 33 | , "UPtr*", 0 34 | , "UInt") 35 | 36 | if (NET_API_STATUS = NERR_SUCCESS) 37 | { 38 | Addr := Buf 39 | LOCALGROUP_MEMBERS_INFO := Map() 40 | loop EntriesRead 41 | { 42 | MEMBERS_INFO := Map() 43 | MEMBERS_INFO["sid"] := ConvertSidToStringSid(NumGet(Addr, A_PtrSize * 0, "Ptr")) 44 | MEMBERS_INFO["sidusage"] := SID_NAME_USE[NumGet(Addr, A_PtrSize * 1, "Int")] 45 | MEMBERS_INFO["domainandname"] := (Ptr := NumGet(Addr, A_PtrSize * 2, "Ptr")) ? StrGet(Ptr) : "" 46 | LOCALGROUP_MEMBERS_INFO[A_Index] := MEMBERS_INFO 47 | 48 | Addr += A_PtrSize * 3 49 | } 50 | 51 | DllCall("netapi32\NetApiBufferFree", "Ptr", Buf, "UInt") 52 | return LOCALGROUP_MEMBERS_INFO 53 | } 54 | 55 | DllCall("netapi32\NetApiBufferFree", "Ptr", Buf, "UInt") 56 | return false 57 | } 58 | 59 | 60 | ConvertSidToStringSid(PSID) 61 | { 62 | #DllLoad "advapi32.dll" 63 | 64 | if (DllCall("advapi32\ConvertSidToStringSidW", "Ptr", PSID, "Ptr*", &StringSid := 0)) 65 | { 66 | StringLength := DllCall("lstrlenW", "Ptr", StringSid) 67 | VarSetStrCapacity(&SID, StringLength) 68 | DllCall("lstrcpyW", "Str", SID, "Ptr", StringSid) 69 | DllCall("LocalFree", "Ptr", StringSid) 70 | return SID 71 | } 72 | return false 73 | } 74 | 75 | 76 | ; =========================================================================================================================================================================== 77 | ; Example 78 | ; =========================================================================================================================================================================== 79 | 80 | LocalGroupMembers := NetLocalGroupGetMembers("L_GROUP_TEST", "dc.contoso.com") 81 | for i, v in LocalGroupMembers { 82 | for k, v in LocalGroupMembers[i] 83 | output .= k ": " v "`n" 84 | MsgBox output 85 | output := "" 86 | } -------------------------------------------------------------------------------- /src/Others/CreateGUID.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author ........: jNizM 3 | ; Released ......: 2021-10-13 4 | ; Modified ......: 2023-01-12 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: CreateGUID() 8 | ; 9 | ; Parameter(s)...: No parameters used 10 | ; 11 | ; Return ........: Creates an Globally Unique IDentifier (GUID). 12 | ; A GUID provides a unique 128-bit integer used for CLSIDs and interface identifiers. 13 | ; ============================================================================================================================================================= 14 | 15 | #Requires AutoHotkey v2.0 16 | 17 | 18 | CreateGUID() 19 | { 20 | static S_OK := 0, GUID := "" 21 | 22 | pGUID := Buffer(16) 23 | if (DllCall("ole32\CoCreateGuid", "Ptr", pGUID) = S_OK) 24 | { 25 | Size := VarSetStrCapacity(&GUID, 38) 26 | if (DllCall("ole32\StringFromGUID2", "Ptr", pGUID, "Str", GUID, "Int", Size + 1)) 27 | { 28 | return GUID 29 | } 30 | } 31 | return 32 | } 33 | 34 | 35 | ; ============================================================================================================================================================= 36 | ; Example 37 | ; ============================================================================================================================================================= 38 | 39 | MsgBox CreateGUID() -------------------------------------------------------------------------------- /src/Others/CreateUUID.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author ........: jNizM 3 | ; Released ......: 2021-10-13 4 | ; Modified ......: 2023-01-12 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: CreateUUID() 8 | ; 9 | ; Parameter(s)...: No parameters used 10 | ; 11 | ; Return ........: Creates an Universally Unique IDentifier (UUID). 12 | ; A UUID provides a unique designation of an object such as an interface, a manager entry-point vector, or a client object. 13 | ; ============================================================================================================================================================= 14 | 15 | #Requires AutoHotkey v2.0 16 | 17 | 18 | CreateUUID() 19 | { 20 | static RPC_S_OK := 0, UUID := "" 21 | 22 | pUUID := Buffer(16) 23 | if (DllCall("rpcrt4\UuidCreate", "Ptr", pUUID) = RPC_S_OK) 24 | { 25 | if (DllCall("rpcrt4\UuidToStringW", "Ptr", pUUID, "Ptr*", &StringUuid := 0) = RPC_S_OK) 26 | { 27 | UUID := StrGet(StringUuid) 28 | DllCall("rpcrt4\RpcStringFreeW", "Ptr*", StringUuid) 29 | } 30 | } 31 | return UUID 32 | } 33 | 34 | 35 | ; ============================================================================================================================================================= 36 | ; Example 37 | ; ============================================================================================================================================================= 38 | 39 | MsgBox CreateUUID() -------------------------------------------------------------------------------- /src/Others/GetFileOwner.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author ........: jNizM 3 | ; Released ......: 2022-02-08 4 | ; Modified ......: 2023-01-12 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: GetFileOwner( FileName ) 8 | ; 9 | ; Parameter(s)...: FileName - path to the file 10 | ; 11 | ; Return ........: Finding the Owner of a File or Folder 12 | ; ============================================================================================================================================================= 13 | 14 | #Requires AutoHotkey v2.0 15 | 16 | 17 | GetFileOwner(FileName) 18 | { 19 | static GENERIC_READ := 0x80000000 20 | static FILE_SHARE_READ := 0x00000001 21 | static FILE_SHARE_WRITE := 0x00000002 22 | static FILE_SHARE_DELETE := 0x00000004 23 | static OPEN_EXISTING := 3 24 | static FILE_FLAG_BACKUP_SEMANTICS := 0x02000000 25 | static SE_FILE_OBJECT := 1 26 | static OWNER_SECURITY_INFORMATION := 0x00000001 27 | static ERROR_SUCCESS := 0 28 | static SidTypeUnknown := 8 29 | 30 | if !(hFile := DllCall("CreateFile", "Str", FileName 31 | , "UInt", GENERIC_READ 32 | , "UInt", FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE 33 | , "Ptr", 0 34 | , "UInt", OPEN_EXISTING 35 | , "UInt", 0 36 | , "Ptr", 0 37 | , "Ptr")) 38 | && !(hFile := DllCall("CreateFile", "Str", FileName 39 | , "UInt", GENERIC_READ 40 | , "UInt", FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE 41 | , "Ptr", 0 42 | , "UInt", OPEN_EXISTING 43 | , "UInt", FILE_FLAG_BACKUP_SEMANTICS 44 | , "Ptr", 0 45 | , "Ptr")) 46 | return 47 | 48 | rCode := DllCall("advapi32\GetSecurityInfo", "Ptr", hFile 49 | , "Int", SE_FILE_OBJECT 50 | , "UInt", OWNER_SECURITY_INFORMATION 51 | , "Ptr*", &pSidOwner := 0 52 | , "Ptr", 0 53 | , "Ptr", 0 54 | , "Ptr", 0 55 | , "Ptr*", &pSD := 0 56 | , "UInt") 57 | if (rCode != ERROR_SUCCESS) 58 | { 59 | DllCall("CloseHandle", "Ptr", hFile) 60 | return 61 | } 62 | 63 | DllCall("advapi32\LookupAccountSid", "Ptr", 0 64 | , "Ptr", pSidOwner 65 | , "Ptr", 0 66 | , "UInt*", &sN := 0 67 | , "Ptr", 0 68 | , "UInt*", &sD := 0 69 | , "UInt*", SidTypeUnknown) 70 | 71 | VarSetStrCapacity(&Name, sN) 72 | VarSetStrCapacity(&DomainName, sD) 73 | DllCall("advapi32\LookupAccountSid", "Ptr", 0 74 | , "Ptr", pSidOwner 75 | , "Str", Name 76 | , "UInt*", sN 77 | , "Str", DomainName 78 | , "UInt*", sD 79 | , "UInt*", SidTypeUnknown) 80 | 81 | DllCall("LocalFree", "Ptr", pSD) 82 | DllCall("CloseHandle", "Ptr", hFile) 83 | 84 | return (DomainName) ? DomainName "\" Name : (Name) ? Name : "" 85 | } 86 | 87 | 88 | ; ============================================================================================================================================================= 89 | ; Example 90 | ; ============================================================================================================================================================= 91 | 92 | MsgBox GetFileOwner("C:\Program Files\AutoHotkey\AutoHotkeyU64.exe") -------------------------------------------------------------------------------- /src/Others/GetFileVersionInfo.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author ........: jNizM (Original by Lexikos) 3 | ; Released ......: 2021-05-10 4 | ; Modified ......: 2023-01-12 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: GetFileVersionInfo( FileName ) 8 | ; 9 | ; Parameter(s)...: FileName - path to the file 10 | ; 11 | ; Return ........: Retrieves specified version information from the specified version-information resource. 12 | ; ============================================================================================================================================================= 13 | 14 | #Requires AutoHotkey v2.0 15 | 16 | 17 | GetFileVersionInfo(FileName) 18 | { 19 | static StringTable := [ "Comments", "CompanyName", "FileDescription", "FileVersion", "InternalName", "LegalCopyright" 20 | , "LegalTrademarks", "OriginalFilename", "PrivateBuild", "ProductName", "ProductVersion", "SpecialBuild" ] 21 | 22 | if (Size := DllCall("version\GetFileVersionInfoSizeW", "Str", FileName, "Ptr", 0, "UInt")) 23 | { 24 | Data := Buffer(Size) 25 | if (DllCall("version\GetFileVersionInfoW", "Str", FileName, "UInt", 0, "UInt", Data.Size, "Ptr", Data)) 26 | { 27 | if (DllCall("version\VerQueryValueW", "Ptr", Data, "Str", "\VarFileInfo\Translation", "Ptr*", &Buf := 0, "UInt*", &Len := 0)) 28 | { 29 | LangCP := Format("{:04X}{:04X}", NumGet(Buf + 0, "UShort"), NumGet(Buf + 2, "UShort")) 30 | FileInfo := Map() 31 | for index, value in StringTable 32 | { 33 | if (DllCall("version\VerQueryValueW", "Ptr", Data, "Str", "\StringFileInfo\" . LangCP . "\" value, "Ptr*", &Buf, "UInt*", &Len)) 34 | { 35 | FileInfo[value] := StrGet(Buf, Len, "UTF-16") 36 | } 37 | } 38 | return FileInfo 39 | } 40 | } 41 | } 42 | throw OSError() 43 | } 44 | 45 | 46 | ; ============================================================================================================================================================= 47 | ; Example 48 | ; ============================================================================================================================================================= 49 | 50 | FileVersionInfo := GetFileVersionInfo("C:\Program Files\AutoHotkey\AutoHotkey.exe") 51 | for key, value in FileVersionInfo 52 | output .= key ": " value "`n" 53 | MsgBox output -------------------------------------------------------------------------------- /src/Others/IsRemoteSession.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author ........: jNizM 3 | ; Released ......: 2022-02-21 4 | ; Modified ......: 2023-02-08 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: IsRemoteSession() 8 | ; 9 | ; Parameter(s)...: No parameters used 10 | ; 11 | ; Return ........: Returns TRUE that the current session is a remote session, and FALSE that the current session is a local session. 12 | ; ============================================================================================================================================================= 13 | 14 | #Requires AutoHotkey v2.0 15 | 16 | 17 | IsRemoteSession() 18 | { 19 | #DllLoad "wtsapi32.dll" 20 | 21 | static WTS_CURRENT_SERVER_HANDLE := 0 22 | static WTSIsRemoteSession := 29 23 | static ProcessId := DllCall("kernel32\GetCurrentProcessId") 24 | 25 | ; retrieves the Remote Desktop Services session associated with a specified process 26 | if !(DllCall("kernel32\ProcessIdToSessionId", "UInt", ProcessId, "UInt*", &SessionId := 0)) 27 | throw OSError() 28 | 29 | ; retrieves session information for the specified session on the specified Remote Desktop Session Host (RD Session Host) 30 | if !(DllCall("wtsapi32\WTSQuerySessionInformation", "Ptr", WTS_CURRENT_SERVER_HANDLE, "UInt", SessionId, "Int", WTSIsRemoteSession, "Ptr*", &Buf := 0, "UInt*", &Size := 0)) 31 | { 32 | DllCall("wtsapi32\WTSFreeMemory", "Ptr", Buf) 33 | throw OSError() 34 | } 35 | IsRemoteSession := NumGet(Buf, "Int") 36 | DllCall("wtsapi32\WTSFreeMemory", "Ptr", Buf) 37 | 38 | return IsRemoteSession 39 | } 40 | 41 | 42 | ; ============================================================================================================================================================= 43 | ; Example 44 | ; ============================================================================================================================================================= 45 | 46 | MsgBox IsRemoteSession() -------------------------------------------------------------------------------- /src/ProcessThreadModule/GetModuleBaseAddr.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author ........: jNizM 3 | ; Released ......: 2016-06-20 4 | ; Modified ......: 2023-01-12 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: GetModuleBaseAddr() 8 | ; 9 | ; Parameter(s)...: ProcessID - The process identifier of the process. 10 | ; ModuleName - The name of the module. 11 | ; 12 | ; Return ........: Retrieves the base address and size of the module in the context of the owning process. 13 | ; ============================================================================================================================================================= 14 | 15 | #Requires AutoHotkey v2.0 16 | 17 | 18 | GetModuleBaseAddr(ProcessID, ModuleName) 19 | { 20 | static TH32CS_SNAPMODULE := 0x00000008 21 | static TH32CS_SNAPMODULE32 := 0x00000010 22 | 23 | if !(hSnapshot := DllCall("CreateToolhelp32Snapshot", "UInt", TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, "UInt", ProcessID, "Ptr")) 24 | throw OSError() 25 | 26 | MODULEENTRY32 := Buffer(A_PtrSize = 8 ? 568 : 548) 27 | NumPut("UInt", MODULEENTRY32.Size, MODULEENTRY32, 0) 28 | if !(DllCall("Module32First", "Ptr", hSnapshot, "Ptr", MODULEENTRY32)) 29 | { 30 | DllCall("CloseHandle", "Ptr", hSnapshot) 31 | throw OSError() 32 | } 33 | 34 | BaseAddr := Map() 35 | while (DllCall("Module32Next", "Ptr", hSnapshot, "Ptr", MODULEENTRY32)) 36 | { 37 | Module := StrGet(MODULEENTRY32.Ptr + (A_PtrSize = 8 ? 48 : 32), 256, "cp0") 38 | if (Module = ModuleName) 39 | { 40 | BaseAddr["BaseAddr"] := Format("{:#016x}", NumGet(MODULEENTRY32, (A_PtrSize = 8 ? 24 : 20), "uptr")) 41 | BaseAddr["BaseSize"] := NumGet(MODULEENTRY32, (A_PtrSize = 8 ? 32 : 24), "uint") 42 | } 43 | } 44 | 45 | DllCall("CloseHandle", "Ptr", hSnapshot) 46 | return BaseAddr 47 | } 48 | 49 | 50 | ; ============================================================================================================================================================= 51 | ; Example 52 | ; ============================================================================================================================================================= 53 | 54 | ModuleBaseAddr := GetModuleBaseAddr(16084, "user32.dll") 55 | MsgBox "BaseAddr:`t" ModuleBaseAddr["BaseAddr"] "`nBaseSize:`t`t" ModuleBaseAddr["BaseSize"] " bytes" -------------------------------------------------------------------------------- /src/ProcessThreadModule/GetProcessHandles.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author ........: jNizM 3 | ; Released ......: 2016-07-07 4 | ; Modified ......: 2023-02-01 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: GetProcessHandles() 8 | ; 9 | ; Parameter(s)...: ProcessID - The process identifier of the process. 10 | ; 11 | ; Return ........: Retrieves all Handles in the context of the owning process. 12 | ; ============================================================================================================================================================= 13 | 14 | #Requires AutoHotkey v2.0 15 | 16 | 17 | GetProcessHandles(ProcessID) 18 | { 19 | #DllLoad "advapi32.dll" 20 | #DllLoad "ntdll.dll" 21 | 22 | static PROCESS_DUP_HANDLE := 0x0040 23 | static TOKEN_ADJUST_PRIVILEGES := 0x0020 24 | static DUPLICATE_SAME_ACCESS := 0x00000002 25 | static OBJECT_NAME_INFORMATION := 1 26 | static OBJECT_TYPE_INFORMATION := 2 27 | static hCurrentProcess := DllCall("GetCurrentProcess", "Ptr") 28 | 29 | hToken := OpenProcessToken(hCurrentProcess, TOKEN_ADJUST_PRIVILEGES) 30 | LUID := LookupPrivilegeValue("SeDebugPrivilege") 31 | AdjustTokenPrivileges(hToken, LUID) 32 | CloseHandle(hToken) 33 | 34 | hProcess := OpenProcess(ProcessID, PROCESS_DUP_HANDLE) 35 | mHandles := SystemHandleInformation(ProcessID) 36 | ProcessHandles := Map() 37 | for i, v in mHandles 38 | { 39 | PH := Map() 40 | HandleValue := mHandles[i]["HandleValue"] 41 | if !(hDublicate := DuplicateObject(hProcess, hCurrentProcess, HandleValue, DUPLICATE_SAME_ACCESS)) 42 | continue 43 | PH["Handle"] := HandleValue 44 | PH["Name"] := QueryObject(hDublicate, OBJECT_NAME_INFORMATION) 45 | PH["Type"] := QueryObject(hDublicate, OBJECT_TYPE_INFORMATION) 46 | PH["Path"] := GetFinalPathNameByHandle(hDublicate) 47 | ProcessHandles[A_Index] := PH 48 | CloseHandle(hDublicate) 49 | } 50 | CloseHandle(hProcess) 51 | return ProcessHandles 52 | 53 | 54 | AdjustTokenPrivileges(hToken, LUID) 55 | { 56 | static SE_PRIVILEGE_ENABLED := 0x00000002 57 | 58 | TOKEN_PRIVILEGES := Buffer(16, 0) 59 | NumPut("UInt", 1, TOKEN_PRIVILEGES, 0) 60 | NumPut("Int64", LUID, TOKEN_PRIVILEGES, 4) 61 | NumPut("UInt", SE_PRIVILEGE_ENABLED, TOKEN_PRIVILEGES, 12) 62 | if !(DllCall("advapi32\AdjustTokenPrivileges", "Ptr", hToken, "Int", 0, "Ptr", TOKEN_PRIVILEGES, "UInt", TOKEN_PRIVILEGES.Size, "Ptr", 0, "Ptr", 0)) 63 | return false 64 | return true 65 | } 66 | 67 | CloseHandle(hObject) 68 | { 69 | if (hObject) 70 | DllCall("CloseHandle", "Ptr", hObject) 71 | } 72 | 73 | DuplicateObject(hProcess, hCurrentProcess, Handle, Options) 74 | { 75 | static STATUS_SUCCESS := 0x00000000 76 | 77 | NT_STATUS := DllCall("ntdll\NtDuplicateObject", "Ptr", hProcess, "Ptr", Handle, "Ptr", hCurrentProcess, "Ptr*", &hDublicate := 0, "UInt", 0, "UInt", 0, "UInt", Options) 78 | if (NT_STATUS = STATUS_SUCCESS) 79 | return hDublicate 80 | return false 81 | } 82 | 83 | GetFinalPathNameByHandle(hFile) 84 | { 85 | Size := DllCall("GetFinalPathNameByHandleW", "Ptr", hFile, "Ptr", 0, "UInt", 0, "UInt", 0, "UInt") 86 | VarSetStrCapacity(&FilePath, Size) 87 | if !(DllCall("GetFinalPathNameByHandleW", "Ptr", hFile, "Str", FilePath, "UInt", Size, "UInt", 0, "UInt")) 88 | return 89 | return FilePath 90 | } 91 | 92 | LookupPrivilegeValue(Name) 93 | { 94 | if !(DllCall("advapi32\LookupPrivilegeValueW", "Ptr", 0, "Str", Name, "Int64*", &LUID := 0)) 95 | return false 96 | return LUID 97 | } 98 | 99 | QueryObject(Handle, OBJECT_INFORMATION_CLASS) 100 | { 101 | static STATUS_SUCCESS := 0x00000000 102 | 103 | DllCall("ntdll\NtQueryObject", "Ptr", Handle, "UInt", OBJECT_INFORMATION_CLASS, "Ptr", 0, "UInt", 0, "UInt*", &Size := 0, "UInt") 104 | Buf := Buffer(Size, 0) 105 | NT_STATUS := DllCall("ntdll\NtQueryObject", "Ptr", Handle, "UInt", OBJECT_INFORMATION_CLASS, "Ptr", Buf.Ptr, "UInt", Buf.Size, "UInt*", &Size := 0, "UInt") 106 | if (NT_STATUS = STATUS_SUCCESS) 107 | { 108 | switch OBJECT_INFORMATION_CLASS 109 | { 110 | case 1: 111 | ObjectInformation := StrGet(NumGet(buf, A_PtrSize, "UPtr"), NumGet(buf, 0, "UShort") // 2, "UTF-16") 112 | case 2: 113 | ObjectInformation .= StrGet(NumGet(buf, A_PtrSize, "UPtr"), NumGet(buf, 0, "UShort") // 2, "UTF-16") 114 | } 115 | return ObjectInformation 116 | } 117 | return 118 | } 119 | 120 | OpenProcess(ProcessID, DesiredAccess, InheritHandle := 0) 121 | { 122 | if !(hProcess := DllCall("OpenProcess", "UInt", DesiredAccess, "Int", InheritHandle, "UInt", ProcessID, "Ptr")) 123 | return false 124 | return hProcess 125 | } 126 | 127 | OpenProcessToken(hProcess, DesiredAccess) 128 | { 129 | if !(DllCall("advapi32\OpenProcessToken", "Ptr", hProcess, "UInt", DesiredAccess, "Ptr*", &hToken := 0)) 130 | return false 131 | return hToken 132 | } 133 | 134 | SystemHandleInformation(ProcessID) 135 | { 136 | static STATUS_SUCCESS := 0x00000000 137 | static STATUS_INFO_LENGTH_MISMATCH := 0xC0000004 138 | static STATUS_BUFFER_TOO_SMALL := 0xC0000023 139 | static SYSTEM_HANDLE_INFORMATION := 0x00000010 140 | static SYSTEM_HANDLE_INFORMATION_EX := 0x00000040 141 | 142 | Buf := Buffer(0, 0) 143 | NT_STATUS := DllCall("ntdll\NtQuerySystemInformation", "Int", SYSTEM_HANDLE_INFORMATION_EX, "Ptr", Buf.Ptr, "UInt", Buf.Size, "UInt*", &Size := 0, "UInt") 144 | while (NT_STATUS = STATUS_INFO_LENGTH_MISMATCH) || (NT_STATUS = STATUS_BUFFER_TOO_SMALL) 145 | { 146 | Buf := Buffer(Size, 0) 147 | NT_STATUS := DllCall("ntdll\NtQuerySystemInformation", "Int", SYSTEM_HANDLE_INFORMATION_EX, "Ptr", Buf.Ptr, "UInt", Buf.Size, "UInt*", &Size := 0, "UInt") 148 | } 149 | if (NT_STATUS = STATUS_SUCCESS) 150 | { 151 | NumberOfHandles := NumGet(Buf, 0x0000, "UInt") 152 | Addr := Buf.Ptr + 0x0010 153 | HANDLE_INFORMATION := Map() 154 | loop NumberOfHandles 155 | { 156 | if (NumGet(Addr, 0x0008, "UInt") = ProcessID) 157 | { 158 | HANDLE := Map() 159 | HANDLE["UniqueProcessId"] := NumGet(Addr, 0x0008, "UInt") 160 | HANDLE["HandleValue"] := NumGet(Addr, 0x0010, "UInt") 161 | HANDLE["GrantedAccess"] := NumGet(Addr, 0x0018, "UInt") 162 | HANDLE["HandleAttributes"] := NumGet(Addr, 0x0020, "UInt") 163 | HANDLE_INFORMATION[A_Index] := HANDLE 164 | } 165 | Addr += 0x0028 166 | } 167 | return HANDLE_INFORMATION 168 | } 169 | return false 170 | } 171 | } 172 | 173 | 174 | ; ============================================================================================================================================================= 175 | ; Example 176 | ; ============================================================================================================================================================= 177 | 178 | ProcessID := 1284 179 | 180 | Main := Gui("+Resize +MinSize1024x576") 181 | Main.MarginX := 10 182 | Main.MarginY := 10 183 | LV := Main.AddListView("xm ym w800 r30", ["Handle", "Type", "Name", "Path"]) 184 | for i, v in PH := GetProcessHandles(ProcessID) 185 | LV.Add("", PH[i]["Handle"], PH[i]["Type"], PH[i]["Name"], PH[i]["Path"]) 186 | Main.OnEvent("Close", (*) => ExitApp) 187 | Main.OnEvent("Size", Gui_Size) 188 | Main.Title := LV.GetCount() 189 | Main.Show() 190 | 191 | 192 | Gui_Size(thisGui, MinMax, Width, Height) 193 | { 194 | if (MinMax = -1) 195 | return 196 | LV.Move(,, Width - 20, Height - 20) 197 | LV.Redraw() 198 | } -------------------------------------------------------------------------------- /src/ProcessThreadModule/GetProcessThreads.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author ........: jNizM 3 | ; Released ......: 2016-06-20 4 | ; Modified ......: 2023-01-12 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: GetProcessThreads() 8 | ; 9 | ; Parameter(s)...: ProcessID - The process identifier of the process. 10 | ; 11 | ; Return ........: Retrieves a list of all threads in a process. 12 | ; ============================================================================================================================================================= 13 | 14 | #Requires AutoHotkey v2.0 15 | 16 | 17 | GetProcessThreads(ProcessID) 18 | { 19 | static TH32CS_SNAPTHREAD := 0x00000004 20 | 21 | if !(hSnapshot := DllCall("CreateToolhelp32Snapshot", "UInt", TH32CS_SNAPTHREAD, "UInt", ProcessID, "Ptr")) 22 | throw OSError() 23 | 24 | THREADENTRY32 := Buffer(28) 25 | NumPut("UInt", THREADENTRY32.Size, THREADENTRY32, 0) 26 | if !(DllCall("Thread32First", "Ptr", hSnapshot, "Ptr", THREADENTRY32)) 27 | { 28 | DllCall("CloseHandle", "Ptr", hSnapshot) 29 | throw OSError() 30 | } 31 | 32 | Threads := Array() 33 | while (DllCall("Thread32Next", "Ptr", hSnapshot, "Ptr", THREADENTRY32)) 34 | { 35 | OwnerProcessID := NumGet(THREADENTRY32, 12, "UInt") 36 | if (OwnerProcessID = ProcessID) 37 | { 38 | Threads.Push(NumGet(THREADENTRY32, 8, "UInt")) 39 | } 40 | } 41 | 42 | DllCall("CloseHandle", "Ptr", hSnapshot) 43 | return Threads 44 | } 45 | 46 | 47 | ; ============================================================================================================================================================= 48 | ; Example 49 | ; ============================================================================================================================================================= 50 | 51 | Threads := GetProcessThreads(16084) 52 | loop Threads.Length 53 | MsgBox Threads[A_Index] -------------------------------------------------------------------------------- /src/ProcessThreadModule/GetThreadStartAddr.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author ........: jNizM 3 | ; Released ......: 2016-06-20 4 | ; Modified ......: 2023-01-12 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: GetThreadStartAddr() 8 | ; 9 | ; Parameter(s)...: ProcessID - The process identifier of the process. 10 | ; 11 | ; Return ........: Retrieves the start address of a thread. 12 | ; ============================================================================================================================================================= 13 | 14 | #Requires AutoHotkey v2.0 15 | 16 | 17 | GetThreadStartAddr(ProcessID) 18 | { 19 | #DllLoad "ntdll.dll" 20 | 21 | static TH32CS_SNAPTHREAD := 0x00000004 22 | static THREAD_QUERY_INFORMATION := 0x0040 23 | static ThreadQuerySetWin32StartAddress := 9 24 | 25 | if !(hSnapshot := DllCall("CreateToolhelp32Snapshot", "UInt", TH32CS_SNAPTHREAD, "UInt", ProcessID, "Ptr")) 26 | throw OSError() 27 | 28 | THREADENTRY32 := Buffer(28) 29 | NumPut("UInt", THREADENTRY32.Size, THREADENTRY32, 0) 30 | if !(DllCall("Thread32First", "Ptr", hSnapshot, "Ptr", THREADENTRY32)) 31 | { 32 | DllCall("CloseHandle", "Ptr", hSnapshot) 33 | throw OSError() 34 | } 35 | 36 | StartAddr := Map() 37 | while (DllCall("Thread32Next", "Ptr", hSnapshot, "Ptr", THREADENTRY32)) 38 | { 39 | OwnerProcessID := NumGet(THREADENTRY32, 12, "UInt") 40 | if (OwnerProcessID = ProcessID) 41 | { 42 | ThreadID := NumGet(THREADENTRY32, 8, "UInt") 43 | if !(hThread := DllCall("OpenThread", "UInt", THREAD_QUERY_INFORMATION, "Int", false, "UInt", ThreadID, "Ptr")) 44 | continue 45 | if (DllCall("ntdll\NtQueryInformationThread", "Ptr", hThread, "UInt", ThreadQuerySetWin32StartAddress, "Ptr*", &ThreadStartAddr := 0, "UInt", A_PtrSize, "UInt*", 0) != 0) 46 | continue 47 | StartAddr[ThreadID] := Format("{:#016x}", ThreadStartAddr) 48 | DllCall("CloseHandle", "Ptr", hThread) 49 | } 50 | } 51 | 52 | DllCall("CloseHandle", "Ptr", hSnapshot) 53 | return StartAddr 54 | } 55 | 56 | 57 | ; ============================================================================================================================================================= 58 | ; Example 59 | ; ============================================================================================================================================================= 60 | 61 | for k, v in GetThreadStartAddr(16084) 62 | MsgBox "ThreadID:`t" k "`nStartAddr:`t" v -------------------------------------------------------------------------------- /src/ProcessThreadModule/IsProcessElevated.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author ........: jNizM 3 | ; Released ......: 2017-01-10 4 | ; Modified ......: 2023-01-16 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: IsProcessElevated() 8 | ; 9 | ; Parameter(s)...: ProcessID - The process identifier of the process. 10 | ; 11 | ; Return ........: Retrieves whether a token has elevated privileges. 12 | ; ============================================================================================================================================================= 13 | 14 | #Requires AutoHotkey v2.0 15 | 16 | 17 | IsProcessElevated(ProcessID) 18 | { 19 | static INVALID_HANDLE_VALUE := -1 20 | static PROCESS_QUERY_INFORMATION := 0x0400 21 | static PROCESS_QUERY_LIMITED_INFORMATION := 0x1000 22 | static TOKEN_QUERY := 0x0008 23 | static TOKEN_QUERY_SOURCE := 0x0010 24 | static TokenElevation := 20 25 | 26 | hProcess := DllCall("OpenProcess", "UInt", PROCESS_QUERY_INFORMATION, "Int", False, "UInt", ProcessID, "Ptr") 27 | if (!hProcess) || (hProcess = INVALID_HANDLE_VALUE) 28 | { 29 | hProcess := DllCall("OpenProcess", "UInt", PROCESS_QUERY_LIMITED_INFORMATION, "Int", False, "UInt", ProcessID, "Ptr") 30 | if (!hProcess) || (hProcess = INVALID_HANDLE_VALUE) 31 | throw OSError() 32 | } 33 | 34 | if !(DllCall("advapi32\OpenProcessToken", "Ptr", hProcess, "UInt", TOKEN_QUERY | TOKEN_QUERY_SOURCE, "Ptr*", &hToken := 0)) 35 | { 36 | DllCall("CloseHandle", "Ptr", hProcess) 37 | throw OSError() 38 | } 39 | 40 | if !(DllCall("advapi32\GetTokenInformation", "Ptr", hToken, "Int", TokenElevation, "UInt*", &IsElevated := 0, "UInt", 4, "UInt*", &Size := 0)) 41 | { 42 | DllCall("CloseHandle", "Ptr", hToken) 43 | DllCall("CloseHandle", "Ptr", hProcess) 44 | throw OSError() 45 | } 46 | 47 | DllCall("CloseHandle", "Ptr", hToken) 48 | DllCall("CloseHandle", "Ptr", hProcess) 49 | return IsElevated 50 | } 51 | 52 | 53 | ; ============================================================================================================================================================= 54 | ; Example 55 | ; ============================================================================================================================================================= 56 | 57 | MsgBox IsProcessElevated(19256) -------------------------------------------------------------------------------- /src/Strings/Base64ToString.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author ........: jNizM 3 | ; Released ......: 2016-10-21 4 | ; Modified ......: 2023-01-13 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: Base64ToString() 8 | ; 9 | ; Parameter(s)...: Base64 - encoded string 10 | ; 11 | ; Return ........: Converts a base64 string to a readable string. 12 | ; ============================================================================================================================================================= 13 | 14 | #Requires AutoHotkey v2.0 15 | 16 | 17 | Base64ToString(Base64) 18 | { 19 | static CRYPT_STRING_BASE64 := 0x00000001 20 | 21 | if !(DllCall("crypt32\CryptStringToBinaryW", "Str", Base64, "UInt", 0, "UInt", CRYPT_STRING_BASE64, "Ptr", 0, "UInt*", &Size := 0, "Ptr", 0, "Ptr", 0)) 22 | throw OSError() 23 | 24 | String := Buffer(Size) 25 | if !(DllCall("crypt32\CryptStringToBinaryW", "Str", Base64, "UInt", 0, "UInt", CRYPT_STRING_BASE64, "Ptr", String, "UInt*", Size, "Ptr", 0, "Ptr", 0)) 26 | throw OSError() 27 | 28 | return StrGet(String, "UTF-8") 29 | } 30 | 31 | 32 | ; ============================================================================================================================================================= 33 | ; Example 34 | ; ============================================================================================================================================================= 35 | 36 | MsgBox Base64ToString("VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw==") ; => The quick brown fox jumps over the lazy dog -------------------------------------------------------------------------------- /src/Strings/CountLeadingChar.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author ........: jNizM 3 | ; Released ......: 2021-12-03 4 | ; Modified ......: 2023-01-13 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: GetModuleBaseAddr() 8 | ; 9 | ; Parameter(s)...: String 10 | ; Char (Leading Char) 11 | ; 12 | ; Return ........: Count how often a certain character occurs at the beginning of a string. 13 | ; ============================================================================================================================================================= 14 | 15 | #Requires AutoHotkey v2.0 16 | 17 | 18 | CountLeadingChar(String, Char) 19 | { 20 | Match := 0 21 | loop StrLen(String) 22 | { 23 | if !(InStr(SubStr(String, 1 + Match, 1), Char)) 24 | break 25 | Match++ 26 | } 27 | return Match 28 | } 29 | 30 | 31 | ; ============================================================================================================================================================= 32 | ; Example 33 | ; ============================================================================================================================================================= 34 | 35 | MsgBox CountLeadingChar("000000013370", "0") ; -> 7 -------------------------------------------------------------------------------- /src/Strings/GetCurrencyFormat.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author ........: jNizM 3 | ; Released ......: 2015-11-02 4 | ; Modified ......: 2023-01-13 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: GetCurrencyFormat() 8 | ; 9 | ; Parameter(s)...: Value 10 | ; Locale Identifier (32-bit value - see https://learn.microsoft.com/en-us/windows/win32/intl/locale-identifiers) 11 | ; 12 | ; Return ........: Formats a number string as a currency string for a locale specified by name. 13 | ; ============================================================================================================================================================= 14 | 15 | #Requires AutoHotkey v2.0 16 | 17 | 18 | GetCurrencyFormat(Value, Locale := 0x0400) 19 | { 20 | if (Size := DllCall("GetCurrencyFormatW", "UInt", Locale, "UInt", 0, "Str", Value, "Ptr", 0, "Ptr", 0, "Int", 0)) 21 | { 22 | Size := VarSetStrCapacity(&CurrencyStr, Size) 23 | if (Size := DllCall("GetCurrencyFormatW", "UInt", Locale, "UInt", 0, "Str", Value, "Ptr", 0, "Str", CurrencyStr, "Int", Size)) 24 | { 25 | return CurrencyStr 26 | } 27 | } 28 | return 29 | } 30 | 31 | 32 | ; ============================================================================================================================================================= 33 | ; Example 34 | ; ============================================================================================================================================================= 35 | 36 | MsgBox GetCurrencyFormat(1149.99) ; 1.149,99 € ( LANG_USER_DEFAULT | SUBLANG_DEFAULT ) (for me it is german) 37 | MsgBox GetCurrencyFormat(1149.99, 0x0409) ; $1,149.99 ( LANG_ENGLISH | SUBLANG_ENGLISH_US ) 38 | MsgBox GetCurrencyFormat(1149.99, 0x0809) ; £1,149.99 ( LANG_ENGLISH | SUBLANG_ENGLISH_UK ) 39 | MsgBox GetCurrencyFormat(1149.99, 0x0407) ; 1.149,99 € ( LANG_GERMAN | SUBLANG_GERMAN ) -------------------------------------------------------------------------------- /src/Strings/GetCurrencyFormatEx.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author ........: jNizM 3 | ; Released ......: 2015-11-02 4 | ; Modified ......: 2023-01-13 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: GetCurrencyFormatEx() 8 | ; 9 | ; Parameter(s)...: Value 10 | ; Locale Name (- - see https://learn.microsoft.com/en-us/windows/win32/intl/locale-names) 11 | ; 12 | ; Return ........: Formats a number string as a currency string for a locale specified by name. 13 | ; ============================================================================================================================================================= 14 | 15 | #Requires AutoHotkey v2.0 16 | 17 | 18 | GetCurrencyFormatEx(Value, LocaleName := "!x-sys-default-locale") 19 | { 20 | if (Size := DllCall("GetCurrencyFormatEx", "Str", LocaleName, "UInt", 0, "Str", Value, "Ptr", 0, "Ptr", 0, "Int", 0)) 21 | { 22 | Size := VarSetStrCapacity(&CurrencyStr, Size) 23 | if (Size := DllCall("GetCurrencyFormatEx", "Str", LocaleName, "UInt", 0, "Str", Value, "Ptr", 0, "Str", CurrencyStr, "Int", Size)) 24 | { 25 | return CurrencyStr 26 | } 27 | } 28 | return 29 | } 30 | 31 | 32 | ; ============================================================================================================================================================= 33 | ; Example 34 | ; ============================================================================================================================================================= 35 | 36 | MsgBox GetCurrencyFormatEx(1149.99) ; 1.149,99 € ( LANG_USER_DEFAULT | SUBLANG_DEFAULT ) (for me it is german) 37 | MsgBox GetCurrencyFormatEx(1149.99, "en-US") ; $1,149.99 ( LANG_ENGLISH | SUBLANG_ENGLISH_US ) 38 | MsgBox GetCurrencyFormatEx(1149.99, "en-GB") ; £1,149.99 ( LANG_ENGLISH | SUBLANG_ENGLISH_UK ) 39 | MsgBox GetCurrencyFormatEx(1149.99, "de-DE") ; 1.149,99 € ( LANG_GERMAN | SUBLANG_GERMAN ) -------------------------------------------------------------------------------- /src/Strings/GetDurationFormat.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author ........: jNizM 3 | ; Released ......: 2015-11-02 4 | ; Modified ......: 2023-01-13 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: GetDurationFormat() 8 | ; 9 | ; Parameter(s)...: Duration 10 | ; Format 11 | ; Locale Identifier (32-bit value - see https://learn.microsoft.com/en-us/windows/win32/intl/locale-identifiers) 12 | ; 13 | ; Return ........: Formats a duration of time as a time string for a locale specified by identifier. (Duration * 10000 = in ms | Duration * 10000000 = in sec) 14 | ; ============================================================================================================================================================= 15 | 16 | #Requires AutoHotkey v2.0 17 | 18 | 19 | GetDurationFormat(Duration, Format := "", Locale := 0x0400) 20 | { 21 | if (Size := DllCall("GetDurationFormat", "UInt", Locale, "UInt", 0, "Ptr", 0, "Int64", Duration * 10000, "Ptr", (Format ? StrPtr(Format) : 0), "Ptr", 0, "Int", 0)) 22 | { 23 | Size := VarSetStrCapacity(&DurationStr, Size) 24 | if (Size := DllCall("GetDurationFormat", "UInt", Locale, "UInt", 0, "Ptr", 0, "Int64", Duration * 10000, "Ptr", (Format ? StrPtr(Format) : 0), "Str", DurationStr, "Int", Size)) 25 | { 26 | return DurationStr 27 | } 28 | } 29 | return 30 | } 31 | 32 | 33 | ; ============================================================================================================================================================= 34 | ; Example 35 | ; ============================================================================================================================================================= 36 | 37 | MsgBox GetDurationFormat(817000) ; 13:37 38 | MsgBox GetDurationFormat(421337, "hh:mm:ss.fff") ; 00:07:01.337 39 | MsgBox GetDurationFormat(2520000, "mm' Minutes") ; 42 Minutes 40 | MsgBox GetDurationFormat(43140000, "hh' Hours and 'mm' Minutes") ; 11 Hours and 59 Minutes -------------------------------------------------------------------------------- /src/Strings/GetDurationFormatEx.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author ........: jNizM 3 | ; Released ......: 2015-11-02 4 | ; Modified ......: 2023-01-13 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: GetDurationFormatEx() 8 | ; 9 | ; Parameter(s)...: Duration 10 | ; Format 11 | ; Locale Name (- - see https://learn.microsoft.com/en-us/windows/win32/intl/locale-names) 12 | ; 13 | ; Return ........: Formats a duration of time as a time string for a locale specified by name. (Duration * 10000 = in ms | Duration * 10000000 = in sec) 14 | ; ============================================================================================================================================================= 15 | 16 | #Requires AutoHotkey v2.0 17 | 18 | 19 | GetDurationFormatEx(Duration, Format := "", LocaleName := "!x-sys-default-locale") 20 | { 21 | if (Size := DllCall("GetDurationFormatEx", "Str", LocaleName, "UInt", 0, "Ptr", 0, "Int64", Duration * 10000, "Ptr", (Format ? StrPtr(Format) : 0), "Ptr", 0, "Int", 0)) 22 | { 23 | Size := VarSetStrCapacity(&DurationStr, Size) 24 | if (Size := DllCall("GetDurationFormatEx", "Str", LocaleName, "UInt", 0, "Ptr", 0, "Int64", Duration * 10000, "Ptr", (Format ? StrPtr(Format) : 0), "Str", DurationStr, "Int", Size)) 25 | { 26 | return DurationStr 27 | } 28 | } 29 | return 30 | } 31 | 32 | 33 | ; ============================================================================================================================================================= 34 | ; Example 35 | ; ============================================================================================================================================================= 36 | 37 | MsgBox GetDurationFormatEx(817000) ; 13:37 38 | MsgBox GetDurationFormatEx(421337, "hh:mm:ss.fff") ; 00:07:01.337 39 | MsgBox GetDurationFormatEx(2520000, "mm' Minutes") ; 42 Minutes 40 | MsgBox GetDurationFormatEx(43140000, "hh' Hours and 'mm' Minutes") ; 11 Hours and 59 Minutes -------------------------------------------------------------------------------- /src/Strings/GetNumberFormat.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author ........: jNizM 3 | ; Released ......: 2015-11-02 4 | ; Modified ......: 2023-01-13 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: GetNumberFormat() 8 | ; 9 | ; Parameter(s)...: Value 10 | ; Locale Identifier (32-bit value - see https://learn.microsoft.com/en-us/windows/win32/intl/locale-identifiers) 11 | ; 12 | ; Return ........: Formats a number string as a number string customized for a locale specified by identifier. 13 | ; ============================================================================================================================================================= 14 | 15 | #Requires AutoHotkey v2.0 16 | 17 | 18 | GetNumberFormat(Value, Locale := 0x0400) 19 | { 20 | if (Size := DllCall("GetNumberFormatW", "UInt", Locale, "UInt", 0, "Str", Value, "Ptr", 0, "Ptr", 0, "Int", 0)) 21 | { 22 | Size := VarSetStrCapacity(&NumberStr, Size) 23 | if (Size := DllCall("GetNumberFormatW", "UInt", Locale, "UInt", 0, "Str", Value, "Ptr", 0, "Str", NumberStr, "Int", Size)) 24 | { 25 | return NumberStr 26 | } 27 | } 28 | return 29 | } 30 | 31 | 32 | ; ============================================================================================================================================================= 33 | ; Example 34 | ; ============================================================================================================================================================= 35 | 36 | MsgBox GetNumberFormat(1149.99) ; 1.149,99 ( LANG_USER_DEFAULT | SUBLANG_DEFAULT ) (for me it is german) 37 | MsgBox GetNumberFormat(1149.99, 0x0409) ; 1,149.99 ( LANG_ENGLISH | SUBLANG_ENGLISH_US ) 38 | MsgBox GetNumberFormat(1149.99, 0x0809) ; 1,149.99 ( LANG_ENGLISH | SUBLANG_ENGLISH_UK ) 39 | MsgBox GetNumberFormat(1149.99, 0x0407) ; 1.149,99 ( LANG_GERMAN | SUBLANG_GERMAN ) -------------------------------------------------------------------------------- /src/Strings/GetNumberFormatEx.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author ........: jNizM 3 | ; Released ......: 2015-11-02 4 | ; Modified ......: 2023-01-13 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: GetNumberFormatEx() 8 | ; 9 | ; Parameter(s)...: Value 10 | ; Locale Name (- - see https://learn.microsoft.com/en-us/windows/win32/intl/locale-names) 11 | ; 12 | ; Return ........: Formats a number string as a number string customized for a locale specified by name. 13 | ; ============================================================================================================================================================= 14 | 15 | #Requires AutoHotkey v2.0 16 | 17 | 18 | GetNumberFormatEx(Value, LocaleName := "!x-sys-default-locale") 19 | { 20 | if (Size := DllCall("GetNumberFormatEx", "Str", LocaleName, "UInt", 0, "Str", Value, "Ptr", 0, "Ptr", 0, "Int", 0)) 21 | { 22 | Size := VarSetStrCapacity(&NumberStr, Size) 23 | if (Size := DllCall("GetNumberFormatEx", "Str", LocaleName, "UInt", 0, "Str", Value, "Ptr", 0, "Str", NumberStr, "Int", Size)) 24 | { 25 | return NumberStr 26 | } 27 | } 28 | return 29 | } 30 | 31 | 32 | ; ============================================================================================================================================================= 33 | ; Example 34 | ; ============================================================================================================================================================= 35 | 36 | MsgBox GetNumberFormatEx(1149.99) ; 1.149,99 ( LANG_USER_DEFAULT | SUBLANG_DEFAULT ) (for me it is german) 37 | MsgBox GetNumberFormatEx(1149.99, "en-US") ; 1,149.99 ( LANG_ENGLISH | SUBLANG_ENGLISH_US ) 38 | MsgBox GetNumberFormatEx(1149.99, "en-GB") ; 1,149.99 ( LANG_ENGLISH | SUBLANG_ENGLISH_UK ) 39 | MsgBox GetNumberFormatEx(1149.99, "de-DE") ; 1.149,99 ( LANG_GERMAN | SUBLANG_GERMAN ) -------------------------------------------------------------------------------- /src/Strings/StringToBase64.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author ........: jNizM 3 | ; Released ......: 2016-10-21 4 | ; Modified ......: 2023-01-13 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: StringToBase64() 8 | ; 9 | ; Parameter(s)...: String 10 | ; Encoding (default = UTF-8) 11 | ; 12 | ; Return ........: Converts a readable string to a base64 string. 13 | ; ============================================================================================================================================================= 14 | 15 | #Requires AutoHotkey v2.0 16 | 17 | 18 | StringToBase64(String, Encoding := "UTF-8") 19 | { 20 | static CRYPT_STRING_BASE64 := 0x00000001 21 | static CRYPT_STRING_NOCRLF := 0x40000000 22 | 23 | Binary := Buffer(StrPut(String, Encoding)) 24 | StrPut(String, Binary, Encoding) 25 | if !(DllCall("crypt32\CryptBinaryToStringW", "Ptr", Binary, "UInt", Binary.Size - 1, "UInt", (CRYPT_STRING_BASE64 | CRYPT_STRING_NOCRLF), "Ptr", 0, "UInt*", &Size := 0)) 26 | throw OSError() 27 | 28 | Base64 := Buffer(Size << 1, 0) 29 | if !(DllCall("crypt32\CryptBinaryToStringW", "Ptr", Binary, "UInt", Binary.Size - 1, "UInt", (CRYPT_STRING_BASE64 | CRYPT_STRING_NOCRLF), "Ptr", Base64, "UInt*", Size)) 30 | throw OSError() 31 | 32 | return StrGet(Base64) 33 | } 34 | 35 | 36 | ; ============================================================================================================================================================= 37 | ; Example 38 | ; ============================================================================================================================================================= 39 | 40 | MsgBox StringToBase64("The quick brown fox jumps over the lazy dog") ; => VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw== 41 | -------------------------------------------------------------------------------- /src/SystemInformation/SystemDeviceInformation.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author ........: jNizM 3 | ; Released ......: 2021-12-22 4 | ; Modified ......: 2023-01-13 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: SystemDeviceInformation() 8 | ; 9 | ; Parameter(s)...: No parameters used 10 | ; 11 | ; Return ........: Returns a SYSTEM_DEVICE_INFORMATION structure from the NtQuerySystemInformation function. 12 | ; ============================================================================================================================================================= 13 | 14 | #Requires AutoHotkey v2.0 15 | 16 | 17 | SystemDeviceInformation() 18 | { 19 | #DllLoad "ntdll.dll" 20 | 21 | static STATUS_SUCCESS := 0x00000000 22 | static STATUS_INFO_LENGTH_MISMATCH := 0xC0000004 23 | static STATUS_BUFFER_TOO_SMALL := 0xC0000023 24 | static SYSTEM_DEVICE_INFORMATION := 0x00000007 25 | 26 | Buf := Buffer(0x0018) 27 | NT_STATUS := DllCall("ntdll\NtQuerySystemInformation", "Int", SYSTEM_DEVICE_INFORMATION, "Ptr", Buf.Ptr, "UInt", Buf.Size, "UInt*", &Size := 0, "UInt") 28 | 29 | while (NT_STATUS = STATUS_INFO_LENGTH_MISMATCH) || (NT_STATUS = STATUS_BUFFER_TOO_SMALL) 30 | { 31 | Buf := Buffer(Size) 32 | NT_STATUS := DllCall("ntdll\NtQuerySystemInformation", "Int", SYSTEM_DEVICE_INFORMATION, "Ptr", Buf.Ptr, "UInt", Buf.Size, "UInt*", &Size := 0, "UInt") 33 | } 34 | 35 | if (NT_STATUS = STATUS_SUCCESS) 36 | { 37 | DEVICE_INFORMATION := Map() 38 | DEVICE_INFORMATION["NumberOfDisks"] := NumGet(Buf, 0x0000, "UInt") 39 | DEVICE_INFORMATION["NumberOfFloppies"] := NumGet(Buf, 0x0004, "UInt") 40 | DEVICE_INFORMATION["NumberOfCdRoms"] := NumGet(Buf, 0x0008, "UInt") 41 | DEVICE_INFORMATION["NumberOfTapes"] := NumGet(Buf, 0x000C, "UInt") 42 | DEVICE_INFORMATION["NumberOfSerialPorts"] := NumGet(Buf, 0x0010, "UInt") 43 | DEVICE_INFORMATION["NumberOfParallelPorts"] := NumGet(Buf, 0x0014, "UInt") 44 | return DEVICE_INFORMATION 45 | } 46 | 47 | throw OSError() 48 | } 49 | 50 | 51 | ; ============================================================================================================================================================= 52 | ; Example 53 | ; ============================================================================================================================================================= 54 | 55 | MsgBox SystemDeviceInformation()["NumberOfDisks"] -------------------------------------------------------------------------------- /src/SystemInformation/SystemHandleInformation.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author ........: jNizM 3 | ; Released ......: 2021-12-22 4 | ; Modified ......: 2023-01-13 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: SystemHandleInformation() 8 | ; 9 | ; Parameter(s)...: No parameters used 10 | ; 11 | ; Return ........: Returns a SYSTEM_DEVICE_INFORMATION structure from the NtQuerySystemInformation function. 12 | ; ============================================================================================================================================================= 13 | 14 | #Requires AutoHotkey v2.0 15 | 16 | 17 | SystemHandleInformation() 18 | { 19 | #DllLoad "ntdll.dll" 20 | 21 | static STATUS_SUCCESS := 0x00000000 22 | static STATUS_INFO_LENGTH_MISMATCH := 0xC0000004 23 | static STATUS_BUFFER_TOO_SMALL := 0xC0000023 24 | static SYSTEM_HANDLE_INFORMATION := 0x00000010 25 | 26 | Buf := Buffer(0x0018) 27 | NT_STATUS := DllCall("ntdll\NtQuerySystemInformation", "Int", SYSTEM_HANDLE_INFORMATION, "Ptr", Buf.Ptr, "UInt", Buf.Size, "UInt*", &Size := 0, "UInt") 28 | 29 | while (NT_STATUS = STATUS_INFO_LENGTH_MISMATCH) || (NT_STATUS = STATUS_BUFFER_TOO_SMALL) 30 | { 31 | Buf := Buffer(Size) 32 | NT_STATUS := DllCall("ntdll\NtQuerySystemInformation", "Int", SYSTEM_HANDLE_INFORMATION, "Ptr", Buf.Ptr, "UInt", Buf.Size, "UInt*", &Size := 0, "UInt") 33 | } 34 | 35 | if (NT_STATUS = STATUS_SUCCESS) 36 | { 37 | HANDLE_INFORMATION := Map() 38 | HANDLE_INFORMATION["NumberOfHandles"] := NumGet(Buf, 0x0000, "UInt") 39 | Addr := Buf.Ptr + 0x0008 40 | loop HANDLE_INFORMATION["NumberOfHandles"] 41 | { 42 | HANDLE := Map() 43 | HANDLE["UniqueProcessId"] := NumGet(Addr, 0x0000, "UShort") 44 | HANDLE["CreatorBackTraceIndex"] := NumGet(Addr, 0x0002, "UShort") 45 | HANDLE["ObjectTypeIndex"] := NumGet(Addr, 0x0004, "UChar") 46 | HANDLE["HandleAttributes"] := NumGet(Addr, 0x0005, "UChar") 47 | HANDLE["HandleValue"] := NumGet(Addr, 0x0006, "UShort") 48 | HANDLE["Object"] := NumGet(Addr, 0x0008, "Ptr*") 49 | HANDLE["GrantedAccess"] := NumGet(Addr, 0x0010, "UInt") 50 | HANDLE_INFORMATION[A_Index] := HANDLE 51 | Addr += 0x0018 52 | } 53 | 54 | return HANDLE_INFORMATION 55 | } 56 | 57 | throw OSError() 58 | } 59 | 60 | 61 | ; ============================================================================================================================================================= 62 | ; Example 63 | ; ============================================================================================================================================================= 64 | 65 | MsgBox SystemHandleInformation()["NumberOfHandles"] 66 | 67 | Handle := SystemHandleInformation() 68 | for i, v in Handle { 69 | for k, v in Handle[i] 70 | MsgBox k ": " v 71 | } -------------------------------------------------------------------------------- /src/SystemInformation/SystemPerformanceInformation.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author ........: jNizM 3 | ; Released ......: 2021-12-22 4 | ; Modified ......: 2023-01-13 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: SystemPerformanceInformation() 8 | ; 9 | ; Parameter(s)...: No parameters used 10 | ; 11 | ; Return ........: Returns a SYSTEM_PERFORMANCE_INFORMATION structure from the NtQuerySystemInformation function. 12 | ; ============================================================================================================================================================= 13 | 14 | #Requires AutoHotkey v2.0 15 | 16 | 17 | SystemPerformanceInformation() 18 | { 19 | #DllLoad "ntdll.dll" 20 | 21 | static STATUS_SUCCESS := 0x00000000 22 | static STATUS_INFO_LENGTH_MISMATCH := 0xC0000004 23 | static STATUS_BUFFER_TOO_SMALL := 0xC0000023 24 | static SYSTEM_PERFORMANCE_INFORMATION := 0x00000002 25 | 26 | Buf := Buffer(0x0158) 27 | NT_STATUS := DllCall("ntdll\NtQuerySystemInformation", "Int", SYSTEM_PERFORMANCE_INFORMATION, "Ptr", Buf.Ptr, "UInt", Buf.Size, "UInt*", &Size := 0, "UInt") 28 | 29 | while (NT_STATUS = STATUS_INFO_LENGTH_MISMATCH) || (NT_STATUS = STATUS_BUFFER_TOO_SMALL) 30 | { 31 | Buf := Buffer(Size) 32 | NT_STATUS := DllCall("ntdll\NtQuerySystemInformation", "Int", SYSTEM_PERFORMANCE_INFORMATION, "Ptr", Buf.Ptr, "UInt", Buf.Size, "UInt*", &Size := 0, "UInt") 33 | } 34 | 35 | if (NT_STATUS = STATUS_SUCCESS) 36 | { 37 | PERFORMANCE_INFORMATION := Map() 38 | PERFORMANCE_INFORMATION["IdleProcessTime"] := NumGet(Buf, 0x0000, "Int64") 39 | PERFORMANCE_INFORMATION["IoReadTransferCount"] := NumGet(Buf, 0x0008, "Int64") 40 | PERFORMANCE_INFORMATION["IoWriteTransferCount"] := NumGet(Buf, 0x0010, "Int64") 41 | PERFORMANCE_INFORMATION["IoOtherTransferCount"] := NumGet(Buf, 0x0018, "Int64") 42 | PERFORMANCE_INFORMATION["IoReadOperationCount"] := NumGet(Buf, 0x0020, "UInt") 43 | PERFORMANCE_INFORMATION["IoWriteOperationCount"] := NumGet(Buf, 0x0024, "UInt") 44 | PERFORMANCE_INFORMATION["IoOtherOperationCount"] := NumGet(Buf, 0x0028, "UInt") 45 | PERFORMANCE_INFORMATION["AvailablePages"] := NumGet(Buf, 0x002C, "UInt") 46 | PERFORMANCE_INFORMATION["CommittedPages"] := NumGet(Buf, 0x0030, "UInt") 47 | PERFORMANCE_INFORMATION["CommitLimit"] := NumGet(Buf, 0x0034, "UInt") 48 | PERFORMANCE_INFORMATION["PeakCommitment"] := NumGet(Buf, 0x0038, "UInt") 49 | PERFORMANCE_INFORMATION["PageFaultCount"] := NumGet(Buf, 0x003C, "UInt") 50 | PERFORMANCE_INFORMATION["CopyOnWriteCount"] := NumGet(Buf, 0x0040, "UInt") 51 | PERFORMANCE_INFORMATION["TransitionCount"] := NumGet(Buf, 0x0044, "UInt") 52 | PERFORMANCE_INFORMATION["CacheTransitionCount"] := NumGet(Buf, 0x0048, "UInt") 53 | PERFORMANCE_INFORMATION["DemandZeroCount"] := NumGet(Buf, 0x004C, "UInt") 54 | PERFORMANCE_INFORMATION["PageReadCount"] := NumGet(Buf, 0x0050, "UInt") 55 | PERFORMANCE_INFORMATION["PageReadIoCount"] := NumGet(Buf, 0x0054, "UInt") 56 | PERFORMANCE_INFORMATION["CacheReadCount"] := NumGet(Buf, 0x0058, "UInt") 57 | PERFORMANCE_INFORMATION["CacheIoCount"] := NumGet(Buf, 0x005C, "UInt") 58 | PERFORMANCE_INFORMATION["DirtyPagesWriteCount"] := NumGet(Buf, 0x0060, "UInt") 59 | PERFORMANCE_INFORMATION["DirtyWriteIoCount"] := NumGet(Buf, 0x0064, "UInt") 60 | PERFORMANCE_INFORMATION["MappedPagesWriteCount"] := NumGet(Buf, 0x0068, "UInt") 61 | PERFORMANCE_INFORMATION["MappedWriteIoCount"] := NumGet(Buf, 0x006C, "UInt") 62 | PERFORMANCE_INFORMATION["PagedPoolPages"] := NumGet(Buf, 0x0070, "UInt") 63 | PERFORMANCE_INFORMATION["NonPagedPoolPages"] := NumGet(Buf, 0x0074, "UInt") 64 | PERFORMANCE_INFORMATION["PagedPoolAllocs"] := NumGet(Buf, 0x0078, "UInt") 65 | PERFORMANCE_INFORMATION["PagedPoolFrees"] := NumGet(Buf, 0x007C, "UInt") 66 | PERFORMANCE_INFORMATION["NonPagedPoolAllocs"] := NumGet(Buf, 0x0080, "UInt") 67 | PERFORMANCE_INFORMATION["NonPagedPoolFrees"] := NumGet(Buf, 0x0084, "UInt") 68 | PERFORMANCE_INFORMATION["FreeSystemPtes"] := NumGet(Buf, 0x0088, "UInt") 69 | PERFORMANCE_INFORMATION["ResidentSystemCodePage"] := NumGet(Buf, 0x008C, "UInt") 70 | PERFORMANCE_INFORMATION["TotalSystemDriverPages"] := NumGet(Buf, 0x0090, "UInt") 71 | PERFORMANCE_INFORMATION["TotalSystemCodePages"] := NumGet(Buf, 0x0094, "UInt") 72 | PERFORMANCE_INFORMATION["NonPagedPoolLookasideHits"] := NumGet(Buf, 0x0098, "UInt") 73 | PERFORMANCE_INFORMATION["PagedPoolLookasideHits"] := NumGet(Buf, 0x009C, "UInt") 74 | PERFORMANCE_INFORMATION["AvailablePagedPoolPages"] := NumGet(Buf, 0x00A0, "UInt") 75 | PERFORMANCE_INFORMATION["ResidentSystemCachePage"] := NumGet(Buf, 0x00A4, "UInt") 76 | PERFORMANCE_INFORMATION["ResidentPagedPoolPage"] := NumGet(Buf, 0x00A8, "UInt") 77 | PERFORMANCE_INFORMATION["ResidentSystemDriverPage"] := NumGet(Buf, 0x00AC, "UInt") 78 | PERFORMANCE_INFORMATION["CcFastReadNoWait"] := NumGet(Buf, 0x00B0, "UInt") 79 | PERFORMANCE_INFORMATION["CcFastReadWait"] := NumGet(Buf, 0x00B4, "UInt") 80 | PERFORMANCE_INFORMATION["CcFastReadResourceMiss"] := NumGet(Buf, 0x00B8, "UInt") 81 | PERFORMANCE_INFORMATION["CcFastReadNotPossible"] := NumGet(Buf, 0x00BC, "UInt") 82 | PERFORMANCE_INFORMATION["CcFastMdlReadNoWait"] := NumGet(Buf, 0x00C0, "UInt") 83 | PERFORMANCE_INFORMATION["CcFastMdlReadWait"] := NumGet(Buf, 0x00C4, "UInt") 84 | PERFORMANCE_INFORMATION["CcFastMdlReadResourceMiss"] := NumGet(Buf, 0x00C8, "UInt") 85 | PERFORMANCE_INFORMATION["CcFastMdlReadNotPossible"] := NumGet(Buf, 0x00CC, "UInt") 86 | PERFORMANCE_INFORMATION["CcMapDataNoWait"] := NumGet(Buf, 0x00D0, "UInt") 87 | PERFORMANCE_INFORMATION["CcMapDataWait"] := NumGet(Buf, 0x00D4, "UInt") 88 | PERFORMANCE_INFORMATION["CcMapDataNoWaitMiss"] := NumGet(Buf, 0x00D8, "UInt") 89 | PERFORMANCE_INFORMATION["CcMapDataWaitMiss"] := NumGet(Buf, 0x00DC, "UInt") 90 | PERFORMANCE_INFORMATION["CcPinMappedDataCount"] := NumGet(Buf, 0x00E0, "UInt") 91 | PERFORMANCE_INFORMATION["CcPinReadNoWait"] := NumGet(Buf, 0x00E4, "UInt") 92 | PERFORMANCE_INFORMATION["CcPinReadWait"] := NumGet(Buf, 0x00E8, "UInt") 93 | PERFORMANCE_INFORMATION["CcPinReadNoWaitMiss"] := NumGet(Buf, 0x00EC, "UInt") 94 | PERFORMANCE_INFORMATION["CcPinReadWaitMiss"] := NumGet(Buf, 0x00F0, "UInt") 95 | PERFORMANCE_INFORMATION["CcCopyReadNoWait"] := NumGet(Buf, 0x00F4, "UInt") 96 | PERFORMANCE_INFORMATION["CcCopyReadWait"] := NumGet(Buf, 0x00F8, "UInt") 97 | PERFORMANCE_INFORMATION["CcCopyReadNoWaitMiss"] := NumGet(Buf, 0x00FC, "UInt") 98 | PERFORMANCE_INFORMATION["CcCopyReadWaitMiss"] := NumGet(Buf, 0x0100, "UInt") 99 | PERFORMANCE_INFORMATION["CcMdlReadNoWait"] := NumGet(Buf, 0x0104, "UInt") 100 | PERFORMANCE_INFORMATION["CcMdlReadWait"] := NumGet(Buf, 0x0108, "UInt") 101 | PERFORMANCE_INFORMATION["CcMdlReadNoWaitMiss"] := NumGet(Buf, 0x010C, "UInt") 102 | PERFORMANCE_INFORMATION["CcMdlReadWaitMiss"] := NumGet(Buf, 0x0110, "UInt") 103 | PERFORMANCE_INFORMATION["CcReadAheadIos"] := NumGet(Buf, 0x0114, "UInt") 104 | PERFORMANCE_INFORMATION["CcLazyWriteIos"] := NumGet(Buf, 0x0118, "UInt") 105 | PERFORMANCE_INFORMATION["CcLazyWritePages"] := NumGet(Buf, 0x011C, "UInt") 106 | PERFORMANCE_INFORMATION["CcDataFlushes"] := NumGet(Buf, 0x0120, "UInt") 107 | PERFORMANCE_INFORMATION["CcDataPages"] := NumGet(Buf, 0x0124, "UInt") 108 | PERFORMANCE_INFORMATION["ContextSwitches"] := NumGet(Buf, 0x0128, "UInt") 109 | PERFORMANCE_INFORMATION["FirstLevelTbFills"] := NumGet(Buf, 0x012C, "UInt") 110 | PERFORMANCE_INFORMATION["SecondLevelTbFills"] := NumGet(Buf, 0x0130, "UInt") 111 | PERFORMANCE_INFORMATION["SystemCalls"] := NumGet(Buf, 0x0134, "UInt") 112 | PERFORMANCE_INFORMATION["CcTotalDirtyPages"] := NumGet(Buf, 0x0138, "UInt64") 113 | PERFORMANCE_INFORMATION["CcDirtyPageThreshold"] := NumGet(Buf, 0x0140, "UInt64") 114 | PERFORMANCE_INFORMATION["ResidentAvailablePages"] := NumGet(Buf, 0x0148, "Int64") 115 | PERFORMANCE_INFORMATION["SharedCommittedPages"] := NumGet(Buf, 0x0150, "UInt64") 116 | return PERFORMANCE_INFORMATION 117 | } 118 | 119 | throw OSError() 120 | } 121 | 122 | 123 | ; ============================================================================================================================================================= 124 | ; Example 125 | ; ============================================================================================================================================================= 126 | 127 | MsgBox SystemPerformanceInformation()["SystemCalls"] -------------------------------------------------------------------------------- /src/SystemInformation/SystemProcessInformation.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author ........: jNizM 3 | ; Released ......: 2021-12-22 4 | ; Modified ......: 2023-01-13 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: SystemProcessInformation() 8 | ; 9 | ; Parameter(s)...: [Optional] ProcessID or ProcessName 10 | ; 11 | ; Return ........: Returns a SYSTEM_PROCESS_INFORMATION structure from the NtQuerySystemInformation function. 12 | ; ============================================================================================================================================================= 13 | 14 | #Requires AutoHotkey v2.0 15 | 16 | 17 | SystemProcessInformation(Process?) 18 | { 19 | #DllLoad "ntdll.dll" 20 | 21 | static STATUS_SUCCESS := 0x00000000 22 | static STATUS_INFO_LENGTH_MISMATCH := 0xC0000004 23 | static STATUS_BUFFER_TOO_SMALL := 0xC0000023 24 | static SYSTEM_PROCESS_INFORMATION := 0x00000005 25 | 26 | Buf := Buffer(0x0100) 27 | NT_STATUS := DllCall("ntdll\NtQuerySystemInformation", "Int", SYSTEM_PROCESS_INFORMATION, "Ptr", Buf.Ptr, "UInt", Buf.Size, "UInt*", &Size := 0, "UInt") 28 | 29 | while (NT_STATUS = STATUS_INFO_LENGTH_MISMATCH) || (NT_STATUS = STATUS_BUFFER_TOO_SMALL) 30 | { 31 | Buf := Buffer(Size) 32 | NT_STATUS := DllCall("ntdll\NtQuerySystemInformation", "Int", SYSTEM_PROCESS_INFORMATION, "Ptr", Buf.Ptr, "UInt", Buf.Size, "UInt*", &Size := 0, "UInt") 33 | } 34 | 35 | if (NT_STATUS = STATUS_SUCCESS) 36 | { 37 | PROCESS_INFORMATION := Map() 38 | Addr := Buf.Ptr 39 | while (Addr) 40 | { 41 | if (IsSet(Process)) 42 | { 43 | UniqueProcessId := NumGet(Addr, 0x0050, "Ptr") 44 | ImageName := (Ptr := NumGet(Addr, 0x0040, "Ptr")) ? StrGet(Ptr) : "" 45 | if (UniqueProcessId != Process) && (!InStr(ImageName, Process)) 46 | { 47 | if !(NumGet(Addr, 0x0000, "UInt")) 48 | break 49 | Addr += NumGet(Addr, 0x0000, "UInt") 50 | continue 51 | } 52 | } 53 | 54 | INFORMATION := Map() 55 | INFORMATION["NumberOfThreads"] := NumGet(Addr, 0x0004, "UInt") 56 | INFORMATION["WorkingSetPrivateSize"] := NumGet(Addr, 0x0008, "Int64") 57 | INFORMATION["HardFaultCount"] := NumGet(Addr, 0x0010, "UInt") 58 | INFORMATION["NumberOfThreadsHighWatermark"] := NumGet(Addr, 0x0014, "UInt") 59 | INFORMATION["CycleTime"] := NumGet(Addr, 0x0018, "UInt64") 60 | INFORMATION["CreateTime"] := NumGet(Addr, 0x0020, "Int64") 61 | INFORMATION["UserTime"] := NumGet(Addr, 0x0028, "Int64") 62 | INFORMATION["KernelTime"] := NumGet(Addr, 0x0030, "Int64") 63 | INFORMATION["ImageName"] := (Ptr := NumGet(Addr, 0x0040, "Ptr")) ? StrGet(Ptr) : "" 64 | INFORMATION["BasePriority"] := NumGet(Addr, 0x0048, "Int") 65 | INFORMATION["UniqueProcessId"] := NumGet(Addr, 0x0050, "Ptr") 66 | INFORMATION["InheritedFromUniqueProcessId"] := NumGet(Addr, 0x0058, "Ptr*") 67 | INFORMATION["HandleCount"] := NumGet(Addr, 0x0060, "UInt") 68 | INFORMATION["SessionId"] := NumGet(Addr, 0x0064, "UInt") 69 | INFORMATION["UniqueProcessKey"] := NumGet(Addr, 0x0068, "UPtr") 70 | INFORMATION["PeakVirtualSize"] := NumGet(Addr, 0x0070, "UPtr") 71 | INFORMATION["VirtualSize"] := NumGet(Addr, 0x0078, "UPtr") 72 | INFORMATION["PageFaultCount"] := NumGet(Addr, 0x0080, "UInt") 73 | INFORMATION["PeakWorkingSetSize"] := NumGet(Addr, 0x0088, "UPtr") 74 | INFORMATION["WorkingSetSize"] := NumGet(Addr, 0x0090, "UPtr") 75 | INFORMATION["QuotaPeakPagedPoolUsage"] := NumGet(Addr, 0x0098, "UPtr") 76 | INFORMATION["QuotaPagedPoolUsage"] := NumGet(Addr, 0x00A0, "UPtr") 77 | INFORMATION["QuotaPeakNonPagedPoolUsage"] := NumGet(Addr, 0x00A8, "UPtr") 78 | INFORMATION["QuotaNonPagedPoolUsage"] := NumGet(Addr, 0x00B0, "UPtr") 79 | INFORMATION["PagefileUsage"] := NumGet(Addr, 0x00B8, "UPtr") 80 | INFORMATION["PeakPagefileUsage"] := NumGet(Addr, 0x00C0, "UPtr") 81 | INFORMATION["PrivatePageCount"] := NumGet(Addr, 0x00C8, "UPtr") 82 | INFORMATION["ReadOperationCount"] := NumGet(Addr, 0x00D0, "Int64") 83 | INFORMATION["WriteOperationCount"] := NumGet(Addr, 0x00D8, "Int64") 84 | INFORMATION["OtherOperationCount"] := NumGet(Addr, 0x00E0, "Int64") 85 | INFORMATION["ReadTransferCount"] := NumGet(Addr, 0x00E8, "Int64") 86 | INFORMATION["WriteTransferCount"] := NumGet(Addr, 0x00F0, "Int64") 87 | INFORMATION["OtherTransferCount"] := NumGet(Addr, 0x00F8, "Int64") 88 | PROCESS_INFORMATION[A_Index] := INFORMATION 89 | 90 | if !(NumGet(Addr, 0x0000, "UInt")) 91 | break 92 | Addr += NumGet(Addr, 0x0000, "UInt") 93 | } 94 | return PROCESS_INFORMATION 95 | } 96 | 97 | throw OSError() 98 | } 99 | 100 | 101 | ; ============================================================================================================================================================= 102 | ; Example 103 | ; ============================================================================================================================================================= 104 | 105 | PI := SystemProcessInformation() ; or ("notepad") / (15027) 106 | Main := Gui() 107 | LV := Main.AddListView("xm ym w1366 r40") 108 | for i, in PI 109 | { 110 | arr := [], index := A_Index 111 | for k, v in PI[i] 112 | { 113 | if (index < 2) 114 | LV.InsertCol(A_Index,, k) 115 | arr.Push(v) 116 | } 117 | LV.Add("", arr*) 118 | } 119 | loop LV.GetCount("Col") 120 | LV.ModifyCol(A_Index, "Auto") 121 | Main.OnEvent("Close", (*) => ExitApp) 122 | Main.Show("AutoSize") 123 | 124 | /* 125 | Proc := SystemProcessInformation() 126 | for i, v in Proc { 127 | for k, v in Proc[i] 128 | MsgBox k ": " v 129 | } 130 | */ -------------------------------------------------------------------------------- /src/SystemInformation/SystemProcessorInformation.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author ........: jNizM 3 | ; Released ......: 2021-12-22 4 | ; Modified ......: 2023-01-13 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: SystemProcessorInformation() 8 | ; 9 | ; Parameter(s)...: No parameters used 10 | ; 11 | ; Return ........: Returns a SYSTEM_PROCESSOR_INFORMATION structure from the NtQuerySystemInformation function. 12 | ; ============================================================================================================================================================= 13 | 14 | #Requires AutoHotkey v2.0 15 | 16 | 17 | SystemProcessorInformation() 18 | { 19 | #DllLoad "ntdll.dll" 20 | 21 | static STATUS_SUCCESS := 0x00000000 22 | static STATUS_INFO_LENGTH_MISMATCH := 0xC0000004 23 | static STATUS_BUFFER_TOO_SMALL := 0xC0000023 24 | static SYSTEM_PROCESSOR_INFORMATION := 0x00000001 25 | 26 | Buf := Buffer(0x000C) 27 | NT_STATUS := DllCall("ntdll\NtQuerySystemInformation", "Int", SYSTEM_PROCESSOR_INFORMATION, "Ptr", Buf.Ptr, "UInt", Buf.Size, "UInt*", &Size := 0, "UInt") 28 | 29 | while (NT_STATUS = STATUS_INFO_LENGTH_MISMATCH) || (NT_STATUS = STATUS_BUFFER_TOO_SMALL) 30 | { 31 | Buf := Buffer(Size) 32 | NT_STATUS := DllCall("ntdll\NtQuerySystemInformation", "Int", SYSTEM_PROCESSOR_INFORMATION, "Ptr", Buf.Ptr, "UInt", Buf.Size, "UInt*", &Size := 0, "UInt") 33 | } 34 | 35 | if (NT_STATUS = STATUS_SUCCESS) 36 | { 37 | PROCESSOR_INFORMATION := Map() 38 | PROCESSOR_INFORMATION["ProcessorArchitecture"] := NumGet(Buf, 0x0000, "UShort") 39 | PROCESSOR_INFORMATION["ProcessorLevel"] := NumGet(Buf, 0x0002, "UShort") 40 | PROCESSOR_INFORMATION["ProcessorRevision"] := NumGet(Buf, 0x0004, "UShort") 41 | PROCESSOR_INFORMATION["MaximumProcessors"] := NumGet(Buf, 0x0006, "UShort") 42 | PROCESSOR_INFORMATION["ProcessorFeatureBits"] := NumGet(Buf, 0x0008, "UInt") 43 | return PROCESSOR_INFORMATION 44 | } 45 | 46 | throw OSError() 47 | } 48 | 49 | 50 | ; ============================================================================================================================================================= 51 | ; Example 52 | ; ============================================================================================================================================================= 53 | 54 | MsgBox SystemProcessorInformation()["MaximumProcessors"] -------------------------------------------------------------------------------- /src/SystemInformation/SystemProcessorPerformanceInformation.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author ........: jNizM 3 | ; Released ......: 2021-12-22 4 | ; Modified ......: 2023-01-13 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: SystemProcessorPerformanceInformation() 8 | ; 9 | ; Parameter(s)...: No parameters used 10 | ; 11 | ; Return ........: Returns a SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION structure from the NtQuerySystemInformation function. 12 | ; ============================================================================================================================================================= 13 | 14 | #Requires AutoHotkey v2.0 15 | 16 | 17 | SystemProcessorPerformanceInformation() 18 | { 19 | #DllLoad "ntdll.dll" 20 | 21 | static STATUS_SUCCESS := 0x00000000 22 | static STATUS_INFO_LENGTH_MISMATCH := 0xC0000004 23 | static STATUS_BUFFER_TOO_SMALL := 0xC0000023 24 | static SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION := 0x00000008 25 | 26 | Buf := Buffer(0x0030) 27 | NT_STATUS := DllCall("ntdll\NtQuerySystemInformation", "Int", SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION, "Ptr", Buf.Ptr, "UInt", Buf.Size, "UInt*", &Size := 0, "UInt") 28 | 29 | while (NT_STATUS = STATUS_INFO_LENGTH_MISMATCH) || (NT_STATUS = STATUS_BUFFER_TOO_SMALL) 30 | { 31 | Buf := Buffer(Size) 32 | NT_STATUS := DllCall("ntdll\NtQuerySystemInformation", "Int", SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION, "Ptr", Buf.Ptr, "UInt", Buf.Size, "UInt*", &Size := 0, "UInt") 33 | } 34 | 35 | if (NT_STATUS = STATUS_SUCCESS) 36 | { 37 | DEVICE_INFORMATION := Map() 38 | DEVICE_INFORMATION["IdleTime"] := NumGet(Buf, 0x0000, "Int64") 39 | DEVICE_INFORMATION["KernelTime"] := NumGet(Buf, 0x0008, "Int64") 40 | DEVICE_INFORMATION["UserTime"] := NumGet(Buf, 0x0010, "Int64") 41 | DEVICE_INFORMATION["DpcTime"] := NumGet(Buf, 0x0018, "Int64") 42 | DEVICE_INFORMATION["InterruptTime"] := NumGet(Buf, 0x0020, "Int64") 43 | DEVICE_INFORMATION["InterruptCount"] := NumGet(Buf, 0x0028, "UInt") 44 | return DEVICE_INFORMATION 45 | } 46 | 47 | throw OSError() 48 | } 49 | 50 | 51 | ; ============================================================================================================================================================= 52 | ; Example 53 | ; ============================================================================================================================================================= 54 | 55 | MsgBox SystemProcessorPerformanceInformation()["IdleTime"] -------------------------------------------------------------------------------- /src/SystemInformation/SystemProcessorPowerInformation.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author ........: jNizM 3 | ; Released ......: 2021-12-22 4 | ; Modified ......: 2023-01-13 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: SystemProcessorPowerInformation() 8 | ; 9 | ; Parameter(s)...: No parameters used 10 | ; 11 | ; Return ........: Returns a SYSTEM_PROCESSOR_POWER_INFORMATION structure from the NtQuerySystemInformation function. 12 | ; ============================================================================================================================================================= 13 | 14 | #Requires AutoHotkey v2.0 15 | 16 | 17 | SystemProcessorPowerInformation() 18 | { 19 | #DllLoad "ntdll.dll" 20 | 21 | static STATUS_SUCCESS := 0x00000000 22 | static STATUS_INFO_LENGTH_MISMATCH := 0xC0000004 23 | static STATUS_BUFFER_TOO_SMALL := 0xC0000023 24 | static SYSTEM_PROCESSOR_POWER_INFORMATION := 0x0000003D 25 | 26 | Buf := Buffer(0x0050) 27 | NT_STATUS := DllCall("ntdll\NtQuerySystemInformation", "Int", SYSTEM_PROCESSOR_POWER_INFORMATION, "Ptr", Buf.Ptr, "UInt", Buf.Size, "UInt*", &Size := 0, "UInt") 28 | 29 | while (NT_STATUS = STATUS_INFO_LENGTH_MISMATCH) || (NT_STATUS = STATUS_BUFFER_TOO_SMALL) 30 | { 31 | Buf := Buffer(Size) 32 | NT_STATUS := DllCall("ntdll\NtQuerySystemInformation", "Int", SYSTEM_PROCESSOR_POWER_INFORMATION, "Ptr", Buf.Ptr, "UInt", Buf.Size, "UInt*", &Size := 0, "UInt") 33 | } 34 | 35 | if (NT_STATUS = STATUS_SUCCESS) 36 | { 37 | PROCESSOR_POWER_INFORMATION := Map() 38 | PROCESSOR_POWER_INFORMATION["CurrentFrequency"] := NumGet(Buf, 0x0000, "UChar") 39 | PROCESSOR_POWER_INFORMATION["ThermalLimitFrequency"] := NumGet(Buf, 0x0001, "UChar") 40 | PROCESSOR_POWER_INFORMATION["ConstantThrottleFrequency"] := NumGet(Buf, 0x0002, "UChar") 41 | PROCESSOR_POWER_INFORMATION["DegradedThrottleFrequency"] := NumGet(Buf, 0x0003, "UChar") 42 | PROCESSOR_POWER_INFORMATION["LastBusyFrequency"] := NumGet(Buf, 0x0004, "UChar") 43 | PROCESSOR_POWER_INFORMATION["LastC3Frequency"] := NumGet(Buf, 0x0005, "UChar") 44 | PROCESSOR_POWER_INFORMATION["LastAdjustedBusyFrequency"] := NumGet(Buf, 0x0006, "UChar") 45 | PROCESSOR_POWER_INFORMATION["ProcessorMinThrottle"] := NumGet(Buf, 0x0007, "UChar") 46 | PROCESSOR_POWER_INFORMATION["ProcessorMaxThrottle"] := NumGet(Buf, 0x0008, "UChar") 47 | PROCESSOR_POWER_INFORMATION["NumberOfFrequencies"] := NumGet(Buf, 0x000C, "UInt") 48 | PROCESSOR_POWER_INFORMATION["PromotionCount"] := NumGet(Buf, 0x0010, "UInt") 49 | PROCESSOR_POWER_INFORMATION["DemotionCount"] := NumGet(Buf, 0x0014, "UInt") 50 | PROCESSOR_POWER_INFORMATION["ErrorCount"] := NumGet(Buf, 0x0018, "UInt") 51 | PROCESSOR_POWER_INFORMATION["RetryCount"] := NumGet(Buf, 0x001C, "UInt") 52 | PROCESSOR_POWER_INFORMATION["CurrentFrequencyTime"] := NumGet(Buf, 0x0020, "UInt64") 53 | PROCESSOR_POWER_INFORMATION["CurrentProcessorTime"] := NumGet(Buf, 0x0028, "UInt64") 54 | PROCESSOR_POWER_INFORMATION["CurrentProcessorIdleTime"] := NumGet(Buf, 0x0030, "UInt64") 55 | PROCESSOR_POWER_INFORMATION["LastProcessorTime"] := NumGet(Buf, 0x0038, "UInt64") 56 | PROCESSOR_POWER_INFORMATION["LastProcessorIdleTime"] := NumGet(Buf, 0x0040, "UInt64") 57 | PROCESSOR_POWER_INFORMATION["Energy"] := NumGet(Buf, 0x0048, "UInt64") 58 | return PROCESSOR_POWER_INFORMATION 59 | } 60 | 61 | throw OSError() 62 | } 63 | 64 | 65 | ; ============================================================================================================================================================= 66 | ; Example 67 | ; ============================================================================================================================================================= 68 | 69 | MsgBox SystemProcessorPowerInformation()["CurrentFrequency"] -------------------------------------------------------------------------------- /src/SystemInformation/SystemSecureBootInformation.ahk: -------------------------------------------------------------------------------- 1 | ; ============================================================================================================================================================= 2 | ; Author ........: jNizM 3 | ; Released ......: 2021-12-22 4 | ; Modified ......: 2023-01-13 5 | ; Tested with....: AutoHotkey v2.0.2 (x64) 6 | ; Tested on .....: Windows 11 - 22H2 (x64) 7 | ; Function ......: SystemSecureBootInformation() 8 | ; 9 | ; Parameter(s)...: No parameters used 10 | ; 11 | ; Return ........: Returns a SYSTEM_SECUREBOOT_INFORMATION structure from the NtQuerySystemInformation function. 12 | ; ============================================================================================================================================================= 13 | 14 | #Requires AutoHotkey v2.0 15 | 16 | 17 | SystemSecureBootInformation() 18 | { 19 | #DllLoad "ntdll.dll" 20 | 21 | static STATUS_SUCCESS := 0x00000000 22 | static STATUS_INFO_LENGTH_MISMATCH := 0xC0000004 23 | static STATUS_BUFFER_TOO_SMALL := 0xC0000023 24 | static SYSTEM_SECUREBOOT_INFORMATION := 0x00000091 25 | 26 | Buf := Buffer(0x0002) 27 | NT_STATUS := DllCall("ntdll\NtQuerySystemInformation", "Int", SYSTEM_SECUREBOOT_INFORMATION, "Ptr", Buf.Ptr, "UInt", Buf.Size, "UInt*", &Size := 0, "UInt") 28 | 29 | while (NT_STATUS = STATUS_INFO_LENGTH_MISMATCH) || (NT_STATUS = STATUS_BUFFER_TOO_SMALL) 30 | { 31 | Buf := Buffer(Size) 32 | NT_STATUS := DllCall("ntdll\NtQuerySystemInformation", "Int", SYSTEM_SECUREBOOT_INFORMATION, "Ptr", Buf.Ptr, "UInt", Buf.Size, "UInt*", &Size := 0, "UInt") 33 | } 34 | 35 | if (NT_STATUS = STATUS_SUCCESS) 36 | { 37 | SECUREBOOT_INFORMATION := Map() 38 | SECUREBOOT_INFORMATION["SecureBootEnabled"] := NumGet(Buf, 0x0000, "UChar") 39 | SECUREBOOT_INFORMATION["SecureBootCapable"] := NumGet(Buf, 0x0001, "UChar") 40 | return SECUREBOOT_INFORMATION 41 | } 42 | 43 | throw OSError() 44 | } 45 | 46 | 47 | ; ============================================================================================================================================================= 48 | ; Example 49 | ; ============================================================================================================================================================= 50 | 51 | MsgBox SystemSecureBootInformation()["SecureBootEnabled"] --------------------------------------------------------------------------------