Created
October 26, 2018 13:35
-
-
Save albcunha/9301bcf204d3aaa5a7cf1e834d82e8c1 to your computer and use it in GitHub Desktop.
Python Script to allow horizontal mouse wrapping on three monitors (it goes from the monitor 1 to monitor 3 and from monitor 3 to monitor 1 if you reach the outer edge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from infi.systray import SysTrayIcon | |
from win32api import GetCursorPos, SetCursorPos | |
import time | |
import multiprocessing | |
import base64 | |
import tempfile | |
# I cant pass a IO Binary, so the solution was to create a tempfile for the icon so I only need one py.file | |
icon = base64.decodebytes(b'''AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAQAABILAAASCw | |
AAAAAAAAAAAAAAAAAAAAAAAGlhZceuqq3/ | |
rqqt/5+anP+TjI7/jYeK/42Hiv+JhIb/kI2P/5CNj/+QjY//YFdaxwAAAAAAAAAAAAAAAAAAAABjXGCbmJGW9oV/gvTn5ef | |
//////////////////////9nW1/+Gf4T0koyP9l9XW5sAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgHh+/7y4uv+ppKf | |
/op2f/6Sgov9wZ2z/AAAAAAAAAAAAAAAAAAAAAAAAAABvZms9b2Zr/29ma/9vZmv/b2Zr/29ma/9vZmv/b2Zr/29ma/9vZmv | |
/b2Zr/29ma/9vZmv/b2Zr/29ma/9vZmtslI6Q/b+9uf+6uLX/vbu4/727uP+7ubf/u7q2/7u6t/+7ubf/u7m2/7u5t/+9u7j/ | |
vbu4/7u5tv+7ubb/hX5//ZeSlPLDxML/XVxd/15cYf9dXGD/XFtg/1xbYP9cW1//XFtf/1xbYP9cW2D/XFxg/15cYP9gXF7/ | |
wcDA/4uFh/KfmZzzyMrQ/39rTv//4If/9tB///fRgf/30YH/99GB//fRgf/30YH/99GB//fQgf//3oP/f2tO/8bIz/ | |
+UjZHzpJ6h89fZ4f9/a07//9uF//PKev/1zH7/9cx+//XMfv/1zH7/9cx+//XMfv/1y37//9h//39rTv/X2OD/nJaY86ukqPPh5ez | |
/mHxW//3Mc//twG//7sJy/+7Ccv/uwnL/7sJy/+7Ccv/uwnL/7cFy//7LcP+YfFb/4OTs/6OcoPO0ra/z9fr//6KDXf/2x3D/6bdj/ | |
+i5ZP/ouGT/6Lhj/+i4Y//ouGP/6Lhk/+i3ZP/2v2D/ooNd//H2//+vqKrzt7Ky8/////+ig13/9s2J/+zFh//sxIP/6sF5/+q/dP/qv3b/6r90 | |
/+rBev/rw4P/9cuE/6KDXf//////t7Cw87u2uPP/////ooNd//DDdv/nvHr/6MB7/+jAfv/owH7/6MB+/+jAfv/owH3/58B7//HAc/ | |
+ig13//////7q1t/O/ubrz/////6KDXf/ru2b/4bZq/+S4a//ktmv/5Lhr/+S4a//kuGv/5Lhr/+O4a//rumH/ooNd//////++t7nzw7y98v//// | |
+ghFj/oIRY/6CEWP+ghFj/oIRY/6CEWP+ghFj/oIRY/6CEWP+ghFj/oIRY/6CEWP//////wrq78sbAwf//////////////////////////////// | |
///////////////////////////////////////////8S9vv/GwMFdxsDB/8bAwf/GwMH/xsDB/8bAwf/GwMH/xsDB/8bAwf/GwMH/xsDB/8bAwf/ | |
GwMH/xsDB/8bAwf/GwMFgwAMAAMADAAD4HwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==''') | |
def monitor_bordeless(): | |
c=0 | |
while c < 100: | |
x, y = GetCursorPos() | |
if x == -1920: | |
SetCursorPos((3838, y)) | |
if x == 3839: | |
SetCursorPos((-1919, y)) | |
time.sleep(0.1) | |
c+=1 | |
def on_quit_callback(systray): | |
p.terminate() | |
p.join() | |
#tf.close() | |
if __name__ == '__main__': | |
tmp_file = tempfile.NamedTemporaryFile() | |
tmp_file.close() | |
with open(tmp_file.name, 'wb') as f: | |
f.write(icon) | |
p = multiprocessing.Process(target=monitor_bordeless, args=[]) | |
systray = SysTrayIcon(tmp_file.name, "Three Monitors", on_quit=on_quit_callback) | |
p.start() | |
systray.start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment