|
阅读:2905回复:6
能弄个firegestures脚本,用记事本打开指定文件吗
我的目标是user.js,比如在X:\\firefox\\profile\\user.js
应该是可以的吧,类似的用IE打开当前链接好像还复杂一点,我这里连目标文件都不是变量 const IE_PATH = "C:\\Program Files\\Internet Explorer\\iexplore.exe";
var file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
file.initWithPath(IE_PATH);
if (!file.exists()) {
alert("File does not exist: " + IE_PATH);
return;
}
var process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);
try {
var args = [window.content.location.href];
process.init(file);
process.run(false, args, args.length);
}
catch (ex) {
alert("Failed to execute: " + IE_PATH);
} |
|
|
|
1楼#
发布于:2010-09-23 01:25
dindog:我的目标是user.js,比如在X:\\firefox\\profile\\user.js IE_PATH改为记事本路径,window.content.location.href改为目标文件路径,注意格式。 |
|
|
|
2楼#
发布于:2010-09-23 01:25
ithinc: OK!可以用profile的相对路径吗,我有2个配置文件夹,经常2边互相copy配置 搜索了一下,似乎是这个PorfD。。。。乱改了半小时不行 https://developer.mozilla.org/en/Code_s ... cial_files var file = Components.classes["@mozilla.org/file/directory_service;1"].
getService(Components.interfaces.nsIProperties).
get("ProfD", Components.interfaces.nsIFile); |
|
|
|
3楼#
发布于:2010-09-23 01:25
用file.path应该就可以了。 |
|
|
|
4楼#
发布于:2010-09-23 01:25
帮我看看这行该怎么改好吗。。。完全不懂,边学边改。现在这样能打开对应的profile文件夹了,但不知道怎么在后面加上文件名
var args = [ProfileDir]; var dirService = Components.classes["@mozilla.org/file/directory_service;1"].
getService(Components.interfaces.nsIProperties);
var ProfDirFile = dirService.get("ProfD", Components.interfaces.nsIFile);
var ProfileDir = ProfDirFile.path;
const IE_PATH = "C:\\windows\\notepad.exe";
var file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
file.initWithPath(IE_PATH);
if (!file.exists()) {
alert("File does not exist: " + IE_PATH);
return;
}
var process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);
try {
var args = [ProfileDir]; /*这行不知道怎么改。'ProfileDir\\user.js'这样不行 */
process.init(file);
process.run(false, args, args.length);
}
catch (ex) {
alert("Failed to execute: " + IE_PATH);
} |
|
|
|
5楼#
发布于:2010-09-23 01:25
帮我看看这行该怎么改好吗。。。完全不懂,边学边改。现在这样能打开对应的profile文件夹了,但不知道怎么在后面加上文件名 愿意动手就是好同学,呵呵。 ProfileDir + "\\user.js" |
|
|
|
6楼#
发布于:2010-09-23 01:25
|
|
|