lib/muter.rb in sensible-cinema-0.21.5 vs lib/muter.rb in sensible-cinema-0.21.9
- old
+ new
@@ -15,10 +15,12 @@
You should have received a copy of the GNU General Public License
along with Sensible Cinema. If not, see <http://www.gnu.org/licenses/>.
=end
require 'rubygems' # ugh
require 'ffi'
+require 'sane'
+require_relative 'mouse'
module Muter
# from msdn on keybd_event ...
VK_VOLUME_DOWN = 0xAE
@@ -46,19 +48,31 @@
def hit_volume_down_key
keybd_event(VK_VOLUME_DOWN, 0, 0, nil)
keybd_event(VK_VOLUME_DOWN, 0, KEYEVENTF_KEYUP, nil)
end
+ @@use_mouse = false # ai ai
+
def mute!
- #unmute! # just in case
- hit_mute_key
+ #unmute! # just in case...somehow this was causing problems...windows 7 perhaps? VLC?
+ # anyway we just use a toggle for now...dangerous but works, if barely
+ if !@@use_mouse
+ hit_mute_key
+ else
+ Mouse.single_click_left_mouse_button
+ end
end
# TODO better for doze 7...
def unmute!
- hit_mute_key # Windows XP...
- hit_volume_down_key
- hit_volume_up_key
+ if !@@use_mouse
+ hit_mute_key # Windows XP...
+ hit_volume_down_key
+ hit_volume_up_key
+ else
+ Mouse.single_click_left_mouse_button
+ end
+
end
# allow for Muter.xxx
extend self