-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbasic_example.py
More file actions
35 lines (26 loc) · 928 Bytes
/
Copy pathbasic_example.py
File metadata and controls
35 lines (26 loc) · 928 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from connection import Connection
def main():
# Create the connection
c = Connection()
# Press some keys and move the mouse
c.req.press_keys.append("w")
c.req.press_keys.append("a")
c.req.mouse.x = 100
c.req.mouse.y = -10
# Send the request, Note that this also resets the
# fields in `c.req`, so we can reuse the same Connection object
c.send_request()
# Request human keyboard and mouse input and a screenshot of a window
c.req.get_keys = True
c.req.get_mouse = True
c.req.get_image = True
c.req.quality = 80
c.req.process_name = "explorer.exe"
# Send the request
resp = c.send_request()
print("Keys: {}".format(resp.pressed_keys))
print("Mouse: {}, {}".format(resp.mouse.x, resp.mouse.y))
with open("sample_image.jpg", "wb") as f:
f.write(resp.image)
if __name__ == "__main__":
main()