-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.py
More file actions
45 lines (40 loc) · 1.46 KB
/
code.py
File metadata and controls
45 lines (40 loc) · 1.46 KB
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
# Copyright (c) 2025 ComputerL (@1ComputerL)
# Licensed under the MIT License. See LICENSE file in the project root for full license information.
# this circuitpython code is meant to run on a pico but should work on any microcontroller with usb
# when connected to the typical windows computer, it opens an html file in the microcontroller's storage and displays it
# in microsoft edge on the computer
### IMPORTS ###
import usb_hid
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keycode import Keycode
from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS
import time
### OPEN HTML FILE ###
# wait for an annoying file manager window to pop up
time.sleep(12)
# create keyboard object (for entering keycodes)
kbd = Keyboard(usb_hid.devices)
# create layout object (for entering text)
layout = KeyboardLayoutUS(kbd)
# open a PowerShell window via Win+R
kbd.send(Keycode.GUI, Keycode.R) # Win+R = Run dialog
# delay
time.sleep(1)
# (optional extra Enter if needed)
kbd.send(Keycode.ENTER)
# delay
time.sleep(1)
# enter the powershell command into the run dialouge
layout.write("powershell")
# delay
time.sleep(1)
# run the command
kbd.send(Keycode.ENTER)
# let powershell load for a few seconds
time.sleep(5)
# write the command to open 'index.html' on the circuitpython drive
layout.write("""Start-Process "msedge.exe" -ArgumentList @("--new-window","--start-fullscreen","file:///D:/index.html")""")
# delay
time.sleep(0.5)
# enter the command
kbd.send(Keycode.ENTER)