I fixed the issue!
It looks like MicaForEveryone has a nice option under Config File section: "Reload on change".
So I created a new script for Directory Opus that automatically updates the Mica's config file when the window becomes active, size changes or other events when the bug occurred:
function OnInit(initData) {
initData.name = "DopusListerMonitor";
initData.desc = "Monitor lister events to update Mica configuration file";
initData.default_enable = true;
initData.version = "1.0";
}
/*function OnListerUIChange(ListerUIChangeData) {
if(ListerUIChangeData.change == "minmax"){
DOpus.Output("ListerUIChangeData: " + ListerUIChangeData.change);
UpdateConfigFile();
}
}*/
function OnListerResize(ListerResizeData) {
if(ListerResizeData.action == "resize"){
DOpus.Output("MicaFix: OnListerResize: " + ListerResizeData.action);
UpdateConfigFile();
}
}
function OnActivateLister(activateListerData) {
if(activateListerData.active){
DOpus.Output("MicaFix: Lister activated");
//DOpus.Dlg.Request("Lister activated", "OK");
UpdateConfigFile();
}
}
function UpdateConfigFile() {
var mica_config_path = "D:\\FOLDERY\\SyncSettings\\MicaForEveryone.conf";
var lineToFind = "# DopusFix:";
var fso = new ActiveXObject("Scripting.FileSystemObject");
if (!fso.FileExists(mica_config_path)) {
DOpus.Output("MicaFix: Configuration file not found: " + mica_config_path);
return;
}
var inputFile;
try {
inputFile = fso.OpenTextFile(mica_config_path, 1); // For reading
} catch (e) {
DOpus.Output("MicaFix: Error opening file for reading: " + e.message);
return;
}
var content = [];
var found = false;
var random = Math.floor(Math.random() * 99) + 1;
// Read the file content
while (!inputFile.AtEndOfStream) {
var line = inputFile.ReadLine();
if (line.indexOf(lineToFind) != -1) {
found = true;
line = lineToFind + " " + random;
}
content.push(line);
}
inputFile.Close();
if (!found) {
content.push(lineToFind + " " + random);
}
// Write the updated content back to the original file
var outputFile;
try {
outputFile = fso.OpenTextFile(mica_config_path, 2); // For writing
} catch (e) {
DOpus.Output("MicaFix: Error opening file for writing: " + e.message);
return;
}
for (var i = 0; i < content.length; i++) {
outputFile.WriteLine(content[i]);
}
outputFile.Close();
DOpus.Output("MicaFix: Configuration file updated with random number: " + random);
//DOpus.Dlg.Request("Configuration file updated with random number: " + random, "OK");
}
Thanks to this Mica reloads the effect for the Dopus window and everything works the same way as before.