Skip to content

Instantly share code, notes, and snippets.

@satyr
Created November 13, 2009 21:14
Show Gist options
  • Save satyr/234163 to your computer and use it in GitHub Desktop.
Save satyr/234163 to your computer and use it in GitHub Desktop.
Ruby (→ MozRepl → js-ctypes → WIN32API/OLE) → Ubiquity
#!ruby
require 'net/telnet'
require 'win32ole'
prompt = /^repl> /
mozrepl = Net::Telnet.new 'Port'=> 4242, 'Prompt'=> prompt, 'Timeout'=> 5
mozrepl.waitfor prompt
res = ''
mozrepl.cmd(<<'JS'){|s| s.slice! prompt; res << s }
try {
let Cu = Components.utils;
let {ctypes: ct} = Cu.import("resource://gre/modules/ctypes.jsm", null);
let k32 = ct.open("kernel32");
let pid = k32.declare("GetCurrentProcessId", ct.stdcall_abi, ct.int32_t)();
k32.close();
let {Utils} = Cu.import('resource://ubiquity/modules/utils.js', null);
Utils.currentChromeWindow.gUbiquity.openWindow();
pid;
} catch(e){ Application.console.log(e); 0 }
JS
mozrepl.close
print res
WIN32OLE.new('WScript.Shell').AppActivate res
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment