Open AmadeusDeadDmytro opened 6 months ago
Yes, unfortunately, the documentation may have been lacking in that regard. A sample string could be <screen module="\device\harddiskvolume4\users\meso\appdata\local\slack\app-4.37.98\slack.exe" window="general (Channel) - SplitmediaLabs Limited - Slack" class="Chrome_WidgetWin_1" desktop="" hwnd="133558" wclient="1" left="0" top="0" width="0" height="0">
where available screens and their details can be fetched via xjs.System.getAvailableScreens
. The said method, getAvailableScreens, however, is currently broken since XBC v.4.5.2307.1301 due to the move from using XSplitScriptPlugin.dll
to Xjs.dll
For the latest XBC versions, the following code can be used to fetch for available windows (getWindows
) and available monitors (getMonitors
) : (Oh, and apologies, as we are about to dig deeper here)
const oldAsyncDllCallback = window.OnDllCallback;
window.OnDllCallback = (funcName, asyncID, result) => {
let callback = window.ownDllCallBacks[asyncID];
if (callback instanceof Function) {
callback(decodeURIComponent(result));
delete window.ownDllCallBacks[asyncID];
}
if(typeof oldAsyncDllCallback === 'function') {
oldAsyncDllCallback(funcName, asyncID, result);
}
};
const execDll = (funcName, ...args) => {
let callback = null;
let ret = false;
if (args.length > 0) {
callback = args[args.length - 1];
if (callback instanceof Function) {
args.pop();
} else {
callback = null;
}
}
if (
window.external &&
window.external[funcName] &&
window.external[funcName] instanceof Function
) {
ret = window.external[funcName](...args);
ret = ret.replace('async:', '');
}
// register callback if present
if (callback !== null) {
window.ownDllCallBacks[ret] = callback;
}
};
const execDllPromise = (funcName, ...args) => {
return new Promise(resolve => {
execDll('CallDll', funcName, ...args, resolve);
});
};
const getMonitors = async (isDetailed = false) => {
try {
const monitorsStr = await execDllPromise('XSplit.Monitor.Enum');
const monitors = monitorsStr.split('|');
return Promise.all(
monitors.map(async monitor => {
const [hwnd, left, top, width, height] = monitor.split(',').map(Number);
return {
id: await execDllPromise('XSplit.Monitor.GetId', String(hwnd)),
hwnd,
left,
top,
width,
height,
};
})
);
} catch (e) {
console.log('Error on fetch:', e);
return [];
}
};
const getWindows = async () => {
try {
const appsStr = await execDllPromise('XSplit.Window.GetList', '3');
const xmlParser = new DOMParser();
const windowListXMLDoc = xmlParser.parseFromString(appsStr, 'application/xml');
window.windowListXMLDoc = windowListXMLDoc;
const windowList = windowListXMLDoc.querySelector('windowList');
if (!windowList) return [];
const windows = windowList.querySelectorAll('window')
if (windows.length) {
var windowsArray = Array.prototype.slice.call(windows, 0);
return windowsArray
.sort((a, b) => a.getAttribute('title').localeCompare(b.getAttribute('title')))
.map(app => {
return {
id: app.getAttribute('processId'),
hwnd: app.getAttribute('hwnd'),
name: app.getAttribute('processName'),
title: app.getAttribute('title'),
path: app.getAttribute('processPath'),
};
});
}
return [];
} catch (e) {
console.log('Error on fetch:', e);
return [];
}
};
Will probably just use this same issue for fixing getAvailableScreens
I tring to change value in Screen capture, Documentation sad about XML string. Can you give me example such XML?
I try this, but no effect, just source crashed
`
`