在下面这篇博客里,我使用C#,写了一个命令,可以快捷的切换鼠标左右手习惯。
今天到了一个新环境,想用下这个命令,
却一时找不到编译好的文件,手头有没有visual studio的环境,
于是索性用Ruby将其重写,
原理一样, 都是调用win32 api修改左右收习惯,并修改注册表。
修改注册表的目的是,当电脑重启的时候, 我们的设置也依然有效。
Ruby脚本如下:
require "Win32API" require 'win32/registry' def switch_mouse_habit () sm_swapbutton = 23 # public const int SM_SWAPBUTTON = 23; mouseStatus = Win32API.new('user32.dll', 'GetSystemMetrics',['L'], 'L').call(sm_swapbutton) targetStatus = ( mouseStatus + 1 ) % 2 puts "original status: #{mouseStatus} ; target status: #{targetStatus}" Win32API.new('user32.dll', 'SwapMouseButton',['L'], 'L').call(targetStatus) # see: http://en.wikibooks.org/wiki/Ruby_Programming/Standard_Library/Win32::Registry name = Win32::Registry::HKEY_CURRENT_USER.create "Control Panel\\Mouse" #puts name["SwapMouseButtons"] name.write_s "SwapMouseButtons", targetStatus.to_s end switch_mouse_habit()
相关推荐
前端学 Ruby:熟悉 Ruby 语法
我用Ruby Watir库写的一个自动答题脚本,答题准确率在70%左右,学习Watir库练手之用,有兴趣的不妨看看,另外,谁有可以改进答题准确率的点子,望不吝赐教。此脚本可不是用来作弊的哦,用这个来答题,绝对通不过防...
Test Driven Development in Ruby: A Practical Introduction to TDD Using Problem and Solution Domain Analysis by Bala Paranj English | 5 Apr. 2017 | ISBN: 1484226372 | 288 Pages | PDF | 5.32 MB Learn ...
ruby ssh备份远程服务器脚本,主要是学习net/scp这个模块
ngx_ruby 是嵌入 ruby 脚本的 Nginx 模块
Ruby是一种功能强大的面向对象的脚本语言,可以使用它方便快捷地进行面向对象程序设计。与Perl类似,而且Ruby具有强大的文本处理功能,使文本处理变得简单。此外还可以方便地使用C语言来扩展Ruby的功能。
您可以直接使用Ruby Docker映像来运行Ruby脚本: $ docker run --rm -v " $PWD " :/app coopermaa/alpine-ruby ruby /app/your-daemon-or-script.rb 如何使用onbuild图像 在您的Ruby应用项目中创建一
"Ruby is perhaps best known as the engine powering the hugely popular Ruby on Rails web framework. However, it is an extremely powerful and versatile programming language in its own right. It focuses ...
Rust 与 Ruby:构建 API 这是 Rust 与 Ruby:构建 API 博客文章的存储库。 如何运行示例 git clone https://github.com/Sdogruyol/rust-vs-ruby Ruby Ruby版本:2.2.1 Ruby 服务器:瘦 1.6.3 框架:古巴 3.4.0 ...
ruby_install远程安装时出现HTTP_Response_302和404的解决办法
p6df-Ruby目录p6df-Ruby徽章概括贡献行为守则变化用法p6df-ruby:p6df-ruby / init.zsh: p6_ruby_prompt_info() p6df :: modules :: ruby :: deps() p6df :: modules :: ruby :: home :: symlink() ...
ruby脚本,用来分析case覆盖率,文件名,文件个数等等
模糊Ruby 编程中最困难的部分之一就是正确地拼写所有内容。 特别是在像Ruby这样的动态类型的语言中,单个错字可能会导致严重的运行时故障。 解决该问题的传统方法包括复杂的静态分析,繁琐的代码审查以及繁重的单元...
Learn the principles behind object-oriented programming and within a few chapters create a fully functional Ruby application. You'll also gain a basic understanding of many ancillary technologies such...
ruby脚本交互.rar
搭建redis集群,使用ruby脚本搭建集群。 redis-3.0.0.gem
Ruby 使用 ruby-build 构建... FROM invisiblelines/ruby:2.2.0 构建镜像 $ git clone https://github.com/invisiblelines/docker-ruby.git $ cd docker-ruby $ docker build -t ruby:2.2.0 . 执照 麻省理工学院
【Ruby】基于Ruby的MKS rebase脚本 Ruby语言基础 将MKS网盘中其他工程路径下的工程文件批量rebase到目标工程路径。 【Ruby】基于Ruby的MKS rebase脚本 Ruby语言基础