-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
173 changed files
with
82,596 additions
and
1,476 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
; ---------------------------------------------------------------------------------------------------------------------- | ||
; Function .....: ConfOverride | ||
; Description ..: Override a configuration object with data read from an ini configuration file. | ||
; ..............: The configuration object needs to contain separate section objects with key:value pairs. Eg: | ||
; ..............: CONF := {}, CONF.SCRIPT := { a:"value", b:"value" }, CONF.SETTINGS := { c:"value" } and so on... | ||
; ..............: Use the pair __LOCKED:1 to avoid a section being overridden. | ||
; Parameters ...: oConf - Configuration object to be passed byref. | ||
; ..............: sFile - Path to the ini file. | ||
; Return .......: 0 - Error. | ||
; ..............: 1 - Object updated. | ||
; ..............: 2 - Object not updated. | ||
; AHK Version ..: AHK v2 x32/64 Unicode | ||
; Author .......: cyruz - http://ciroprincipe.info | ||
; License ......: WTFPL - http://www.wtfpl.net/txt/copying/ | ||
; Changelog ....: Oct. 04, 2022 - v0.1.0 - First version. | ||
; ---------------------------------------------------------------------------------------------------------------------- | ||
|
||
ConfOverride(&oConf, sFile) | ||
{ | ||
If !FileExist(sFile) | ||
Return 0 | ||
|
||
sIniFile := IniRead(sFile) | ||
Loop Parse, sIniFile, "`n" | ||
{ | ||
If oConf.HasOwnProp(A_LoopField) | ||
{ | ||
If oConf.%A_LoopField%.HasOwnProp("__LOCKED") | ||
&& oConf.%A_LoopField%.__LOCKED | ||
Continue | ||
sSectionName := A_LoopField | ||
sSectionContent := IniRead(sFile, sSectionName) | ||
Loop Parse, sSectionContent, "`n" | ||
If RegExMatch(A_LoopField, "S)^\s*(\w+)\s*\=\s*(.*)\s*$", &oMatch) | ||
oConf.%sSectionName%.%oMatch.1% := oMatch.2, bUpdated := 1 | ||
} | ||
} | ||
Return bUpdated ? 1 : 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
CreateDirectoryMap(fso, path){ ; Returns data for all folders & files found (name, path, date created, date last modified, parent folder name, contents within (files/folders) | ||
|
||
dir := fso.GetFolder(path) ; Get contents of specified directory | ||
|
||
; Create array if subfolders/files exist, else make empty string | ||
(folders := dir.SubFolders) ? folderData := [] : folderData := "" | ||
(files := dir.Files ) ? fileData := [] : fileData := "" | ||
|
||
; if subfolders exist, push map of folder data into array | ||
if (IsObject(folderData)) | ||
for folder in folders | ||
folderData.Push( Map("Name", folder.Name, | ||
"Path", folder.Path, | ||
"Created", folder.DateCreated, | ||
"Modified", folder.DateLastModified, | ||
"Parent", folder.ParentFolder.Name, | ||
"Contents", CreateDirectoryMap(fso, folder.Path)) ) ; Recurse through all folders found below specified directory | ||
|
||
; if files exist, push map of file data into array | ||
if (IsObject(fileData)) | ||
for file in files | ||
fileData.Push( Map("Name", file.Name, | ||
"Path", file.Path, | ||
"Created", file.DateCreated, | ||
"Modified", file.DateLastModified, | ||
"Parent", file.ParentFolder.Name) ) | ||
|
||
return Map("Name", dir.Name, ; string | ||
"Path", path, ; string | ||
"Created", dir.DateCreated, ; string | ||
"Modified", dir.DateLastModified, ; string | ||
"Parent", dir.ParentFolder.Name, ; string | ||
"Contents", Map("Folders", folderData, "Files", fileData)) ; Map with Array of nested Map objects | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#Requires Autohotkey v2.0-beta.7 | ||
/** | ||
* Function: GetDefaultIcon(fExt [, getHandle]) | ||
* https://docs.microsoft.com/en-us/windows/win32/api/shlwapi/nf-shlwapi-assocquerystringw | ||
* | ||
* Based on a specific use case of the AssocQueryString function. | ||
* | ||
* Searches for and retrieves the default icon for a provided extension and returns | ||
* a handle to the icon to be used in a picture control or the string to the associated icon path. | ||
* | ||
* Params: | ||
* fExt - File extension to work on with optional `.` in front e.g.: ahk or .ahk | ||
* getHandle - instruct the function to either return the handle to a resource or | ||
* the string to the default executable file | ||
* | ||
* Returns: | ||
* - A Handle to an icon resource (Default) | ||
* - A string to the default executable and icon number for the extension | ||
* | ||
* Examples: | ||
* ---ahk | ||
MsgBox GetDefaultIcon("ahk") | ||
MsgBox GetDefaultIcon(".ahk") | ||
* --- | ||
* | ||
* ---ahk | ||
for ext in ["ahk", ".html", ".bat", "vbs", ".dll"] | ||
strings .= GetDefaultIcon(ext, false) '`n' | ||
|
||
MsgBox strings | ||
* --- | ||
*/ ; by RaptorX | ||
|
||
GetDefaultIcon(fExt, getHandle:=true) { | ||
static ASSOCSTR_DEFAULTICON := 15 | ||
|
||
fExt := RegExReplace(fExt, "^\.?(.*)$", ".$1") | ||
|
||
DllCall "shlwapi.dll\AssocQueryString", | ||
"int", false, ; [in] ASSOCF flags, | ||
"int", ASSOCSTR_DEFAULTICON, ; [in] ASSOCSTR str, | ||
"str", fExt, ; [in] LPCSTR pszAssoc, | ||
"int", false, ; [in, optional] LPCSTR pszExtra, | ||
"ptr", StrOut:=Buffer(65000), ; [out, optional] LPSTR pszOut, | ||
"ptr*", &length:=StrOut.size // 2, ; [in, out] DWORD *pcchOut | ||
"HRESULT" | ||
|
||
try | ||
{ | ||
app := StrSplit(assocStr:=StrGet(StrOut), ",") | ||
regKey := "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\." fExt "\UserChoice" | ||
|
||
if (!hIcon := LoadPicture(app[1], "Icon" app.Has(2) ? app[2] : "", &imgType)) | ||
&& (progID := RegRead(regKey,"progID", false)) | ||
&& (icon := RegRead("HKCR\" progID "\DefaultIcon")) | ||
{ | ||
RegExMatch(icon, "(?<app>.*?),?(?<index>\d+)?$", &matched) | ||
hIcon := LoadPicture(matched.app, "Icon" matched.index, &imgType) | ||
} | ||
} | ||
|
||
return getHandle ? (hIcon?? LoadPicture("C:\Windows\system32\shell32.dll", "Icon291", &imgType)) : assocStr | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
; ---------------------------------------------------------------------------------------------------------------------- | ||
; Function .....: StdoutToVar | ||
; Description ..: Runs a command line program and returns its output. | ||
; Parameters ...: sCmd - Commandline to be executed. | ||
; ..............: sDir - Working directory. | ||
; ..............: sEnc - Encoding used by the target process. Look at StrGet() for possible values. | ||
; Return .......: Command output as a string on success, empty string on error. | ||
; AHK Version ..: AHK v2 x32/64 Unicode | ||
; Author .......: Sean (http://goo.gl/o3VCO8), modified by nfl and by Cyruz | ||
; License ......: WTFPL - http://www.wtfpl.net/txt/copying/ | ||
; Changelog ....: Feb. 20, 2007 - Sean version. | ||
; ..............: Sep. 21, 2011 - nfl version. | ||
; ..............: Nov. 27, 2013 - Cyruz version (code refactored and exit code). | ||
; ..............: Mar. 09, 2014 - Removed input, doesn't seem reliable. Some code improvements. | ||
; ..............: Mar. 16, 2014 - Added encoding parameter as pointed out by lexikos. | ||
; ..............: Jun. 02, 2014 - Corrected exit code error. | ||
; ..............: Nov. 02, 2016 - Fixed blocking behavior due to ReadFile thanks to PeekNamedpipe. | ||
; ..............: Apr. 13, 2021 - Code restyling. Fixed deprecated DllCall types. | ||
; ..............: Oct. 06, 2022 - AHK v2 version. Throw exceptions on failure. | ||
; ---------------------------------------------------------------------------------------------------------------------- | ||
StdoutToVar(sCmd, sDir:="", sEnc:="CP0") { | ||
If !DllCall( "CreatePipe" | ||
, "PtrP" , &hStdOutRd:=0 | ||
, "PtrP" , &hStdOutWr:=0 | ||
, "Ptr" , 0 | ||
, "UInt" , 0 ) | ||
Throw("Error creating pipe.") | ||
If !DllCall( "SetHandleInformation" | ||
, "Ptr" , hStdOutWr | ||
, "UInt" , 1 | ||
, "UInt" , 1 ) | ||
{ | ||
DllCall( "CloseHandle", "Ptr" , hStdOutWr ) | ||
DllCall( "CloseHandle", "Ptr" , hStdOutRd ) | ||
Throw("Error setting handle information.") | ||
} | ||
|
||
PI := Buffer(A_PtrSize == 4 ? 16 : 24, 0) | ||
SI := Buffer(A_PtrSize == 4 ? 68 : 104, 0) | ||
NumPut( "UInt", SI.Size, SI, 0 ) | ||
NumPut( "UInt", 0x100, SI, A_PtrSize == 4 ? 44 : 60 ) | ||
NumPut( "Ptr", hStdOutWr, SI, A_PtrSize == 4 ? 60 : 88 ) | ||
NumPut( "Ptr", hStdOutWr, SI, A_PtrSize == 4 ? 64 : 96 ) | ||
|
||
If !DllCall( "CreateProcess" | ||
, "Ptr" , 0 | ||
, "Str" , sCmd | ||
, "Ptr" , 0 | ||
, "Ptr" , 0 | ||
, "Int" , True | ||
, "UInt" , 0x08000000 | ||
, "Ptr" , 0 | ||
, "Ptr" , sDir ? StrPtr(sDir) : 0 | ||
, "Ptr" , SI | ||
, "Ptr" , PI ) | ||
{ | ||
DllCall( "CloseHandle", "Ptr" , hStdOutWr ) | ||
DllCall( "CloseHandle", "Ptr" , hStdOutRd ) | ||
Throw("Error creating process.") | ||
} | ||
|
||
; The write pipe must be closed before reading the stdout. | ||
DllCall( "CloseHandle", "Ptr" , hStdOutWr ) | ||
|
||
; Before reading, we check if the pipe has been written to, so we avoid freezings. | ||
nAvail := 0, nLen := 0 | ||
While DllCall( "PeekNamedPipe" | ||
, "Ptr" , hStdOutRd | ||
, "Ptr" , 0 | ||
, "UInt" , 0 | ||
, "Ptr" , 0 | ||
, "UIntP" , &nAvail | ||
, "Ptr" , 0 ) != 0 | ||
{ | ||
; If the pipe buffer is empty, sleep and continue checking. | ||
If !nAvail && DllCall( "Sleep", "UInt",100 ) | ||
Continue | ||
cBuf := Buffer(nAvail+1) | ||
DllCall( "ReadFile" | ||
, "Ptr" , hStdOutRd | ||
, "Ptr" , cBuf | ||
, "UInt" , nAvail | ||
, "PtrP" , &nLen | ||
, "Ptr" , 0 ) | ||
sOutput .= StrGet(cBuf, nLen, sEnc) | ||
} | ||
|
||
DllCall( "GetExitCodeProcess" | ||
, "Ptr" , NumGet(PI, 0, "Ptr") | ||
, "UIntP" , &nExitCode:=0 ) | ||
DllCall( "CloseHandle", "Ptr" , NumGet(PI, 0, "Ptr") ) | ||
DllCall( "CloseHandle", "Ptr" , NumGet(PI, A_PtrSize, "Ptr") ) | ||
DllCall( "CloseHandle", "Ptr" , hStdOutRd ) | ||
|
||
Return { Output: sOutput, ExitCode: nExitCode } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.