def loadJSON():
    # Check the file and load it
    if os.path.isfile(args.words_file) is False:
        print('ERR: Words file not exist!')
        exit()

    if args.words_file2 is not None:
        if os.path.isfile(args.words_file2) is not False:
            words = loadWord(args.words_file)
            words2 = loadWord(args.words_file2)
            words.update(words2)
            # register the status of file in these moment
            files[args.words_file] = os.stat(args.words_file)
            files[args.words_file2] = os.stat(args.words_file2)
    else:
        words = loadWord(args.words_file)
        # register the status of file in these moment
        files[args.words_file] = os.stat(args.words_file)

    print(str(len(words)) + " words loaded")
    for (correct, wrongs) in words.items():
        for wrong in wrongs:
            if wrong != '':
                print('Loaded ' + wrong + ' with as: ' + correct)
                keyboard.add_abbreviation(wrong, ' ' + correct + ' ')
Exemple #2
0
    def test_abbreviation(self):
        keyboard.add_abbreviation("tm", "a")
        self.press("shift")
        self.click("t")
        self.release("shift")
        self.click("space")
        self.assertEqual(self.flush_events(), [])  # abbreviations should be case sensitive
        self.click("t")
        self.click("m")
        self.click("space")
        self.assertEqual(
            self.flush_events(),
            [
                (KEY_UP, "space"),
                (KEY_DOWN, "backspace"),
                (KEY_UP, "backspace"),
                (KEY_DOWN, "backspace"),
                (KEY_UP, "backspace"),
                (KEY_DOWN, "backspace"),
                (KEY_UP, "backspace"),
                (KEY_DOWN, "a"),
                (KEY_UP, "a"),
            ],
        )

        keyboard.add_abbreviation("TM", "A")
        self.press("shift")
        self.click("t")
        self.release("shift")
        self.click("m")
        self.click("space")
        self.assertEqual(self.flush_events(), [])
        self.press("shift")
        self.click("t")
        self.click("m")
        self.release("shift")
        self.click("space")
        self.assertEqual(
            self.flush_events(),
            [
                (KEY_UP, "space"),
                (KEY_DOWN, "backspace"),
                (KEY_UP, "backspace"),
                (KEY_DOWN, "backspace"),
                (KEY_UP, "backspace"),
                (KEY_DOWN, "backspace"),
                (KEY_UP, "backspace"),
                (KEY_DOWN, "shift"),
                (KEY_DOWN, "a"),
                (KEY_UP, "a"),
                (KEY_UP, "shift"),
            ],
        )
def main():
    cfg = load_config()
    for k, v in load_placeholders().items():
        keyboard.add_abbreviation(source_text=cfg['prefix'].replace('Â', '') +
                                  k,
                                  replacement_text=v,
                                  match_suffix=True,
                                  timeout=cfg['placeholder_timeout'])

    keyboard.add_hotkey(cfg['cbman_hotkey'],
                        callback=start_cbman,
                        suppress=True,
                        timeout=cfg['hotkey_timeout'])

    keyboard.wait()
Exemple #4
0
    def test_abbreviation(self):
        keyboard.add_abbreviation('tm', 'a')
        self.press('shift')
        self.click('t')
        self.release('shift')
        self.click('space')
        self.assertEqual(self.flush_events(),
                         [])  # abbreviations should be case sensitive
        self.click('t')
        self.click('m')
        self.click('space')
        self.assertEqual(self.flush_events(), [(KEY_UP, 'space'),
                                               (KEY_DOWN, 'backspace'),
                                               (KEY_UP, 'backspace'),
                                               (KEY_DOWN, 'backspace'),
                                               (KEY_UP, 'backspace'),
                                               (KEY_DOWN, 'backspace'),
                                               (KEY_UP, 'backspace'),
                                               (KEY_DOWN, 'a'), (KEY_UP, 'a')])

        keyboard.add_abbreviation('TM', 'A')
        self.press('shift')
        self.click('t')
        self.release('shift')
        self.click('m')
        self.click('space')
        self.assertEqual(self.flush_events(), [])
        self.press('shift')
        self.click('t')
        self.click('m')
        self.release('shift')
        self.click('space')
        self.assertEqual(self.flush_events(), [
            (KEY_UP, 'space'),
            (KEY_DOWN, 'backspace'),
            (KEY_UP, 'backspace'),
            (KEY_DOWN, 'backspace'),
            (KEY_UP, 'backspace'),
            (KEY_DOWN, 'backspace'),
            (KEY_UP, 'backspace'),
            (KEY_DOWN, 'shift'),
            (KEY_DOWN, 'a'),
            (KEY_UP, 'a'),
            (KEY_UP, 'shift'),
        ])
Exemple #5
0
keyboard.add_hotkey(101, lambda: open_spotify())
# F15
keyboard.add_hotkey(102, lambda: (add_win()))
# F16
keyboard.add_hotkey(103, lambda: (add_loss()))
# F17
keyboard.add_hotkey(104, lambda: play_error())
# F18

# F19
keyboard.add_hotkey(106, lambda: play_gg_sound())
# F20

# ABBREVIATIONS FOR SIMPLE QUICK TYPING
# GMAIL
keyboard.add_abbreviation('@@', '*****@*****.**')
# PROTONMAIL
keyboard.add_abbreviation('@@@', '*****@*****.**')
#Twitch
keyboard.add_abbreviation('TTV', 'https://twitch.tv/namastez')
# MISCELLANEOUS
keyboard.add_abbreviation('tm', u'™')
keyboard.add_abbreviation('cr', u'©')
keyboard.add_abbreviation('^^2', u'²')

play(system_online)  # Plays a sound when program starts
start_scoring()  # Makes sure the .txt files for scoring are reset
keyboard.hook(
    print_pressed_keys)  # Shows the value for currently pressed key in console
keyboard.wait()  # "While True"
Exemple #6
0
"""

author: @endormi

Keyboard abbreviations (type @.. and then press space)

"""

import keyboard

keyboard.add_abbreviation('@email', '*****@*****.**')
keyboard.add_abbreviation('@gh', 'your_github')
keyboard.add_abbreviation('@t', 'your_twitter')
keyboard.wait('esc')
Exemple #7
0
"""

Keyboard abbreviations (type @.. and then press space)

"""

import keyboard

keyboard.add_abbreviation('@email', '*****@*****.**')
keyboard.add_abbreviation('@yt', 'your_youtube')
keyboard.add_abbreviation('@gh', 'your_github')
keyboard.add_abbreviation('@t', 'your_twitter')
keyboard.add_abbreviation('@tw', 'your_twitch')
keyboard.add_abbreviation('@so', 'your_stackoverflow')
keyboard.add_abbreviation('@py', 'your_PyPi')
keyboard.add_abbreviation('@npm', 'your_npm')
keyboard.add_abbreviation('@red', 'your_reddit')
keyboard.add_abbreviation('@s', 'your_steam')
keyboard.wait('esc')
Exemple #8
0
#!/envs/drAIver/bin/python

import keyboard

#keyboard.add_hotkey('p', print)
while True:
    print(keyboard.is_pressed('p'))

keyboard.press_and_release('shift+s, space')

keyboard.write('The quick brown fox jumps over the lazy dog.')

keyboard.add_hotkey('ctrl+shift+a', print, args=('triggered', 'hotkey'))

# Press PAGE UP then PAGE DOWN to type "foobar".
keyboard.add_hotkey('page up, page down', lambda: keyboard.write('foobar'))

# Blocks until you press esc.
keyboard.wait('esc')

# Record events until 'esc' is pressed.
recorded = keyboard.record(until='esc')
# Then replay back at three times the speed.
keyboard.play(recorded, speed_factor=3)

# Type @@ then press space to replace with abbreviation.
keyboard.add_abbreviation('@@', '*****@*****.**')

# Block forever, like `while True`.
keyboard.wait()
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import keyboard

keyboard.add_abbreviation('aa', 'ά'.decode('utf-8'))
keyboard.add_abbreviation('ee', 'έ'.decode('utf-8'))
keyboard.add_abbreviation('hh', 'ή'.decode('utf-8'))
keyboard.add_abbreviation('ii', 'ί'.decode('utf-8'))
keyboard.add_abbreviation('oo', 'ό'.decode('utf-8'))
keyboard.add_abbreviation('yy', 'ύ'.decode('utf-8'))
keyboard.add_abbreviation('vv', 'ώ'.decode('utf-8'))

keyboard.add_abbreviation('iii', 'ϊ'.decode('utf-8'))
keyboard.add_abbreviation('yyy', 'ϋ'.decode('utf-8'))

keyboard.add_abbreviation('iiii', 'ΐ'.decode('utf-8'))
keyboard.add_abbreviation('yyyy', 'ΰ'.decode('utf-8'))

