dindog
千年狐狸
千年狐狸
  • UID30818
  • 注册日期2009-10-24
  • 最后登录2025-02-19
  • 发帖数1201
  • 经验67枚
  • 威望0点
  • 贡献值34点
  • 好评度10点
阅读:2648回复:6

能弄个firegestures脚本,用记事本打开指定文件吗

楼主#
更多 发布于:2010-09-23 01:25
我的目标是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);
}
以前firefox跳个票的时间现在可以发布几个正式版了-_-
ithinc
狐狸大王
狐狸大王
  • UID22844
  • 注册日期2008-02-04
  • 最后登录2014-09-28
  • 发帖数371
  • 经验10枚
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 社区居民
1楼#
发布于:2010-09-23 01:25
dindog:我的目标是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);
}
回到原帖

IE_PATH改为记事本路径,window.content.location.href改为目标文件路径,注意格式。
Tab Utilities的功能要求,请提交到http://tabutils.uservoice.com
dindog
千年狐狸
千年狐狸
  • UID30818
  • 注册日期2009-10-24
  • 最后登录2025-02-19
  • 发帖数1201
  • 经验67枚
  • 威望0点
  • 贡献值34点
  • 好评度10点
2楼#
发布于:2010-09-23 01:25
ithinc
IE_PATH改为记事本路径,window.content.location.href改为目标文件路径,注意格式。
回到原帖

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);
以前firefox跳个票的时间现在可以发布几个正式版了-_-
ithinc
狐狸大王
狐狸大王
  • UID22844
  • 注册日期2008-02-04
  • 最后登录2014-09-28
  • 发帖数371
  • 经验10枚
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 社区居民
3楼#
发布于:2010-09-23 01:25

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);

用file.path应该就可以了。
Tab Utilities的功能要求,请提交到http://tabutils.uservoice.com
dindog
千年狐狸
千年狐狸
  • UID30818
  • 注册日期2009-10-24
  • 最后登录2025-02-19
  • 发帖数1201
  • 经验67枚
  • 威望0点
  • 贡献值34点
  • 好评度10点
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);
}
以前firefox跳个票的时间现在可以发布几个正式版了-_-
ithinc
狐狸大王
狐狸大王
  • UID22844
  • 注册日期2008-02-04
  • 最后登录2014-09-28
  • 发帖数371
  • 经验10枚
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 社区居民
5楼#
发布于:2010-09-23 01:25
帮我看看这行该怎么改好吗。。。完全不懂,边学边改。现在这样能打开对应的profile文件夹了,但不知道怎么在后面加上文件名

愿意动手就是好同学,呵呵。
ProfileDir + "\\user.js"
Tab Utilities的功能要求,请提交到http://tabutils.uservoice.com
dindog
千年狐狸
千年狐狸
  • UID30818
  • 注册日期2009-10-24
  • 最后登录2025-02-19
  • 发帖数1201
  • 经验67枚
  • 威望0点
  • 贡献值34点
  • 好评度10点
6楼#
发布于:2010-09-23 01:25
ithinc
愿意动手就是好同学,呵呵。
ProfileDir + "\\user.js"
回到原帖

bingo......谢谢
以前firefox跳个票的时间现在可以发布几个正式版了-_-
游客

返回顶部