2) Now, if the content of the XYplorer_MiniTreeBrowsing.ini file is changed, the new values are immediately used w/o having to restart the script.
as always, USAGE AT OWN RISK!!!!!! (Do I have to write that all the time?
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#Persistent
global XY_eval_and_returnvalue_XYRETURN
XYdata_path := XY_eval_and_returnvalue("<xydata>")
if (not FileExist(XYdata_path . "\XYplorer_MiniTreeBrowsing.ini"))
{
FileAppend [on/off settings]`nUse_maxDisplayedSiblings=1`nUse_parentPathsOfNotDisplayedSiblings=1`n`n[values]`nmaxDisplayedSiblings=30`n; paths are seperated by "|"`nparentPathsOfNotDisplayedSiblings=
, %XYdata_path%\XYplorer_MiniTreeBrowsing.ini
if ErrorLevel
{
MsgBox %XYdata_path%\XYplorer_MiniTreeBrowsing.ini`n`nProblem writing to ini file. Exiting script.
ExitApp
}
Use_maxDisplayedSiblings := 1
Use_parentPathsOfNotDisplayedSiblings := 0
maxDisplayedSiblings := 30
parentPathsOfNotDisplayedSiblings := ""
FileGetTime, XYMiniTreeBrowsing_ini_lastModTime, %XYdata_path%\XYplorer_MiniTreeBrowsing.ini, M
}
Read_XYplorer_MiniTreeBrowsing_ini()
{
global
local iniReadError := ""
IniRead Use_maxDisplayedSiblings, %XYdata_path%\XYplorer_MiniTreeBrowsing.ini, on/off settings, Use_maxDisplayedSiblings
iniReadError := iniReadError . Use_maxDisplayedSiblings . "|"
IniRead Use_parentPathsOfNotDisplayedSiblings, %XYdata_path%\XYplorer_MiniTreeBrowsing.ini, on/off settings, Use_parentPathsOfNotDisplayedSiblings
iniReadError := iniReadError . Use_parentPathsOfNotDisplayedSiblings . "|"
IniRead maxDisplayedSiblings, %XYdata_path%\XYplorer_MiniTreeBrowsing.ini, values, maxDisplayedSiblings
iniReadError := iniReadError . maxDisplayedSiblings . "|"
IniRead parentPathsOfNotDisplayedSiblings, %XYdata_path%\XYplorer_MiniTreeBrowsing.ini, values, parentPathsOfNotDisplayedSiblings
iniReadError := iniReadError . parentPathsOfNotDisplayedSiblings . "|"
if (InStr(iniReadError, "ERROR", 1))
{
MsgBox %XYdata_path%\XYplorer_MiniTreeBrowsing.ini`n`nProblem reading from ini file. To ensure that at least the format of the ini file is correct, delete it and run the exe again, so that it will create it anew. Exiting script.
ExitApp
}
}
;***************************************************************************************
;** code from others (or based on) **
;***************************************************************************************
;heavily based on
;http://www.xyplorer.com/xyfc/viewtopic.php?f=7&t=9233&p=89555&hilit=messenger#p89555
;~ MsgBox % A_ScriptHwnd + 0
;~ OnMessage(0x4a, "Function_Receive_WM_COPYDATA")
XY_eval_and_returnvalue(stringToEval) ;Send message to XYplorer
{
SetTitleMatchMode, 2
SetWinDelay, 0
WinWait XYplorer ahk_class ThunderRT6FormDC
global XY_eval_and_returnvalue_XYRETURN
SenderHWND := A_ScriptHwnd + 0 ;Return this script's hidden hwdn id. +0 to convert from Hex to Dec
if (SubStr(stringToEval,1,9) = "noreturn ")
{
stringToEval := SubStr(stringToEval,10)
MessagetoXYplorer := "::" stringToEval ;"noreturn loadtree get('tree').'|'.listfolder(,,2)" resolved to sth like this: ::loadtree get('tree').'|'.listfolder(,,2)
}
else
{
MessagetoXYplorer := "::CopyData " SenderHWND ", " stringToEval ", 0" ;resolved to sth like this: ::CopyData 7409230, <curitem>, 0 _OR like this: ::CopyData 7409230, tab('get','count'), 0
}
HWND := WinExist("XYplorer ahk_class ThunderRT6FormDC")
Size := StrLen(MessagetoXYplorer)
If !(A_IsUnicode)
{
VarSetCapacity(Data, Size * 2, 0)
StrPut(MessagetoXYplorer, &Data, Size, "UTF-16")
}
Else
Data := MessagetoXYplorer
VarSetCapacity(COPYDATA, A_PtrSize * 3, 0)
NumPut(4194305, COPYDATA, 0, "Ptr")
NumPut(Size * 2, COPYDATA, A_PtrSize, "UInt")
NumPut(&Data, COPYDATA, A_PtrSize * 2, "Ptr")
XY_eval_and_returnvalue_XYRETURN := ""
OnMessage(0x4a, "Function_Receive_WM_COPYDATA") ; 0x4a is WM_COPYDATA. This onhold and wait for the WM_Copydata from XYplorer then execute Function_Receive_WM_COPYDATA(wParam, lParam) below
SendMessage, 0x4a, 0, ©DATA, , ahk_id %HWND% ;SendMessage waits for the target window to process the message, up until the timeout period expires.
OnMessage(0x4a, "")
return XY_eval_and_returnvalue_XYRETURN
}
Function_Receive_WM_COPYDATA(wParam, lParam)
{
global XY_eval_and_returnvalue_XYRETURN
StringAddress := NumGet(lParam + 2*A_PtrSize) ;lParam+8 is the address of CopyDataStruct's lpData member.
CopyOfData := StrGet(StringAddress) ;May also specify CP0 (default) or UTF-8 or UTF-16: StrGet(StringAddress, NumGet(lParam+A_PtrSize), "UTF-16")
cbData := NumGet(lParam+A_PtrSize)/2 ;cbData/2 = String length
StringLeft, Datareceived, CopyOfData, cbData
XY_eval_and_returnvalue_XYRETURN := Datareceived
;~ MsgBox % Datareceived
}
;***************************************************************************************
;~ XY_curPath := XY_eval_and_returnvalue("<curpath>")
SetTimer, Label1, 150
return
Label1:
XY_curPath_new := XY_eval_and_returnvalue("<curpath>")
If (XY_curPath != XY_curPath_new)
{
XY_curPath := XY_curPath_new
FileGetTime, XYMiniTreeBrowsing_ini_lastModTime_new, %XYdata_path%\XYplorer_MiniTreeBrowsing.ini, M
if(XYMiniTreeBrowsing_ini_lastModTime != XYMiniTreeBrowsing_ini_lastModTime_new)
{
Read_XYplorer_MiniTreeBrowsing_ini()
XYMiniTreeBrowsing_ini_lastModTime := XYMiniTreeBrowsing_ini_lastModTime_new
}
FileGetTime, XYini_lastModTime_new, %XYdata_path%\XYplorer.ini, M
if (XYini_lastModTime != XYini_lastModTime_new)
{
XYini_file := FileOpen(XYdata_path . "\XYplorer.ini", "r")
if XYini_file
{
XYini_lastModTime := XYini_lastModTime_new
XYini_line := ""
Loop
{
XYini_line := XYini_file.ReadLine()
}
until SubStr(XYini_line, 1, 22) = "MiniTreePathsFavorite=" or XYini_file.AtEOF
if (XYini_file.AtEOF)
{
XYfavMiniTree_paths := ""
}
else
{
XYfavMiniTree_paths := SubStr(XYini_line, 23)
XYfavMiniTree_paths := RTrim(XYfavMiniTree_paths, "`n`r")
if (XYfavMiniTree_paths)
{
XYfavMiniTree_paths := XYfavMiniTree_paths . "|"
}
}
XYini_file.Close()
}
else
{
XYfavMiniTree_paths := ""
}
}
XYcurFolder_directSubfolderPaths := XY_eval_and_returnvalue("listfolder('" . XY_curPath . "',,2)")
if (XYcurFolder_directSubfolderPaths)
{
XYcurFolder_directSubfolderPaths := XYcurFolder_directSubfolderPaths . "|"
}
XYcurFolder_siblingFolderPaths := ""
SplitPath, XY_curPath,,XY_curPath_parent ;only works correctly on XY_curPath withOUT trailing backslash which is the case with <curpath> (see up above)
if (XY_curPath != XY_curPath_parent) ;if XY_curPath is the root of a drive (e.g. only "C:") then the result for parent is the same and also there are no siblings for the tree
{
retrieveSiblingFolders := 1
if (Use_parentPathsOfNotDisplayedSiblings and (InStr(parentPathsOfNotDisplayedSiblings . "|", XY_curPath_parent . "|") or InStr(parentPathsOfNotDisplayedSiblings . "|", XY_curPath_parent . "\|")))
{
retrieveSiblingFolders := 0
}
XYcurFolder_siblingFoldersCount := XY_eval_and_returnvalue("listfolder('" . XY_curPath_parent . "',,34)")
if (Use_maxDisplayedSiblings and XYcurFolder_siblingFoldersCount > maxDisplayedSiblings)
{
retrieveSiblingFolders := 0
}
if (retrieveSiblingFolders)
{
XYcurFolder_siblingFolderPaths := XY_eval_and_returnvalue("listfolder('" . XY_curPath_parent . "',,2)")
}
}
;~ MsgBox % XY_curPath . "|" . XYfavMiniTree_paths . XYcurFolder_directSubfolderPaths . XYcurFolder_siblingFolderPaths
XY_eval_and_returnvalue("noreturn loadtree '" . XY_curPath . "|" . XYfavMiniTree_paths . XYcurFolder_directSubfolderPaths . XYcurFolder_siblingFolderPaths . "'")
}
return
XYplorer Beta Club