-
Notifications
You must be signed in to change notification settings - Fork 5
/
change_wallpaper.py
70 lines (57 loc) · 2.09 KB
/
change_wallpaper.py
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Download and change wallpaper (Windows 10)
import os
import time
import HID
from HID import CODE
if __name__ == '__main__':
HID.press(bytes([CODE.LEFT_CTRL, 0, CODE.ESC, *[0] * 5]))
time.sleep(0.1)
# open web browser with this URL
cmd = 'chrome http://www.thecuriosityworkshop.com/wp-content/uploads/2015/03/01-rubberduck-hongkong.jpg'
HID.type_string(cmd)
time.sleep(1.0)
HID.press(bytes([*[0] * 2, CODE.ENTER, *[0] * 5]))
time.sleep(5.0)
HID.press(bytes([CODE.LEFT_CTRL, 0, CODE.KEY_S, *[0] * 5]))
time.sleep(1.0)
# save location
# for Chrome: %USERPROFILE%\Downloads\01-rubberduck-hongkong.jpg
cmd = '%USERPROFILE%\\Downloads\\01-rubberduck-hongkong.jpg'
HID.type_string(cmd)
time.sleep(0.2)
HID.press(bytes([*[0] * 2, CODE.ENTER, *[0] * 5]))
time.sleep(0.5)
# TAB to move focus to Show all Downloads (Chrome)
# HID.press(bytes([*[0] * 2, CODE.TAB, *[0] * 5]))
# time.sleep(0.2)
# HID.press(bytes([*[0] * 2, CODE.ENTER, *[0] * 5]))
# or Ctrl + J
HID.press(bytes([CODE.LEFT_CTRL, 0, CODE.KEY_J, *[0] * 5]))
time.sleep(1.0)
# press tab 2 times to move focus to the latest download
for _ in range(2):
HID.press(bytes([*[0] * 2, CODE.TAB, *[0] * 5]))
time.sleep(0.5)
# open the image using default Windows image viewer (Photo)
HID.press(bytes([*[0] * 2, CODE.ENTER, *[0] * 5]))
time.sleep(3.0)
# press tab 11 times
for _ in range(11):
HID.press(bytes([*[0] * 2, CODE.TAB, *[0] * 5]))
time.sleep(0.5)
HID.press(bytes([*[0] * 2, CODE.ENTER, *[0] * 5]))
time.sleep(0.5)
# press down 6 times
for _ in range(6):
HID.press(bytes([*[0] * 2, CODE.KEY_DOWN, *[0] * 5]))
time.sleep(0.5)
HID.press(bytes([*[0] * 2, CODE.ENTER, *[0] * 5]))
time.sleep(0.5)
HID.press(bytes([*[0] * 2, CODE.KEY_DOWN, *[0] * 5]))
time.sleep(0.5)
HID.press(bytes([*[0] * 2, CODE.ENTER, *[0] * 5]))
time.sleep(0.5)
# close 2 windows
for _ in range(2):
HID.press(bytes([CODE.LEFT_ALT, 0, CODE.F4, *[0] * 5]))
time.sleep(1.0)