From f7e0ec9ff6f552698c0cabc8ebfd9911d8468f91 Mon Sep 17 00:00:00 2001 From: Maxim Stewart Date: Wed, 1 Jul 2020 21:55:56 -0500 Subject: [PATCH] Fixed typing --- src/core/routes/Routes.py | 6 +-- src/core/routes/Sockets.py | 6 +++ src/core/static/css/main.css | 5 +- src/core/static/js/events.js | 11 ++++ src/core/static/js/main.css | 99 +++++++++++++++++++++++++++++++++++ src/core/templates/index.html | 11 +++- src/linux-start.sh | 2 +- src/socket_run.sh | 3 +- 8 files changed, 132 insertions(+), 11 deletions(-) create mode 100644 src/core/static/js/main.css diff --git a/src/core/routes/Routes.py b/src/core/routes/Routes.py index a73e233..e0fe225 100644 --- a/src/core/routes/Routes.py +++ b/src/core/routes/Routes.py @@ -43,14 +43,12 @@ def updateCoords2(x, y): message='Key is not a valid input...') -@app.route('/send-key', methods=['GET', 'POST']) -def sendKey(): - pyautogui.doubleClick() +@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. diff --git a/src/core/routes/Sockets.py b/src/core/routes/Sockets.py index 32d0931..595a252 100644 --- a/src/core/routes/Sockets.py +++ b/src/core/routes/Sockets.py @@ -57,6 +57,12 @@ def scrollDown(eve = None): pyautogui.scroll(-1) return "" +@app.route('/press-enter') +@socketio.on('press_enter') +def pressEnter(eve = None): + pyautogui.press("enter") + return "" + @socketio.on('update_coords') def updateCoords(message): diff --git a/src/core/static/css/main.css b/src/core/static/css/main.css index ba1a6b5..b98b752 100644 --- a/src/core/static/css/main.css +++ b/src/core/static/css/main.css @@ -63,9 +63,10 @@ input { cursor: pointer; } +#sendKeysBtn, +#pressEnterBtn, #scrollToggle, -#mouseHoldToggle, -#sendKeysBtn { +#mouseHoldToggle { display: inline-block; font-size: 280%; width: 100%; diff --git a/src/core/static/js/events.js b/src/core/static/js/events.js index 32842ad..7fff859 100644 --- a/src/core/static/js/events.js +++ b/src/core/static/js/events.js @@ -114,6 +114,15 @@ function rightClick() { socket.emit('right_click', ""); } +function sendKeys() { + const text = document.getElementById("sendKeysField").value.trim(); + doAjax("/send-keys", "text=" + text, "send-keys"); +} + +function pressEnter() { + socket.emit('press_enter', ""); +} + function scrollToggle() { if (isScrolling) { isScrolling = false; @@ -160,6 +169,8 @@ document.addEventListener("touchend", touchHandler, true); document.addEventListener("touchcancel", touchHandler, true); document.getElementById("rightClickBtn").addEventListener("mouseup", rightClick, true); +document.getElementById("sendKeysBtn").addEventListener("mouseup", sendKeys, true); +document.getElementById("pressEnterBtn").addEventListener("mouseup", pressEnter, true); document.getElementById("scrollToggle").addEventListener("mouseup", scrollToggle, true); document.getElementById("mouseHoldToggle").addEventListener("mouseup", holdToggle, true); diff --git a/src/core/static/js/main.css b/src/core/static/js/main.css new file mode 100644 index 0000000..b98b752 --- /dev/null +++ b/src/core/static/js/main.css @@ -0,0 +1,99 @@ +/* Elms */ +ul, li { + list-style: none; +} + +body { + touch-action: manipulation; + overflow: hidden; /* Used to prevent touch scroll down reloading page. Ref: https://stackoverflow.com/questions/29008194/disabling-androids-chrome-pull-down-to-refresh-feature */ + -webkit-touch-callout: none; /* iOS Safari */ + -webkit-user-select: none; /* Safari */ + -khtml-user-select: none; /* Konqueror HTML */ + -moz-user-select: none; /* Old versions of Firefox */ + -ms-user-select: none; /* Internet Explorer/Edge */ + user-select: none; /* Non-prefixed version, currently + supported by Chrome, Opera and Firefox */ +} + +input { + width: 100% !important; + margin: 0 auto !important; + background-color: #00000000 !important; +} + + +/* IDs */ +#bg { + position: fixed; + top: 0%; + left: 0%; + width: 100%; + height: 100%; + z-index: -999; +} + +#bg img { + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + width: 100%; + height: 100%; + z-index: -999; +} + +#canvas { + position: relative; + width: 98%; + min-height: 1000px; + border: 2px solid #c3c3c3; +} + +#rightClickBtn { + display: none; /* Hide button unless screen bigger than media query says it is */ + border-style: dashed; + border-width: 2px; + overflow: auto; + font-size: 280%; +} + +#rightClickBtn:hover { + background-color: rgba(0, 232, 255, 0.5); + cursor: pointer; +} + +#sendKeysBtn, +#pressEnterBtn, +#scrollToggle, +#mouseHoldToggle { + display: inline-block; + font-size: 280%; + width: 100%; +} + + +@media only screen and (max-device-width: 800px) { + #sendKeysField { + font-size: 300% !important; + } +} + +/* nothing with screen size smaller than 8000px */ +@media only screen and (min-device-width: 801px) { + body { + width: 800px; + margin: 0 auto; + } + + #rightClickBtn { + display: inline-block; + } +} + + +/* Classes */ +/* Other message text colors */ +.errorTxt { color: rgb(170, 18, 18); } +.warningTxt { color: rgb(255, 168, 0); } +.successTxt { color: rgb(136, 204, 39); } diff --git a/src/core/templates/index.html b/src/core/templates/index.html index c1e510c..10f1750 100644 --- a/src/core/templates/index.html +++ b/src/core/templates/index.html @@ -15,8 +15,15 @@

-
- +
+
+ +
+
+
+
+ +


diff --git a/src/linux-start.sh b/src/linux-start.sh index 2c7c315..533cf88 100755 --- a/src/linux-start.sh +++ b/src/linux-start.sh @@ -6,7 +6,7 @@ function main() { - source "/home/abaddon/Portable_Apps/py-venvs/remotemouse-venv/bin/activate" + source "../venv/bin/activate" # Note can replace 127.0.0.1 with 0.0.0.0 to make it 'network/internet' accessable... # Note: NEED -k eventlet for this to work! I spent too many hours on this... gunicorn wsgi:app -b 127.0.0.1:8088 -k eventlet # : IE : diff --git a/src/socket_run.sh b/src/socket_run.sh index f24d350..b1d0f1c 100755 --- a/src/socket_run.sh +++ b/src/socket_run.sh @@ -10,7 +10,6 @@ function main() { cd "${SCRIPTPATH}" echo "Working Dir: " $(pwd) mkdir /tmp/apps - /home/abaddon/Portable_Apps/py-venvs/remotemouse-venv/bin/gunicorn \ - --bind unix:/tmp/apps/remoteconn.sock wsgi:app + ../venv/bin/gunicorn --bind unix:/tmp/apps/remoteconn.sock wsgi:app } main $@;