Created
March 19, 2015 10:43
-
-
Save smison/ead363b4277c3da6e978 to your computer and use it in GitHub Desktop.
Windowsマウス移動スクリプト
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
require 'Win32API' | |
get_cursor_pos = Win32API.new("user32", "GetCursorPos", ['p'], 'v') | |
$set_cursor_pos = Win32API.new("user32", "SetCursorPos", ['i']*2, 'v') | |
input_point = " " * 8 | |
get_cursor_pos.Call(input_point) | |
x, y = input_point.unpack("LL") | |
puts "grid: #{x}, #{y}" | |
def setm(new_xy) | |
$set_cursor_pos.Call(new_xy[0], new_xy[1]) | |
end | |
100.times{ | |
setm([rand * 800, rand * 600]) | |
sleep 0.01 | |
} | |
# 参考文献 | |
# http://startnews24.com/?p=23035 | |
# http://nijzero.dw.land.to/document/labo/ruby.html | |
# https://www.ruby-forum.com/topic/101280 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment