-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhsb_profile_checker.py
68 lines (54 loc) · 1.99 KB
/
hsb_profile_checker.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
# -*- coding: utf-8 -*-
"""
Filename: hsb_profile_checker.py
Date created: Wed Nov 25 16:19:56 2020
@author: Julio Hong
Purpose: Search the selected name to find profile on sky.lea.moe
Maybe scrape important data in future
https://nitratine.net/blog/post/how-to-make-hotkeys-in-python/#creating-the-script
Steps:
0. Copy the selected username
(Or link to Ctrl-C to read from the clipboard)
1. Set up a custom hotkey
2. Copy selected username into clipboard?
3. Pass username to sky.lea.moe
"""
from pynput import keyboard
import pyperclip
from selenium import webdriver
# For background (headless) Chromium window
from selenium.webdriver.chrome.options import Options
CHROME_PATH = '/usr/bin/google-chrome'
CHROMEDRIVER_PATH = '/usr/bin/chromedriver'
WINDOW_SIZE = "1920,1080"
chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--window-size=%s" % WINDOW_SIZE)
chrome_options.binary_location = CHROME_PATH
driver = webdriver.Chrome(executable_path=CHROMEDRIVER_PATH,
chrome_options=chrome_options
)
driver.get("https://www.google.com")
driver.get_screenshot_as_file("capture.png")
driver.close()
# The key combination to check
# Use 'S' for 'Search'
COMBINATIONS = [
{keyboard.Key.shift, keyboard.KeyCode(char='s')},
{keyboard.Key.shift, keyboard.KeyCode(char='S')}
]
# The currently active modifiers
current = set()
def execute():
print ("Do Something")
def on_press(key):
if any([key in COMBO for COMBO in COMBINATIONS]):
# if any([key in COMBO for COMBO in COMBINATIONS]) and not key in current:
current.add(key)
if any(all(k in current for k in COMBO) for COMBO in COMBINATIONS):
execute()
def on_release(key):
if any([key in COMBO for COMBO in COMBINATIONS]):
current.remove(key)
with keyboard.Listener(on_press=on_press, on_release=on_release) as listener:
listener.join()