-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
for #383 - capture/replay clicks testa
* save more info in capture * need app.replay_event() assumes we have shoes_native_move_cursor
- Loading branch information
Cecil
committed
Dec 16, 2017
1 parent
d25fa42
commit 8e1d885
Showing
2 changed files
with
56 additions
and
37 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
require 'yaml' | ||
Shoes.app do | ||
stack do | ||
tagline "Replay Clicks for another app" | ||
para "Load events from" | ||
flow do | ||
@sv = edit_line width: 450 | ||
@sv.text = "#{DIR}/events.yaml" | ||
button "Change" do | ||
path = ask_file_open | ||
@sv.text = path if path | ||
end | ||
end | ||
|
||
flow do | ||
button "Start App" do | ||
evtflhash = YAML::load_file(@sv.text) | ||
hdr = evtflhash[:context] | ||
puts hdr | ||
script = hdr[:app] | ||
eval IO.read(script).force_encoding("UTF-8"), TOPLEVEL_BINDING, script | ||
w2 = Shoes.APPS[-1] | ||
x = w2.left | ||
y = w2.top | ||
w2.move x+80, y-40 | ||
@events = evtflhash[:events] | ||
puts @events | ||
end | ||
end | ||
button "Replay Events" do | ||
w2 = Shoes.APPS[-1] | ||
delay = 0 | ||
@events.each_index do |r| | ||
ev = @events[r] | ||
t = ev[:time] | ||
delay = t if r == 0 | ||
wait = t - delay | ||
timer(wait) do | ||
puts "waited for #{wait}" | ||
puts " move to #{ev[:x]}, #{ev[:y]} and click " | ||
# want to call: w2.replay_event(:click, ev) | ||
# need native move_cursor ability | ||
end | ||
delay = t | ||
end | ||
end | ||
end | ||
end |