#!/usr/bin/env ruby # source for a minimal executable # registers a global hotkey to launch stuff when pressing win+alt+f # (c) 2008 Y. Guillot, distributed under the wtfpl require 'metasm' cpu = Metasm::Ia32.new cpu = Metasm::X64.new if ARGV.delete('--64') Metasm::PE.compile_c(cpu, DATA.read).encode_file('winhotkey.exe') __END__ #include "winhotkey.h" int main(void) { MSG msg; RegisterHotKey(NULL, 'F', MOD_ALT|MOD_WIN, 'F'); RegisterHotKey(NULL, 'P', MOD_ALT|MOD_WIN, 'P'); while (GetMessage(&msg, NULL, 0, 0)) if (msg.message == WM_HOTKEY) { if (msg.wParam == 'F') WinExec("C:\\Users\\bob\\foo.exe", SW_SHOWDEFAULT); else if (msg.wParam == 'P') WinExec("\"C:\\Program Files\\bla.exe\" some_arg", SW_SHOWDEFAULT); } ExitProcess(0); return 0; }