开发者

Bind Win7 Hotkeys to Chrome/FF javascript (Greasemonkey, native fns?)

I want to control a streaming music website with global hotkeys, so I can use the s开发者_如何转开发ite's player controls (play/pause/next/etc) while another application has focus. I can use Greasemonkey to do this on the site when the browser has focus. What I can't figure out is a bridge between OS-level hotkeys and Greasemonkey.

Any suggestions?

Edit 2011-02-04:

New method: https://gist.github.com/cc9cf651f341cc938852. The window switching was becoming a hassle and would glitch out occasionally, so I've added MozRepl to the stack (https://github.com/bard/mozrepl). Same idea, just targets a terminal with a Mozrepl instance, which controls Firefox.

Edit 2011-02-01:

AutoHotKey works well here. I put up a gist at https://gist.github.com/805417 for anyone else whom this might help.


Greasemonkey cannot do this.

I doubt that a Firefox or Chrome extension could do this.

A C, Python, etc. program probably could do it -- maybe coupled with an extension...


I found a bridge: AutoHotKey

This script I whipped up will look for a window with "Hype Machine" anywhere in the title. If successful, it will map ctrl+shift+[e|q|...] to functions that activate the Hype Machine window, send a certain keystroke command then alt+tab, which gets us back to our original window.

#SingleInstance force
SetTitleMatchMode 2 ; Anywhere in title
SetTitleMatchMode Fast
SendMode Input

#IfWinExist Hype Machine
{
    ^+d::
    WinActivate
    return

    ^+e::
    WinActivate
    WinWaitActive
    Send n !{Tab}
    return

    ^+q::
    WinActivate
    WinWaitActive
    Send p !{Tab}
    return
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