# Library imports
import pyautogui
import time
import json
import sys
import os


# Execute one mouse event
def execute_mouse_event(event):
    # If down direction
    if event['direction'] == 'down':
        # Pause python
        time.sleep(2)
        pyautogui.mouseDown(button=event['button'], x=event['position'][0], y=event['position'][1])

    # If up direction
    if event['direction'] == 'up':
        pyautogui.mouseUp(button=event['button'], x=event['position'][0], y=event['position'][1])


# Execute one mouse event
def execute_keyboard_event(event):
    # If ctrl/shift
    if event['key'] == 'shiftleft' or event['key'] == 'ctrlleft':
        # Press special key
        pyautogui.keyDown(event['key'])

        # Loop through nextKeys
        for next_key in event['nextKeys']:
            pyautogui.press(next_key)

    # For any other key, just press
    pyautogui.press(event['key'])


# Get bot_file_path from electron
bot_name = sys.argv[1]
bot_file_path = os.path.join(os.getcwd(), bot_name + '.json')

# Load bot (passed in as argument by electron)
with open(bot_file_path) as bot_file:
    bot = json.load(bot_file)

    # Execute bot
    for event in bot['events']:
        # For mouse events
        if event['type'] == 'mouse':
            execute_mouse_event(event)

        # For keyboard events
        if event['type'] == 'keyboard':
            execute_keyboard_event(event)

# Exit program
exit(0)

ef2e105cfab752243dcabf991d4267259fe1d8c9
<mask token>


def execute_mouse_event(event):
    if event['direction'] == 'down':
        time.sleep(2)
        pyautogui.mouseDown(button=event['button'], x=event['position'][0],
            y=event['position'][1])
    if event['direction'] == 'up':
        pyautogui.mouseUp(button=event['button'], x=event['position'][0], y
            =event['position'][1])


def execute_keyboard_event(event):
    if event['key'] == 'shiftleft' or event['key'] == 'ctrlleft':
        pyautogui.keyDown(event['key'])
        for next_key in event['nextKeys']:
            pyautogui.press(next_key)
    pyautogui.press(event['key'])


<mask token>

<mask token>


def execute_mouse_event(event):
    if event['direction'] == 'down':
        time.sleep(2)
        pyautogui.mouseDown(button=event['button'], x=event['position'][0],
            y=event['position'][1])
    if event['direction'] == 'up':
        pyautogui.mouseUp(button=event['button'], x=event['position'][0], y
            =event['position'][1])


def execute_keyboard_event(event):
    if event['key'] == 'shiftleft' or event['key'] == 'ctrlleft':
        pyautogui.keyDown(event['key'])
        for next_key in event['nextKeys']:
            pyautogui.press(next_key)
    pyautogui.press(event['key'])


<mask token>
with open(bot_file_path) as bot_file:
    bot = json.load(bot_file)
    for event in bot['events']:
        if event['type'] == 'mouse':
            execute_mouse_event(event)
        if event['type'] == 'keyboard':
            execute_keyboard_event(event)
exit(0)

<mask token>


def execute_mouse_event(event):
    if event['direction'] == 'down':
        time.sleep(2)
        pyautogui.mouseDown(button=event['button'], x=event['position'][0],
            y=event['position'][1])
    if event['direction'] == 'up':
        pyautogui.mouseUp(button=event['button'], x=event['position'][0], y
            =event['position'][1])


def execute_keyboard_event(event):
    if event['key'] == 'shiftleft' or event['key'] == 'ctrlleft':
        pyautogui.keyDown(event['key'])
        for next_key in event['nextKeys']:
            pyautogui.press(next_key)
    pyautogui.press(event['key'])


bot_name = sys.argv[1]
bot_file_path = os.path.join(os.getcwd(), bot_name + '.json')
with open(bot_file_path) as bot_file:
    bot = json.load(bot_file)
    for event in bot['events']:
        if event['type'] == 'mouse':
            execute_mouse_event(event)
        if event['type'] == 'keyboard':
            execute_keyboard_event(event)
exit(0)

import pyautogui
import time
import json
import sys
import os


def execute_mouse_event(event):
    if event['direction'] == 'down':
        time.sleep(2)
        pyautogui.mouseDown(button=event['button'], x=event['position'][0],
            y=event['position'][1])
    if event['direction'] == 'up':
        pyautogui.mouseUp(button=event['button'], x=event['position'][0], y
            =event['position'][1])


def execute_keyboard_event(event):
    if event['key'] == 'shiftleft' or event['key'] == 'ctrlleft':
        pyautogui.keyDown(event['key'])
        for next_key in event['nextKeys']:
            pyautogui.press(next_key)
    pyautogui.press(event['key'])


bot_name = sys.argv[1]
bot_file_path = os.path.join(os.getcwd(), bot_name + '.json')
with open(bot_file_path) as bot_file:
    bot = json.load(bot_file)
    for event in bot['events']:
        if event['type'] == 'mouse':
            execute_mouse_event(event)
        if event['type'] == 'keyboard':
            execute_keyboard_event(event)
exit(0)

# Library imports
import pyautogui
import time
import json
import sys
import os


# Execute one mouse event
def execute_mouse_event(event):
    # If down direction
    if event['direction'] == 'down':
        # Pause python
        time.sleep(2)
        pyautogui.mouseDown(button=event['button'], x=event['position'][0], y=event['position'][1])

    # If up direction
    if event['direction'] == 'up':
        pyautogui.mouseUp(button=event['button'], x=event['position'][0], y=event['position'][1])


# Execute one mouse event
def execute_keyboard_event(event):
    # If ctrl/shift
    if event['key'] == 'shiftleft' or event['key'] == 'ctrlleft':
        # Press special key
        pyautogui.keyDown(event['key'])

        # Loop through nextKeys
        for next_key in event['nextKeys']:
            pyautogui.press(next_key)

    # For any other key, just press
    pyautogui.press(event['key'])


# Get bot_file_path from electron
bot_name = sys.argv[1]
bot_file_path = os.path.join(os.getcwd(), bot_name + '.json')

# Load bot (passed in as argument by electron)
with open(bot_file_path) as bot_file:
    bot = json.load(bot_file)

    # Execute bot
    for event in bot['events']:
        # For mouse events
        if event['type'] == 'mouse':
            execute_mouse_event(event)

        # For keyboard events
        if event['type'] == 'keyboard':
            execute_keyboard_event(event)

# Exit program
exit(0)
