Fixed bug, cleaned up routes

This commit is contained in:
Maxim Stewart 2020-06-29 18:31:57 -05:00
parent 52b3b5ddc0
commit 3ecee5be77
4 changed files with 73 additions and 59 deletions

View File

@ -10,8 +10,6 @@ from core import app, socketio # Get from __init__
from core.MessageHandler import MessageHandler # Get simple message processor from core.MessageHandler import MessageHandler # Get simple message processor
msgHandler = MessageHandler() msgHandler = MessageHandler()
TITLE = app.config['TITLE'] TITLE = app.config['TITLE']
@ -32,61 +30,6 @@ def home():
message='Must use GET request type...') message='Must use GET request type...')
@app.route('/mouse-down')
@socketio.on('mouse_down')
def mouseDown(eve = None):
pyautogui.mouseDown()
return ""
@app.route('/mouse-up')
@socketio.on('mouse_up')
def mouseUp(eve = None):
pyautogui.mouseUp()
return ""
@app.route('/left-click')
@socketio.on('left_click')
def leftClick(eve = None):
pyautogui.click()
return ""
@app.route('/right-click')
@socketio.on('right_click')
def rightClick(eve = None):
pyautogui.click(button='right')
return ""
@app.route('/scroll-up')
@socketio.on('scroll_up')
def scrollUp(eve = None):
pyautogui.scroll(1)
return ""
@app.route('/scroll-down')
@socketio.on('scroll_down')
def scrollDown(eve = None):
pyautogui.scroll(-1)
return ""
@app.route('/get-coords')
def getCoords():
x, y = pyautogui.position();
return '{"x": "'+ str(x) +'", "y":"' + str(y) + '"}'
@socketio.on('update_coords')
def updateCoords(message):
try:
parts = message.split(",")
x = float( parts[0] )
y = float( parts[1] )
# print(str(x) + "," + str(y))
pyautogui.moveRel(x, y);
except Exception as e:
print( repr(e) )
@app.route('/update-coords/xy/<x>/<y>') @app.route('/update-coords/xy/<x>/<y>')
def updateCoords2(x, y): def updateCoords2(x, y):
try: try:

View File

@ -0,0 +1,70 @@
# Python imports
# Lib imports
import pyautogui
from flask import request, render_template
# App imports
from core import app, socketio # Get from __init__
from core.MessageHandler import MessageHandler # Get simple message processor
msgHandler = MessageHandler()
pyautogui.FAILSAFE = False # If we hit corner, that's ok
# Let piautogui make updates as quick as it can...
pyautogui.MINIMUM_DURATION = 0
pyautogui.PAUSE = 0
@app.route('/mouse-down')
@socketio.on('mouse_down')
def mouseDown(eve = None):
pyautogui.mouseDown()
return ""
@app.route('/mouse-up')
@socketio.on('mouse_up')
def mouseUp(eve = None):
pyautogui.mouseUp()
return ""
@app.route('/left-click')
@socketio.on('left_click')
def leftClick(eve = None):
pyautogui.click()
return ""
@app.route('/right-click')
@socketio.on('right_click')
def rightClick(eve = None):
pyautogui.click(button='right')
return ""
@app.route('/scroll-up')
@socketio.on('scroll_up')
def scrollUp(eve = None):
pyautogui.scroll(1)
return ""
@app.route('/scroll-down')
@socketio.on('scroll_down')
def scrollDown(eve = None):
pyautogui.scroll(-1)
return ""
@socketio.on('update_coords')
def updateCoords(message):
try:
parts = message.split(",")
x = float( parts[0] )
y = float( parts[1] )
# print(str(x) + "," + str(y))
pyautogui.moveRel(x, y);
except Exception as e:
print( repr(e) )

View File

@ -1 +1,2 @@
from . import Routes from . import Routes
from . import Sockets

View File

@ -125,7 +125,7 @@ function scrollToggle() {
} }
function scrollToggle() { function holdToggle() {
if (isHoldingMouse) { if (isHoldingMouse) {
isHoldingMouse = false; isHoldingMouse = false;
mouseHoldToggle.classList.add("btn-success"); mouseHoldToggle.classList.add("btn-success");
@ -159,4 +159,4 @@ document.getElementById("leftClickBtn").addEventListener("mouseup", leftClick, t
document.getElementById("rightClickBtn").addEventListener("mouseup", rightClick, true); document.getElementById("rightClickBtn").addEventListener("mouseup", rightClick, true);
document.getElementById("scrollToggle").addEventListener("mouseup", scrollToggle, true); document.getElementById("scrollToggle").addEventListener("mouseup", scrollToggle, true);
document.getElementById("mouseHoldToggle").addEventListener("mouseup", mouseHoldToggle, true); document.getElementById("mouseHoldToggle").addEventListener("mouseup", holdToggle, true);