清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
#!/usr/bin/env ruby # -*- coding: gb18030 -*- # __FILE__ : ctrlvol.rb # 2012-7 # ruby 1.9.3 #参考 http://blog.163.com/fengchaotian_007/blog/static/66572109201152263615209/ # require 'rubygems' require 'windows/window' include Windows::Window require 'windows/window/message.rb' include Windows::Window::Message $: << '.' require 'hotkey.rb' class VolSet WM_APPCOMMAND = 0x319; APPCOMMAND_VOLUME_UP = 0x0a; APPCOMMAND_VOLUME_DOWN = 0x09; APPCOMMAND_VOLUME_MUTE = 0x08; def hwnd GetForegroundWindow() end def up SendMessage(hwnd, WM_APPCOMMAND, 0x30292, APPCOMMAND_VOLUME_UP * 0x10000); end def down SendMessage(hwnd, WM_APPCOMMAND, 0x30292, APPCOMMAND_VOLUME_DOWN * 0x10000); end def mute SendMessage(hwnd, WM_APPCOMMAND, 0x200eb0, APPCOMMAND_VOLUME_MUTE * 0x10000); end end if $0 == __FILE__ V=VolSet.new 32.times {V.down;sleep 0.01 } 32.times {V.up;sleep 0.01 } 2.times {V.mute;sleep 0.5 } end