# Block forever, like `while True`.
keyboard.wait()
Exemple #10
0
    def start(self):
        self.paused = False
        hotkeys = self.settings.hotkeys
        special = self.settings.special
        abbrevations = self.settings.abbrevations

        if hotkeys['right_click']:
            keyboard.add_hotkey(
                hotkeys['right_click'],
                macros.right_click,
                args=(hotkeys['right_click'],),
                suppress=True,
            )
        if hotkeys['left_click']:
            keyboard.add_hotkey(
                hotkeys['left_click'],
                macros.left_click,
                args=(hotkeys['left_click'],),
                suppress=True,
            )
        if hotkeys['lower_difficulty']:
            keyboard.add_hotkey(
                hotkeys['lower_difficulty'], macros.lower_difficulty, suppress=True
            )
        if hotkeys['swap_armor']:
            keyboard.add_hotkey(
                hotkeys['swap_armor'],
                macros.swap_armor,
                args=(special['armor_swap_amount'],),
                suppress=True,
            )
        if hotkeys['pause']:
            keyboard.add_hotkey(hotkeys['pause'], self.pause, suppress=True)
        if hotkeys['port_a1']:
            keyboard.add_hotkey(
                hotkeys['port_a1'], macros.port_town, args=(1,), suppress=True
            )
        if hotkeys['port_a2']:
            keyboard.add_hotkey(
                hotkeys['port_a2'], macros.port_town, args=(2,), suppress=True
            )
        if hotkeys['port_a3']:
            keyboard.add_hotkey(
                hotkeys['port_a3'], macros.port_town, args=(3,), suppress=True
            )
        if hotkeys['port_a4']:
            keyboard.add_hotkey(
                hotkeys['port_a4'], macros.port_town, args=(4,), suppress=True
            )
        if hotkeys['port_a5']:
            keyboard.add_hotkey(
                hotkeys['port_a5'], macros.port_town, args=(5,), suppress=True
            )
        if hotkeys['port_pool']:
            keyboard.add_hotkey(
                hotkeys['port_pool'],
                macros.port_pool,
                args=(PoolSpotList(self.settings.poolspots),),
                suppress=True,
            )
        if hotkeys['open_gr']:
            keyboard.add_hotkey(hotkeys['open_gr'], macros.open_gr, suppress=True)
        if hotkeys['upgrade_gem']:
            keyboard.add_hotkey(
                hotkeys['upgrade_gem'],
                macros.upgrade_gem,
                args=(special['empowered'], special['choose_gem']),
            )
        if hotkeys['leave_game']:
            keyboard.add_hotkey(hotkeys['leave_game'], macros.leave_game, suppress=True)
        if hotkeys['salvage']:
            keyboard.add_hotkey(
                hotkeys['salvage'],
                macros.salvage,
                args=(special['spare_columns'],),
                suppress=True,
            )
        if hotkeys['drop_inventory']:
            keyboard.add_hotkey(
                hotkeys['drop_inventory'],
                macros.drop_inventory,
                args=(special['spare_columns'],),
                suppress=True,
            )
        if hotkeys['gamble']:
            keyboard.add_hotkey(
                hotkeys['gamble'],
                macros.gamble,
                args=(special['gamble_item'],),
                suppress=True,
            )
        if hotkeys['cube_conv_sm']:
            keyboard.add_hotkey(
                hotkeys['cube_conv_sm'],
                macros.cube_conv_sm,
                args=(special['cube_conv_speed'],),
            )
        if hotkeys['cube_conv_lg']:
            keyboard.add_hotkey(
                hotkeys['cube_conv_lg'],
                macros.cube_conv_lg,
                args=(special['cube_conv_speed'],),
            )
        if hotkeys['reforge']:
            keyboard.add_hotkey(hotkeys['reforge'], macros.reforge, suppress=True)
        if hotkeys['skill_macro']:
            active_macro = self.settings.skill_macro['profiles'][
                self.settings.skill_macro['active']
            ]
            print(active_macro['name'])
            keyboard.add_hotkey(
                hotkeys['skill_macro'],
                macros.skill_macro,
                args=(active_macro['hotkeys'], active_macro['delays']),
                suppress=True,
            )

        if self.settings.special['abbrevations_enabled']:
            for abbrevation, msg in abbrevations.items():
                keyboard.add_abbreviation(abbrevation, msg)
Exemple #11
0
import keyboard

# registering a hotkey that replaces one typed text with another
# replaces every "@email" followed by a space with my actual email
keyboard.add_abbreviation("@email", "*****@*****.**")

# invokes a callback everytime a hotkey is pressed
keyboard.add_hotkey("ctrl+alt+p", lambda: print("CTRL+ALT+P Pressed!"))

# check if a ctrl is pressed
print(keyboard.is_pressed('ctrl'))

# press space
keyboard.send("space")

# sends artificial keyboard events to the OS
# simulating the typing of a given text
# setting 0.1 seconds to wait between keypresses to look fancy
keyboard.write("Python Programming is always fun!", delay=0.1)

# record all keyboard clicks until esc is clicked
events = keyboard.record('esc')
# play these events
keyboard.play(events)

# remove all keyboard hooks in use
keyboard.unhook_all()

Exemple #12
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

__author__ = 'ipetrash'


# pip install keyboard
import keyboard

# Type f**k then press space to replace with abbreviation.
keyboard.add_abbreviation('f**k', 'Furnification under consult of King')

# Block forever.
keyboard.wait()

try:
    #from keyboardmaster
    import keyboard

except ImportError:

    install('keyboard')
    import keyboard

# Blocks until you press esc.
#keyboard.wait('esc')

# Type string then press space to replace with abbreviation. eg: a+space
keyboard.add_abbreviation('a', '\u0905')
keyboard.add_abbreviation('aa', '\u0906')
keyboard.add_abbreviation('i', '\u0907')
keyboard.add_abbreviation('ii', '\u0908')
keyboard.add_abbreviation('u', '\u0909')
keyboard.add_abbreviation('uu', '\u090A')
keyboard.add_abbreviation('e', '\u090F')
keyboard.add_abbreviation('ai', '\u090E')
keyboard.add_abbreviation('o', '\u0913')
keyboard.add_abbreviation('au', '\u0914')
keyboard.add_abbreviation('R', '\u090B')
keyboard.add_abbreviation('k', '\u0915')
keyboard.add_abbreviation('kh', '\u0916')
keyboard.add_abbreviation('g', '\u0917')
keyboard.add_abbreviation('gh', '\u0918')
keyboard.add_abbreviation('ra', '\u0919')
import keyboard as k

try:
    f = open('config.txt', 'r')
    records = f.read()
    recs = records.split('\n')
    for i in recs:
        if (i != ''):
            data = i.split(':')
            k.add_abbreviation(data[0], data[1])
            print(data[0])
except IOError:
    print("Unable to find file: config.txt")
finally:
    f.close()
        words = json.load(json_file)
        return words

# Parse argument
parser = argparse.ArgumentParser(description='Scan your digited letter for wrong words and alert you!')
parser.add_argument('-words', action="store", dest='words_file', nargs='?', default=script_path + '/words/en.json', type=str)
parser.add_argument('-words2', action="store", dest='words_file2', nargs='?', default=script_path + '/words/it.json', type=str)
args = parser.parse_args()

# Check the file and load it
if os.path.isfile(args.words_file) is False:
    print('ERR: Words file not exist!')
    exit()

if args.words_file2 is not None:
    if os.path.isfile(args.words_file2) is not False:
        words = loadWord(args.words_file)
        words2 = loadWord(args.words_file2)
        words.update(words2)
else:
    words = loadWord(args.words_file)

print(str(len(words)) + " words loaded")
for (correct, wrongs) in words.items():
    for wrong in wrongs:
        if wrong != '':
            print('Loaded ' + wrong + ' with as: ' + correct)
            keyboard.add_abbreviation(wrong, ' ' + correct + ' ')

keyboard.wait()
import keyboard

# registering a hotkey that replaces one typed text with another
# replaces every "@email" followed by a space with my actual email
keyboard.add_abbreviation("@email", "*****@*****.**")

# invokes a callback everytime a hotkey is pressed
keyboard.add_hotkey("ctrl+alt+p", lambda: print("CTRL+ALT+P Pressed!"))

# check if a ctrl is pressed
print(keyboard.is_pressed('ctrl'))

# press and release space
keyboard.send("space")

# multi-key, windows+d as example shows the desktop in Windows machines
keyboard.send("windows+d")

# send ALT+F4 in the same time, and then send space,
# (be carful, this will close any current open window)
keyboard.send("alt+F4, space")

# press CTRL button
keyboard.press("ctrl")
# release the CTRL button
keyboard.release("ctrl")

# sends artificial keyboard events to the OS
# simulating the typing of a given text
# setting 0.1 seconds to wait between keypresses to look fancy
keyboard.write("Python Programming is always fun!", delay=0.1)
Exemple #17
0
#!/usr/bin/env python3
# coding:utf-8
import keyboard

keyboard.add_abbreviation("^g", "ĝ")

keyboard.add_abbreviation("^c", "ĉ")

keyboard.add_abbreviation("^h", "ĥ")

keyboard.add_abbreviation("^j", "ĵ")

keyboard.add_abbreviation("^s", "ŝ")

keyboard.add_abbreviation("^^u", "ŭ")

keyboard.wait()
Exemple #18
0
y = np.array(result)

keyboard.add_hotkey(
    'shift+"', lambda: (keyboard.write('"'), keyboard.release('shift'),
                        keyboard.press_and_release('left arrow')))
keyboard.add_hotkey(
    "'", lambda: (keyboard.write("'"), keyboard.release('shift'),
                  keyboard.press_and_release('left arrow')))
keyboard.add_hotkey(
    'shift+{', lambda: (keyboard.write('}'), keyboard.release('shift'),
                        keyboard.press_and_release('left arrow')))
keyboard.add_hotkey(
    '[', lambda: (keyboard.write(']'), keyboard.release('shift'),
                  keyboard.press_and_release('left arrow')))
keyboard.add_hotkey(
    'shift+(', lambda: (keyboard.write(')'), keyboard.release('shift'),
                        keyboard.press_and_release('left arrow')))

keyboard.add_abbreviation(x[0], y[0])
keyboard.add_abbreviation(x[1], y[1])
keyboard.add_abbreviation(x[2], y[2])
keyboard.add_abbreviation(x[3], y[3])
keyboard.add_abbreviation(x[4], y[4])
keyboard.add_abbreviation(x[5], y[5])
keyboard.add_abbreviation(x[6], y[6])
keyboard.add_abbreviation(x[7], y[7])
keyboard.add_abbreviation(x[8], y[8])
keyboard.add_abbreviation(x[9], y[9])

keyboard.wait('esc+shift+q')
Exemple #19
0
import keyboard
keyboard.add_hotkey('alt', lambda: keyboard.write(' ')) 
keyboard.add_abbreviation('silly', 'im flippn silly')
keyboard.wait()
Exemple #20
0
import keyboard

keyboard.add_abbreviation('"', '«»')
keyboard.add_abbreviation('tm', '™')
keyboard.add_abbreviation('[', '[]')
keyboard.add_abbreviation(']', '[]')
keyboard.add_abbreviation('ظظ', '؟')
keyboard.add_abbreviation('@@', '*****@*****.**')
keyboard.add_abbreviation('{', '{}')
keyboard.add_abbreviation('وو', '،')

while True:
    try:

        if keyboard.is_pressed('shift+9'):
            keyboard.write(")")

        elif keyboard.is_pressed('shift+0'):
            keyboard.write(")")

        else:
            pass

    except:
        break
                    type=str)
parser.add_argument('-words2',
                    action="store",
                    dest='words_file2',
                    nargs='?',
                    default=script_path + '/words/it.json',
                    type=str)
args = parser.parse_args()

# Check the file and load it
if os.path.isfile(args.words_file) is False:
    print('ERR: Words file not exist!')
    exit()

if args.words_file2 is not None:
    if os.path.isfile(args.words_file2) is not False:
        words = loadWord(args.words_file)
        words2 = loadWord(args.words_file2)
        words.update(words2)
else:
    words = loadWord(args.words_file)

print(str(len(words)) + " words loaded")
for (correct, wrongs) in words.items():
    for wrong in wrongs:
        if wrong != '':
            print('Loaded ' + wrong + ' with as: ' + correct)
            keyboard.add_abbreviation(wrong, ' ' + correct + ' ')

keyboard.wait()
def register(key, value, *args, **kwargs):
    add_abbreviation(key, value, *args, **kwargs)
    print(f'{datetime.now()}\t{key} → {value}')
Exemple #23
0
import keyboard
from tkinter import *
from tkinter import filedialog
from tkinter import font

root = Tk()
root.title("Yoruba Editor")
root.geometry("1100x1000")

global open_status_name
open_status_name = False

global selected
selected = False

keyboard.add_abbreviation('a+', 'á', match_suffix=True)
keyboard.add_abbreviation('e+', 'é', match_suffix=True)
keyboard.add_abbreviation('e+q', 'ẹ́', match_suffix=True)
keyboard.add_abbreviation('i+', 'í', match_suffix=True)
keyboard.add_abbreviation('o+', 'ó', match_suffix=True)
keyboard.add_abbreviation('o+q', 'ọ́', match_suffix=True)
keyboard.add_abbreviation('u+', 'ú', match_suffix=True)

keyboard.add_abbreviation('a=', 'à', match_suffix=True)
keyboard.add_abbreviation('e=', 'è', match_suffix=True)
keyboard.add_abbreviation('e=q', 'ẹ̀', match_suffix=True)
keyboard.add_abbreviation('i=', 'ì', match_suffix=True)
keyboard.add_abbreviation('o=', 'ò', match_suffix=True)
keyboard.add_abbreviation('o=q', 'ọ̀', match_suffix=True)
keyboard.add_abbreviation('u=', 'ù', match_suffix=True)