1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-06 00:13:33 +00:00

Updated process-manager to support an options object, for search

Added win-utils to provide windows specific helper methods.
Added ability to set/query system taskbar autohide on Windows
This commit is contained in:
Bryan Roe
2022-08-03 14:43:26 -07:00
parent 0ce0d3bf8b
commit 10c6aa295c
3 changed files with 65 additions and 3 deletions

File diff suppressed because one or more lines are too long

View File

@@ -350,7 +350,7 @@ function processManager() {
};
}
}
this.getProcessEx = function getProcessEx(cmd)
this.getProcessEx = function getProcessEx(cmd, options)
{
if (process.platform == 'win32')
{
@@ -362,7 +362,10 @@ function processManager() {
{
if(j[i].cmd.toLowerCase() == cmd.toLowerCase())
{
result.push(j[i].pid);
if (options == null || options.path.toLowerCase() == j[i].path.toLowerCase())
{
result.push(j[i].pid);
}
}
}
});

56
modules/win-utils.js Normal file
View File

@@ -0,0 +1,56 @@
/*
Copyright 2022 Intel Corporation
@author Bryan Roe
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
//
// win-utils provides helper functions for Windows Platforms
//
var reg = require('win-registry');
function winutils()
{
this._ObjectID = 'win-utils';
this.taskBar =
{
autoHide: function autoHide(tsid, value)
{
var domain = require('user-sessions').getDomain(tsid);
var user = require('user-sessions').getUsername(tsid);
var key = reg.usernameToUserKey({ domain: domain, user: user });
if(value==null)
{
// Query the Current State
var rv = reg.QueryKey(reg.HKEY.Users, key + '\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\StuckRects3', 'Settings');
return (rv[8] == 3);
}
else
{
var rv = reg.QueryKey(reg.HKEY.Users, key + '\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\StuckRects3', 'Settings');
rv[8] = value === true ? 3 : 2;
reg.WriteKey(reg.HKEY.Users, key + '\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\StuckRects3', 'Settings', rv);
var pids = require('process-manager').getProcessEx('explorer.exe');
if(pids.length == 1)
{
process.kill(pids[0]);
}
return (this.autoHide(tsid));
}
}
};
}
module.exports = new winutils();