swattign all the bugs

meybe fix memory leak
fix a lot of stuff, improvemetns
This commit is contained in:
neon443
2025-03-17 09:00:39 +00:00
parent 4930726372
commit b24df9a77c
7 changed files with 141 additions and 74 deletions

View File

@@ -1,4 +1,6 @@
{ {
"python.analysis.typeCheckingMode" : "strict", "python.analysis.typeCheckingMode" : "strict",
"python.pipRequirements" : "DockPhobiaPy\/requirements.txt" "python.interpreter" : ".\/DockPhobiaPy\/venv\/bin\/python3",
"python.pipRequirements" : "DockPhobiaPy\/requirements.txt",
"python.pythonPath" : "\/Users\/neon443\/Documents\/Xcode\/DockPhobia\/DockPhobiaPy\/venv\/bin\/python3"
} }

View File

@@ -1,17 +0,0 @@
{
"actions" : {
"build" : {
"enabled" : true,
"script" : "#!\/bin\/sh\ncd DockPhobiaPy\npython3 -m venv venv\n. venv\/bin\/activate\npip3 install -r requirements.txt"
},
"clean" : {
"enabled" : true,
"script" : "#!\/bin\/sh\ncd DockPhobiaPy\n. venv\/bin\/activate\npip3 freeze > requirements.txt\nrm -rf venv"
},
"run" : {
"enabled" : true,
"script" : "#!\/bin\/sh\ncd DockPhobiaPy\n. venv\/bin\/activate\npython3 main.py"
}
},
"openLogOnRun" : "start"
}

View File

@@ -0,0 +1,37 @@
{
"actions" : {
"build" : {
"postActions" : [
{
"script" : "cd DockPhobiaPy\npython3 -m venv venv\n. venv\/bin\/activate\npip3 install -r requirements.txt",
"type" : "runScript"
}
]
},
"clean" : {
"postActions" : [
{
"script" : "cd DockPhobiaPy\n. venv\/bin\/activate\npip3 freeze > requirements.txt\nrm -rf venv",
"type" : "runScript"
}
]
},
"run" : {
"postActions" : [
{
"script" : ". DockPhobiaPy\/yvenv\/bin\/activate",
"type" : "runScript"
}
]
}
},
"extension" : {
"identifier" : "panic.Python",
"name" : "Python"
},
"extensionTemplate" : "pythonDebug",
"extensionValues" : {
"python.debug.script" : "main.py",
"python.debug.workingDirectory" : "DockPhobiaPy"
}
}

View File

@@ -0,0 +1,21 @@
{
"actions" : {
"run" : {
"postActions" : [
{
"script" : "python3 main.py",
"type" : "runScript"
}
]
}
},
"extension" : {
"identifier" : "net.danwatson.Python",
"name" : "Python"
},
"extensionTemplate" : "virtualenv",
"extensionValues" : {
"script" : "*Py\/main.py",
"workdir" : "."
}
}

BIN
DockPhobiaPy/.DS_Store vendored
View File

Binary file not shown.

View File

@@ -1,18 +1,19 @@
from pynput.mouse import Button, Controller from pynput.mouse import Controller
import subprocess import subprocess
import time
import AppKit import AppKit
import time
import pdb import pdb
from memory_profiler import profile
mouse = Controller() mouse = Controller()
#while True:
def getDockSide(): def getDockSide():
# pdb.set_trace()
script = "defaults read com.apple.Dock orientation" script = "defaults read com.apple.Dock orientation"
result = subprocess.run(["bash", "-c", script], capture_output=True,text=True) result = subprocess.run(["bash", "-c", script], capture_output=True,text=True)
return result.stdout
formattedResult = result.stdout.strip()
return formattedResult
def moveDock(to): def moveDock(to):
script = f""" script = f"""
@@ -43,7 +44,6 @@ def getScreenSize():
return [] return []
screenSize = getScreenSize() screenSize = getScreenSize()
print(f"Screen size: {screenSize}")
def getDockHeight(): def getDockHeight():
screen = AppKit.NSScreen.mainScreen() screen = AppKit.NSScreen.mainScreen()
@@ -53,36 +53,43 @@ def getDockHeight():
dockHeight = fullHeight - visibleHeight dockHeight = fullHeight - visibleHeight
percentage = (dockHeight / fullHeight) percentage = (dockHeight / fullHeight)
return percentage+0.05 # increase size return percentage
screenSize = getScreenSize()
print(getDockHeight())
print(getScreenSize()) print(getScreenSize())
moveDock("bottom") # moveDock("bottom")
dockSide = "bottom" dockSide = getDockSide()
dockHeight = getDockHeight() startedOutAt = dockSide
print() print()
dockFromBottom = screenSize[1]-(screenSize[1]*dockHeight) def calcDockFromBottom():
# screenSize = getScreenSize()
dockHeight = getDockHeight()
return screenSize[1]-(screenSize[1]*dockHeight)
dockFromBottom = calcDockFromBottom()
print(dockFromBottom) print(dockFromBottom)
print() def calcDockFromLeft():
dockFromLeft = screenSize[1]*dockHeight # screenSize = getScreenSize()
dockHeight = getDockHeight()
return screenSize[1]*dockHeight
dockFromLeft = calcDockFromLeft()
print(dockFromLeft) print(dockFromLeft)
print() def calcDockFromRight():
dockFromRight = screenSize[1]*dockHeight # screenSize = getScreenSize()
dockFromRight = screenSize[0]-(screenSize[1]*dockHeight) dockHeight = getDockHeight()
return screenSize[0]-(screenSize[1]*dockHeight)
dockFromRight = calcDockFromRight()
print(dockFromRight) print(dockFromRight)
@profile
def run_loop():
global dockSide, dockFromBottom, dockFromLeft, dockFromRight, startedOutAt
while True: while True:
# print(dockSide) # for i in range(0,100000):
if dockSide == "bottom": if dockSide == "bottom":
if mouse.position[1] > dockFromBottom: if mouse.position[1] > dockFromBottom:
if mouse.position[0] < screenSize[0]/2: if mouse.position[0] < screenSize[0]/2:
@@ -93,6 +100,7 @@ while True:
moveDock("left") moveDock("left")
dockSide = "left" dockSide = "left"
#mouse is at bottom but on the right of screen #mouse is at bottom but on the right of screen
# neverbeenside = False
elif dockSide == "left": elif dockSide == "left":
if mouse.position[0] < dockFromLeft: if mouse.position[0] < dockFromLeft:
@@ -116,4 +124,17 @@ while True:
dockSide = "left" dockSide = "left"
#mouse is at right but bottom half #mouse is at right but bottom half
# time.sleep(0.01) if startedOutAt == "":
continue
elif startedOutAt == "bottom" and dockSide != "bottom":
# started at bottom, dock is at side, recalc the actuation distance from sides
dockFromLeft = calcDockFromLeft()
dockFromRight = calcDockFromRight()
startedOutAt = ""
elif startedOutAt == "right" or startedOutAt == "left" and dockSide == "bottom":
#started on the side, now at bottom recalc the distance from bottom
dockFromBottom = calcDockFromBottom()
startedOutAt = ""
time.sleep(0.001)
run_loop()

View File

@@ -1,4 +1,7 @@
debugpy==1.8.13
memory-profiler==0.61.0
MouseInfo==0.1.3 MouseInfo==0.1.3
psutil==7.0.0
PyAutoGUI==0.9.54 PyAutoGUI==0.9.54
PyGetWindow==0.0.9 PyGetWindow==0.0.9
PyMsgBox==1.0.9 PyMsgBox==1.0.9