boaw 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/boaw/version.rb +1 -1
- data/lib/boaw.rb +9 -3
- data/lib/xdotool/adapter.rb +13 -20
- data/lib/xdotool/base_error.rb +10 -0
- data/lib/xdotool/position_parser.rb +15 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce2bc4bae1fef75c28ea59cb3b7691c32b3e3bf933eebf08342596dfbedf54a1
|
4
|
+
data.tar.gz: 83ef9f64f397aa3afdfd0810cd0985c99f65fdbb30c79f348b195f0ba114a29a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39334c482e475042fb7ddbfecf3cfb428c62285d05fda65c78c1fcad6af53ab9d84e6dfb7a7bd6563149c3c889ffb5c95b6b356847229d366c91ef981f7fba19
|
7
|
+
data.tar.gz: 6d5390889608eb0659f2b6e466dada0a8894d0cf481610bc7f9fabec79e551f20ee92c86a3467894338937344e5bf1182a59b25e99233e8e7f1f33ccd6f53ff9
|
data/lib/boaw/version.rb
CHANGED
data/lib/boaw.rb
CHANGED
@@ -2,10 +2,8 @@
|
|
2
2
|
|
3
3
|
require_relative 'xdotool/adapter'
|
4
4
|
|
5
|
-
#
|
5
|
+
# The main class from which work with the program begins
|
6
6
|
class Boaw
|
7
|
-
attr_reader :adapter
|
8
|
-
|
9
7
|
def initialize
|
10
8
|
@adapter = Xdotool::Adapter.new
|
11
9
|
end
|
@@ -17,4 +15,12 @@ class Boaw
|
|
17
15
|
def left_click(position)
|
18
16
|
adapter.left_click(position)
|
19
17
|
end
|
18
|
+
|
19
|
+
def right_click(position)
|
20
|
+
adapter.right_click(position)
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
attr_reader :adapter
|
20
26
|
end
|
data/lib/xdotool/adapter.rb
CHANGED
@@ -1,35 +1,28 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative 'position_parser'
|
4
|
+
require_relative 'base_error'
|
5
|
+
|
3
6
|
module Xdotool
|
4
7
|
# Xdotool adapter for mouse control
|
5
8
|
class Adapter
|
6
|
-
def
|
7
|
-
system('xdotool
|
9
|
+
def initialize
|
10
|
+
result = Kernel.system('xdotool')
|
11
|
+
raise BaseError if result.nil?
|
12
|
+
end
|
8
13
|
|
9
|
-
|
14
|
+
def position
|
15
|
+
output = IO.popen('xdotool getmouselocation', &:read)
|
10
16
|
|
11
|
-
|
12
|
-
x: current_position['x'].to_i,
|
13
|
-
y: current_position['y'].to_i
|
14
|
-
}
|
17
|
+
PositionParser.parse(output)
|
15
18
|
end
|
16
19
|
|
17
20
|
def left_click(position)
|
18
|
-
system("xdotool mousemove #{position[:x]} #{position[:y]} click 1")
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def parse_position
|
24
|
-
file = File.open('./temp.txt', 'r')
|
25
|
-
position = file.gets.scan(/(\w+):(\d+)/).to_h
|
26
|
-
file.close
|
27
|
-
delete_temp_file
|
28
|
-
position
|
21
|
+
Kernel.system("xdotool mousemove #{position[:x]} #{position[:y]} click 1")
|
29
22
|
end
|
30
23
|
|
31
|
-
def
|
32
|
-
|
24
|
+
def right_click(position)
|
25
|
+
Kernel.system("xdotool mousemove #{position[:x]} #{position[:y]} click 3")
|
33
26
|
end
|
34
27
|
end
|
35
28
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Xdotool
|
4
|
+
# coordinate position parser from Xdotool
|
5
|
+
class PositionParser
|
6
|
+
def self.parse(position)
|
7
|
+
hash_position = position.scan(/(\w+):(\d+)/).to_h
|
8
|
+
|
9
|
+
{
|
10
|
+
x: hash_position['x'].to_i,
|
11
|
+
y: hash_position['y'].to_i
|
12
|
+
}
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: boaw
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kirill Leonov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-11-
|
11
|
+
date: 2023-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: The library will allow you to create auto-clickers for Unix systems
|
14
14
|
email: leonov7632@gmail.com
|
@@ -19,6 +19,8 @@ files:
|
|
19
19
|
- lib/boaw.rb
|
20
20
|
- lib/boaw/version.rb
|
21
21
|
- lib/xdotool/adapter.rb
|
22
|
+
- lib/xdotool/base_error.rb
|
23
|
+
- lib/xdotool/position_parser.rb
|
22
24
|
homepage: https://github.com/leonovk/boaw
|
23
25
|
licenses:
|
24
26
|
- MIT
|
@@ -41,7 +43,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
41
43
|
- !ruby/object:Gem::Version
|
42
44
|
version: '0'
|
43
45
|
requirements: []
|
44
|
-
rubygems_version: 3.4.
|
46
|
+
rubygems_version: 3.4.21
|
45
47
|
signing_key:
|
46
48
|
specification_version: 4
|
47
49
|
summary: Mouse manipulation library
|