Consolidated call and removed method

This commit is contained in:
Maxim Stewart 2020-11-22 22:36:47 -06:00
parent b2f53b5917
commit 62c678ff68
2 changed files with 14 additions and 47 deletions

View File

@ -24,49 +24,12 @@ def home():
message='Must use GET request type...')
@app.route('/sound-manager')
def soundManager():
if request.method == 'GET':
# command = 'runuser -l abaddon bash -c "pacmd list-sink-inputs"'
command = 'sudo -u abaddon bash -c "pacmd list-sink-inputs"'
# command = 'sudo -u abaddon bash <<EOF pacmd list-sink-inputs EOF'
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
result = process.wait()
print(process.stdout.read())
_apps = []
return render_template('sound-manager.html',
apps=_apps)
return render_template('error.html',
title='Error!',
message='Must use GET request type...')
@app.route('/update-coords/xy/<x>/<y>')
def updateCoords2(x, y):
try:
# print(x + "," + y)
pyautogui.moveRel(float(x), float(y));
return "{}"
except Exception as e:
print( repr(e) )
return render_template('error.html',
title='Error!',
message='Key is not a valid input...')
@app.route('/send-keys', methods=['GET', 'POST'])
def sendKeys():
if request.method == 'POST':
try:
text = str(request.values['text']).strip()
pyautogui.typewrite(text);
# print("\nX: {} Y: {}".format(str(x), str(y)))
# pyautogui.typewrite('Hello world!\n', interval=secs_between_keys) # useful for entering text, newline is Enter
# pyautogui.press(['left', 'left', 'left', 'left']) # Press the left arrow key 4 times.
# pyautogui.keyDown('shift') # Press the Shift key down and hold it.
# pyautogui.keyUp('shift') # Let go of the Shift key.
except Exception as e:
print( repr(e) )
return render_template('error.html',

View File

@ -16,62 +16,66 @@ msgHandler = MessageHandler()
@app.route('/mouse-down')
@socketio.on('mouse_down')
@socketio.on('mouse_down', namespace='/socket.io')
def mouseDown(eve = None):
pyautogui.mouseDown()
return ""
@app.route('/mouse-up')
@socketio.on('mouse_up')
@socketio.on('mouse_up', namespace='/socket.io')
def mouseUp(eve = None):
pyautogui.mouseUp()
return ""
@app.route('/left-click')
@socketio.on('left_click')
@socketio.on('left_click', namespace='/socket.io')
def leftClick(eve = None):
pyautogui.click()
return ""
@app.route('/right-click')
@socketio.on('right_click')
@socketio.on('right_click', namespace='/socket.io')
def rightClick(eve = None):
pyautogui.click(button='right')
return ""
@app.route('/scroll-up')
@socketio.on('scroll_up')
@socketio.on('scroll_up', namespace='/socket.io')
def scrollUp(eve = None):
pyautogui.scroll(1)
return ""
@app.route('/scroll-down')
@socketio.on('scroll_down')
@socketio.on('scroll_down', namespace='/socket.io')
def scrollDown(eve = None):
pyautogui.scroll(-1)
return ""
@app.route('/press-enter')
@socketio.on('press_enter')
@socketio.on('press_enter', namespace='/socket.io')
def pressEnter(eve = None):
pyautogui.press("enter")
return ""
@app.route('/press-back')
@socketio.on('press_back')
@socketio.on('press_back', namespace='/socket.io')
def pressBack(eve = None):
pyautogui.press("backspace")
return ""
@socketio.on('update_coords')
def updateCoords(message):
@app.route('/update-coords/xy/<message>/<message2>')
@socketio.on('update_coords', namespace='/socket.io')
def updateCoords(message = None, message2 = None):
try:
parts = message.split(",")
x = float( parts[0] )
y = float( parts[1] )
# print(str(x) + "," + str(y))
pyautogui.moveRel(x, y);
return ""
except Exception as e:
pass
return ""