Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
watchchange
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Cool Fire
watchchange
Commits
1f121394
Commit
1f121394
authored
6 years ago
by
Cool Fire
Browse files
Options
Downloads
Patches
Plain Diff
Add script to detect by threshold and script to get mouse pos.
parent
41b66d09
Branches
master
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
config.json
+9
-4
9 additions, 4 deletions
config.json
detect-thresh.py
+45
-0
45 additions, 0 deletions
detect-thresh.py
getmouse.py
+4
-0
4 additions, 0 deletions
getmouse.py
grabtest.py
+3
-3
3 additions, 3 deletions
grabtest.py
with
61 additions
and
7 deletions
config.json
+
9
−
4
View file @
1f121394
{
"outputloc"
:
[
1
0
0
,
1
00
],
"outputloc"
:
[
1
48
0
,
8
00
],
"outputtext"
:
"test"
,
"grabs"
:
[
[
100
,
100
,
20
],
[
200
,
200
,
20
],
[
300
,
300
,
20
]
[
1335
,
870
,
20
],
[
1260
,
210
,
20
],
[
1370
,
360
,
20
],
[
820
,
315
,
20
],
[
1301
,
501
,
20
],
[
525
,
187
,
20
],
[
861
,
510
,
20
],
[
434
,
826
,
20
]
]
}
This diff is collapsed.
Click to expand it.
detect-thresh.py
0 → 100644
+
45
−
0
View file @
1f121394
#!/usr/bin/env python2
from
PIL
import
ImageChops
from
pyscreenshot
import
grab
from
time
import
sleep
import
json
import
pyautogui
# Load config
with
open
(
'
config.json
'
)
as
c
:
conf
=
json
.
load
(
c
)
# Calculate box coordinates from x, y and radius
boxes
=
[]
for
g
in
conf
[
'
grabs
'
]:
boxes
.
append
(
(
g
[
0
]
-
g
[
2
],
g
[
1
]
-
g
[
2
],
g
[
0
]
+
g
[
2
],
g
[
1
]
+
g
[
2
])
)
# Grab starting images to compare
source
=
[]
for
i
,
b
in
enumerate
(
boxes
):
source
.
append
(
grab
(
bbox
=
b
).
convert
(
'
RGB
'
))
#source[i].show() # Useful for debugging box locations
# Main loop
while
True
:
dest
=
[]
sleep
(
1
)
for
i
,
b
in
enumerate
(
boxes
):
dest
.
append
(
grab
(
bbox
=
b
).
convert
(
'
RGB
'
))
#dest.append(ImageChops.difference(tmp, source[i]))
#diff.append(dest[i].getbbox())
# Write output if diffs are detected
for
i
,
d
in
enumerate
(
dest
):
diff
=
ImageChops
.
difference
(
source
[
i
],
dest
[
i
])
hist
=
diff
.
histogram
()
dico
=
len
(
filter
(
lambda
a
:
a
!=
0
,
hist
))
print
str
(
i
)
+
"
:
"
+
str
(
dico
)
if
dico
>
100
:
pyautogui
.
click
(
conf
[
'
outputloc
'
][
0
],
conf
[
'
outputloc
'
][
1
])
pyautogui
.
typewrite
(
conf
[
'
outputtext
'
])
print
'
I have done the deed!
'
exit
(
0
)
This diff is collapsed.
Click to expand it.
getmouse.py
0 → 100644
+
4
−
0
View file @
1f121394
#!/usr/bin/env python2
import
pyautogui
print
pyautogui
.
position
()
This diff is collapsed.
Click to expand it.
grabtest.py
+
3
−
3
View file @
1f121394
...
...
@@ -3,8 +3,8 @@
from
pyscreenshot
import
grab
loc
=
[
700
,
200
]
im
=
grab
(
bbox
=
(
loc
[
0
]
-
50
,
loc
[
1
]
-
50
,
loc
[
0
]
+
50
,
loc
[
1
]
+
50
))
loc
=
[
434
,
826
]
r
=
20
im
=
grab
(
bbox
=
(
loc
[
0
]
-
r
,
loc
[
1
]
-
r
,
loc
[
0
]
+
r
,
loc
[
1
]
+
r
))
im
.
show
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment