Sha256: 9343b42c3d1d893d258fa28ffe778171d26086792ea57d2c1c26da3e25e6c8d1
Contents?: true
Size: 1.02 KB
Versions: 8
Compression:
Stored size: 1.02 KB
Contents
require 'rubygems' # ugh require 'ffi' module Muter # from msdn on keybd_event ... VK_VOLUME_DOWN = 0xAE VK_VOLUME_UP = 0xAF VK_VOLUME_MUTE = 0xAD KEYEVENTF_KEYUP = 2 extend FFI::Library ffi_lib 'user32' ffi_convention :stdcall attach_function :keybd_event, [ :uchar, :uchar, :int, :pointer ], :void def hit_mute_key # simulate pressing the mute key keybd_event(VK_VOLUME_MUTE, 0, 0, nil) keybd_event(VK_VOLUME_MUTE, 0, KEYEVENTF_KEYUP, nil) end def hit_volume_up_key keybd_event(VK_VOLUME_UP, 0, 0, nil) keybd_event(VK_VOLUME_UP, 0, KEYEVENTF_KEYUP, nil) end def hit_volume_down_key keybd_event(VK_VOLUME_DOWN, 0, 0, nil) keybd_event(VK_VOLUME_DOWN, 0, KEYEVENTF_KEYUP, nil) end def mute! #unmute! # just in case hit_mute_key end # TODO better for 7... def unmute! hit_mute_key # Windows XP... hit_volume_down_key hit_volume_up_key end # allow for Muter.xxx extend self end
Version data entries
8 entries across 8 versions & 1 rubygems