Currently, my method of launching Firefox is as follows:
var exe = FileUtils.getFile('XREExeF', []); //this provides the path to the executable
var process = Cc['@mozilla.org/process/util;1'].createInstance(Ci.nsIProcess);
process.init(exe);
var args = ['-P', profName, '-no-remote']; //-new-instance
if (url) {
args.push('about:home');
args.push(url);
}
process.run(false, args, args.length);
As it stands, this launches Firefox in the foreground.
I am interested in launching it in the background and then bringing it into focus after a delay of around 5 seconds. (note: currently, it launches when the user clicks "Create New Profile," and I aim to enable them to name the profile while it works in the background. When the user finishes renaming by pressing enter or escape/blur, the window should then come into focus)
Is it possible to achieve this delayed focus without using js-ctypes?
If I decide to use js-ctypes, my idea is to retrieve the pid
attribute from the run
function and then move it to the background before focusing it later. However, there may be an issue with moving it to the background using WinAPI, and I'm unsure about other operating systems. (Mozilla Developer Network states that pid
may not be available on all operating systems - is it accessible on macOS and Linux?)